Skip to content

Commit

Permalink
Merge pull request #19 from rtesse/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
Robin Tesse authored Mar 27, 2023
2 parents e12139f + 7e73f14 commit 281704f
Show file tree
Hide file tree
Showing 49 changed files with 4,697 additions and 3,285 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python: ['3.8', '3.9', '3.10']
os: [ubuntu-latest]
python: ["3.8", "3.9", "3.10"]
steps:
#----------------------------------------------
# check-out repo and set-up python
Expand All @@ -44,11 +44,13 @@ jobs:
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction --with dev
run: |
poetry config virtualenvs.create true --local
poetry install --no-interaction --with dev
#----------------------------------------------
# run test suite with Sonar
#----------------------------------------------
- name: Run tox
- name: Run pytest
run: |
source .venv/bin/activate
tox -e py
pytest
6 changes: 4 additions & 2 deletions .github/workflows/code_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ jobs:
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction --with dev
run: |
poetry config virtualenvs.create true --local
poetry install --no-interaction --with dev
#----------------------------------------------
# run flake8
#----------------------------------------------
- name: Run tox
- name: Run flake8
run: |
source .venv/bin/activate
flake8
13 changes: 9 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ jobs:
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction --with dev
run: |
poetry config virtualenvs.create true --local
poetry install --no-interaction --with dev
#----------------------------------------------
# run test suite with Sonar
#----------------------------------------------
- name: Run tox
- name: Run pytest
run: |
source .venv/bin/activate
tox -e py
export NUMBA_DISABLE_JIT=1
coverage run -m pytest
coverage xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/deploy_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install dependencies
run: poetry install --no-interaction --with docs
run: |
poetry config virtualenvs.create true --local
poetry install --no-interaction --with docs
- name: Run sphinx for html
run: |
source .venv/bin/activate
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images

name: Create and publish a Docker image

on:
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 3 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction --with docs
run: |
poetry config virtualenvs.create true --local
poetry install --no-interaction --with docs
#----------------------------------------------
# Built the doc
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ coverage.xml
.tox/
docs/build
docs/jupyter_execute
.vscode/
.conda_config
dist/
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ repos:
exclude: 'rst'
- id: trailing-whitespace
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.3.0
rev: v2.4.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/kynan/nbstripout
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
FROM python:3.8
FROM python:3.10
RUN apt-get update \
&& apt-get install --no-install-recommends -y libgl1

ENV GIT_SSL_NO_VERIFY=1

# Configure Poetry
ENV POETRY_VERSION=1.2.0
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Install poetry separated from system interpreter
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
&& $POETRY_VENV/bin/pip install poetry

# Add `poetry` to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

WORKDIR /home
RUN git clone --recurse-submodules --branch develop https://github.com/rtesse/georges-core.git
RUN git clone --branch master https://github.com/ULB-Metronu/georges-core.git
RUN poetry config virtualenvs.in-project true
WORKDIR /home/georges-core
RUN poetry install
Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# georges-core
# Georges' accelerator physics library - Core

[![ci](https://github.com/ULB-Metronu/georges-core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/ULB-Metronu/georges-core/actions/workflows/ci.yml)
[![documentation](https://github.com/ULB-Metronu/georges-core/actions/workflows/documentation.yml/badge.svg?branch=master)](https://github.com/ULB-Metronu/georges-core/actions/workflows/documentation.yml)
Expand All @@ -13,4 +13,35 @@
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Gitter](https://badges.gitter.im/ULB-Metronu/georges-core.svg)](https://gitter.im/ULB-Metronu/georges-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Georges' accelerator physics library - Core

Georges-core is a Python3 library that provides a lot of basic functionalities for other libraries such as Zgoubidoo or Georges. Among the different modules, we have :

* The Kinematics module
* The beam's distribution generator
* The Twiss computation
* The plotting module
* The sequence converter

## Design
The aim of this library is to unify the description of particle accelerator beamlines for different tools
(MAD-X, MAD-NG and BDSIM at this stage) in a unique Python library.

The library design strongly follows conventions and typical uses of the *Pandas* library:
beamlines are naturally described as *Dataframes*.
A functional approach is also one of the design goal of the library, something which fits well with
*Pandas*.

Beamlines are loaded and converted using functions split in packages (one package per beam physics code, *e.g.* MAD-X or BDSIM)
in a unique format (`georges-core.Sequence`). This object serves as an input for other tracking code such as Manzoni or Zgoubidoo.

Twiss computation is also provided especially in coupled Twiss computation.

Support tools are also provided, notably a plotting library (based on *Matplotlib* or *Plotly*)

## Installation

`georges-core` is available from PyPI with pip::

pip install georges-core

For a custom installation, please read the installation section in the [documentation](https://ulb-metronu.github.io/georges-core/installation.html).
2 changes: 1 addition & 1 deletion docs/api/georges_core.sequences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ georges\_core.sequences.betablock module
georges\_core.sequences.elements module
---------------------------------------

.. automodule:: georges_core.sequences.elements
.. automodule:: Elements
:members:
:undoc-members:
:show-inheritance:
Expand Down
13 changes: 11 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ Changelog

* 2023-xx

* Write the documentation for Twiss module
* Adapt the Twiss module for 13 particles
* Add installation section for Conda
* Remove tox and add doctesting
* Write a README file
* Fix small issues in sequences/BDSIMSequence
* Update pybdsim in pyproject.toml
* Fix in the documentation

.. todolist::

* 2022-1

* 2022-1
* Write the documentation
* Refactor entire library
* Implement tests
* Add geometry module
* Improve bean distribution generation
* Improve beam distribution generation
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ to ensure consistent Python code. All the parameters are described in the `pypro

Testing and metrics
###################
All the tests are available in the georges-cores's test repository. We use `pytest <https://docs.pytest.org/en/7.2.x/>`_ as a tool for testing and
through `tox <https://tox.wiki/en/latest/>`_ and the results are then passed to `coverage` and uploaded to `sonar <https://www.sonarsource.com/products/sonarcloud/>`_
All the tests are available in the georges-cores's test repository. We use `pytest <https://docs.pytest.org/en/7.2.x/>`_ as a tool for testing
and the results are then passed to `coverage` and uploaded to `sonar <https://www.sonarsource.com/products/sonarcloud/>`_
to compute metrics such as:

* Bugs
Expand Down
11 changes: 9 additions & 2 deletions docs/examples/converters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
Conversion of a sequence
************************

Blabla.
Georges-core can convert different output files into an object of type sequence. As an example,
the user can provide an output file from:
* MAD-X
* MAD-NG
* TRANSPORT
* BDSIM
* CSV File (SURVEY)

.. jupyter-execute::
:hide-output:
Expand Down Expand Up @@ -54,7 +60,8 @@ Load a Transport file

Load a CSV file (survey file)
#############################
Structure du fichier csv, ...
A survey file is a `.csv` file containing the elements' information as the NAME or the TYPE of
the element. The user can provide a survey in a global reference frame (`X, Y, Z`) or in a Frenet-Serret (`S, L`)

.. jupyter-execute::
:hide-output:
Expand Down
29 changes: 26 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
Welcome to Georges-core's documentation!
****************************************

|Actions Status| |Documentation Status|
|Actions Status| |Documentation Status| |Python version| |version| |Bugs| |Coverage| |Reliability|
|License| |Code Style|

Introduction
############
Georges_core is a Python3 library that provides a lot of basic functionalities for other libraries such as Zgoubidoo or Georges. Among the different modules, we have :
Georges-core is an open source project hosted on Github under the GNU General Public Licence (GPL) version 3. It is a Python3 library that provides a lot of basic functionalities for other libraries such as Zgoubidoo or Georges. Among the different modules, we have :

* The Kinematics module
* The beam's distribution generator
* The Twiss computation
* The plotting module
* The sequence converter

Georges-core's documentation
============================

The documentation is part of the Georges-core repository itself and is made available *via* `Github Pages <https://pages.github.com>`_ .
It is hosted at `ulb-metronu.github.io/georges-core/ <https://ulb-metronu.github.io/georges-core/>`_

Expand Down Expand Up @@ -63,4 +67,23 @@ Indices and tables
:target: https://github.com/ULB-Metronu/georges-core/actions

.. |Documentation Status| image:: https://github.com/ULB-Metronu/georges-core/actions/workflows/documentation.yml/badge.svg?branch=master
:target: https://github.com/ULB-Metronu/georges-core/actions
:target: https://github.com/ULB-Metronu/georges-core/actions

.. |Python version| image:: _static/python_versions.svg

.. |version| image:: https://img.shields.io/badge/version-2022.1-blue

.. |Bugs| image:: https://sonarcloud.io/api/project_badges/measure?project=ULB-Metronu_georges-core&metric=bugs
:target: https://sonarcloud.io/summary/new_code?id=ULB-Metronu_georges-core

.. |Coverage| image:: https://sonarcloud.io/api/project_badges/measure?project=ULB-Metronu_georges-core&metric=coverage
:target: https://sonarcloud.io/summary/new_code?id=ULB-Metronu_georges-core

.. |Reliability| image:: https://sonarcloud.io/api/project_badges/measure?project=ULB-Metronu_georges-core&metric=reliability_rating
:target: https://sonarcloud.io/summary/new_code?id=ULB-Metronu_georges-core

.. |License| image:: https://img.shields.io/badge/License-GPLv3-blue.svg
:target: https://www.gnu.org/licenses/gpl-3.0

.. |Code Style| image:: https://img.shields.io/badge/codestyle-black-000000.svg
:target: https://github.com/ambv/black
Loading

0 comments on commit 281704f

Please sign in to comment.