diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09e2581..648d829 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Continuous Integration on: push: pull_request: - branches: [ master ] + branches: [ main ] release: types: [ published ] @@ -14,22 +14,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.10' - name: Install pip dependencies run: | pip install --upgrade pip - pip install --ignore-installed coveralls + pip install coveralls - name: Run tests env: - DOCKER_IMAGE: hepdata/hepdata-converter:0.2.0 + DOCKER_IMAGE: hepdata/hepdata-converter:latest run: | export CURRENT_PATH=`pwd` - docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && coverage run -m unittest discover hepdata_converter/testsuite 'test_*'" - docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && python3 setup.py install && hepdata-converter -v" + docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && pip install -e '.[tests]' && hepdata-converter -v && coverage run -m unittest discover hepdata_converter/testsuite 'test_*'" - name: Run coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -42,14 +41,14 @@ jobs: if: github.event_name == 'release' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build PyPI package env: - DOCKER_IMAGE: hepdata/hepdata-converter:0.2.0 + DOCKER_IMAGE: hepdata/hepdata-converter:latest run: | export CURRENT_PATH=`pwd` - docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && pip3 install wheel" - docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && python3 setup.py sdist bdist_wheel" + docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && pip install wheel" + docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c "cd $CURRENT_PATH && python setup.py sdist bdist_wheel" - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@master with: diff --git a/.gitignore b/.gitignore index e922ee0..1fa3335 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,7 @@ README.html target/ .idea -MANIFEST \ No newline at end of file +MANIFEST + +# venv +venv/ \ No newline at end of file diff --git a/.readthedocs.yml b/.readthedocs.yml index 9126fe7..49d517c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -5,18 +5,27 @@ # Required version: 2 -# Build documentation in the docs/ directory with Sphinx +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.10" + +# Build documentation in the "docs/" directory with Sphinx sphinx: configuration: docs/conf.py + # Fail on all warnings to avoid broken references + fail_on_warning: true # Optionally build your docs in additional formats such as PDF and ePub formats: all -# Optionally set the version of Python and requirements required to build your docs +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: - version: 3.7 install: - - method: pip - path: . - extra_requirements: - - docs + - method: pip + path: . + extra_requirements: + - docs \ No newline at end of file diff --git a/README.rst b/README.rst index 491571a..1c127f5 100644 --- a/README.rst +++ b/README.rst @@ -3,16 +3,16 @@ HEPData Converter ================= -.. image:: https://github.com/HEPData/hepdata-converter/workflows/Continuous%20Integration/badge.svg?branch=master - :target: https://github.com/HEPData/hepdata-converter/actions?query=branch%3Amaster +.. image:: https://github.com/HEPData/hepdata-converter/actions/workflows/ci.yml/badge.svg?branch=main + :target: https://github.com/HEPData/hepdata-converter/actions?query=branch%3Amain :alt: GitHub Actions Build Status -.. image:: https://coveralls.io/repos/github/HEPData/hepdata-converter/badge.svg?branch=master - :target: https://coveralls.io/github/HEPData/hepdata-converter?branch=master +.. image:: https://coveralls.io/repos/github/HEPData/hepdata-converter/badge.svg?branch=main + :target: https://coveralls.io/github/HEPData/hepdata-converter?branch=main :alt: Coveralls Status .. image:: https://img.shields.io/github/license/HEPData/hepdata-converter.svg - :target: https://github.com/HEPData/hepdata-converter/blob/master/LICENSE.txt + :target: https://github.com/HEPData/hepdata-converter/blob/main/LICENSE.txt :alt: License .. image:: https://img.shields.io/github/release/hepdata/hepdata-converter.svg?maxAge=2592000 @@ -34,11 +34,11 @@ HEPData Converter This Python 3 library provides support for converting: -* Old HepData input format (`sample `_) to `YAML `_ +* Old HepData input format (`sample `_) to `YAML `_ * `YAML `_ to: - * `ROOT `_ (tested with v6.22/02) - * `YODA `_ (tested with v1.8.3) + * `ROOT `_ (tested with v6.28/04) + * `YODA `_ (tested with v2.0.0alpha) * `CSV `_ -Documentation: http://hepdata-converter.readthedocs.io +Documentation: https://hepdata-converter.readthedocs.io diff --git a/docker b/docker index 0ed81ed..69c45fb 160000 --- a/docker +++ b/docker @@ -1 +1 @@ -Subproject commit 0ed81edba47dd6dcaf4f35710996207c853b1bcc +Subproject commit 69c45fb5b8fcfff2baf81616fd15d55b1ba26752 diff --git a/docs/conf.py b/docs/conf.py index e7cea37..f1960ca 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -98,7 +98,7 @@ def __getattr__(cls, name): # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -340,4 +340,4 @@ def __getattr__(cls, name): # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/2/': None} +intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)} diff --git a/docs/installation.rst b/docs/installation.rst index 30b5316..7d7abdb 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -33,12 +33,13 @@ alternative output formats via the web interface. To install this package locally, you first need to install `YODA `_ and `ROOT `_ (including `PyROOT `_). Check that you can -``import yoda`` and ``import ROOT`` from Python. You might want to install into a dedicated virtual -environment: +``import yoda`` and ``import ROOT`` from Python. You might want to install into a dedicated `virtual environment +`_: .. code-block:: console - $ mkvirtualenv hepdata-converter + $ python3 -m venv hepdata-converter + $ source hepdata-converter/bin/activate (hepdata-converter)$ pip install hepdata-converter This will install the latest released version from `PyPI `_. @@ -52,10 +53,11 @@ Developers might want to instead install the project directly from .. code-block:: console - $ workon hepdata-converter - (hepdata-converter)$ git clone https://github.com/HEPData/hepdata-converter - (hepdata-converter)$ cd hepdata-converter - (hepdata-converter)$ pip install -e . + $ git clone https://github.com/HEPData/hepdata-converter + $ cd hepdata-converter + $ python3 -m venv venv + $ source venv/bin/activate + (venv)$ pip install -e '.[tests]' Developers can then run the tests with the following command: @@ -80,9 +82,9 @@ The ``hepdata-converter`` package can be installed inside the Docker container: .. code-block:: console - root@617be04cbab5:/# pip3 install --ignore-installed hepdata-converter + root@617be04cbab5:/# pip install hepdata-converter root@617be04cbab5:/# hepdata-converter -h - root@617be04cbab5:/# python3 -c 'import hepdata_converter' + root@617be04cbab5:/# python -c 'import hepdata_converter' Note that the Docker container will be automatically removed when it exits (if running with the ``--rm`` option). The Python module or CLI can then be used as described in :doc:`Usage `. Input and output files can be moved @@ -105,7 +107,7 @@ mount the current directory of the local filesystem when running the Docker cont $ git clone https://github.com/HEPData/hepdata-converter $ cd hepdata-converter $ docker run -v $PWD:$PWD -w $PWD --rm -it hepdata/hepdata-converter /bin/bash - root@2c22e88402d2:/hepdata-converter# python3 -m unittest discover hepdata_converter/testsuite 'test_*' - root@2c22e88402d2:/hepdata-converter# pip3 install -e . + root@2c22e88402d2:/hepdata-converter# pip install -e '.[tests]' root@2c22e88402d2:/hepdata-converter# hepdata-converter -h - root@2c22e88402d2:/hepdata-converter# python3 -c 'import hepdata_converter' + root@2c22e88402d2:/hepdata-converter# python -c 'import hepdata_converter' + root@2c22e88402d2:/hepdata-converter# python -m unittest discover hepdata_converter/testsuite 'test_*' \ No newline at end of file diff --git a/docs/usage.rst b/docs/usage.rst index 127c9a3..c018c71 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -26,7 +26,7 @@ Usage ===== The library exposes a single function ``convert`` which enables conversion from different input formats -(``oldhepdata``, ``yaml``) to different output formats (``csv``, ``root``, ``yaml``, ``yoda``), by using a simple in-memory +(``oldhepdata``, ``yaml``) to different output formats (``csv``, ``root``, ``yaml``, ``yoda``, ``yoda1``), by using a simple in-memory intermediary format. diff --git a/hepdata_converter/__init__.py b/hepdata_converter/__init__.py index e9937e7..7863499 100644 --- a/hepdata_converter/__init__.py +++ b/hepdata_converter/__init__.py @@ -9,7 +9,7 @@ def convert(input, output=None, options={}): """Converts a supported ``input_format`` (*oldhepdata*, *yaml*) - to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*). + to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*, *yoda1*). :param input: location of input file for *oldhepdata* format or input directory for *yaml* format :param output: location of output directory to which converted files will be written diff --git a/run_tests.sh b/run_tests.sh index cdf1ea0..8ee98a6 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -4,4 +4,4 @@ export CURRENT_PATH=`pwd` export DOCKER_IMAGE=${DOCKER_IMAGE:-"hepdata/hepdata-converter"} docker run -v $CURRENT_PATH:$CURRENT_PATH $DOCKER_IMAGE /bin/bash -c \ - "cd $CURRENT_PATH && coverage run -m unittest discover hepdata_converter/testsuite 'test_*'" + "cd $CURRENT_PATH && pip install -e '.[tests]' && coverage run -m unittest discover hepdata_converter/testsuite 'test_*'" diff --git a/setup.py b/setup.py index 50632d0..69d0467 100644 --- a/setup.py +++ b/setup.py @@ -30,22 +30,19 @@ def get_version(): long_description = fp.read() -extras_require = {'docs': ['Sphinx>=1.4.2', 'mock'], - 'all': []} - setup( name='hepdata-converter', version=get_version(), - install_requires=[ - 'pyyaml>=5.3', - 'hepdata-validator>=0.2.2' - ], + install_requires=['hepdata-validator>=0.3.5'], entry_points={ 'console_scripts': [ 'hepdata-converter = hepdata_converter:main', ] }, - extras_require=extras_require, + extras_require={ + 'docs': ['Sphinx>=1.4.2', 'mock'], + 'tests': ['coverage>=5.1'], + }, packages=['hepdata_converter', 'hepdata_converter.parsers', 'hepdata_converter.writers', 'hepdata_converter.testsuite'], package_data={'hepdata_converter': get_all_datafiles(package='hepdata_converter/testsuite', path='testdata')}, include_package_data=True,