diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b471c57..505f4f4 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 run: | export CURRENT_PATH=`pwd` - docker run -v $CURRENT_PATH:$CURRENT_PATH hepdata/hepdata-converter /bin/bash -c "cd $CURRENT_PATH && pip3 install -I -e .[tests] && coverage run -m unittest discover hepdata_converter_ws/testsuite 'test_*'" - docker run -v $CURRENT_PATH:$CURRENT_PATH hepdata/hepdata-converter /bin/bash -c "cd $CURRENT_PATH && pip3 install -I -e . && hepdata-converter-ws -v" + docker run -v $CURRENT_PATH:$CURRENT_PATH hepdata/hepdata-converter /bin/bash -c "cd $CURRENT_PATH && pip install -e '.[tests]' && hepdata-converter-ws -v && coverage run -m unittest discover hepdata_converter_ws/testsuite 'test_*'" - name: Run coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -41,17 +40,18 @@ jobs: needs: test if: github.event_name == 'release' runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/hepdata-converter-ws + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build PyPI package env: DOCKER_IMAGE: hepdata/hepdata-converter 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 && python setup.py sdist bdist_wheel" - name: Publish distribution to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index b0f8242..6904651 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![GitHub Actions Status](https://github.com/HEPData/hepdata-converter-ws/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/HEPData/hepdata-converter-ws/actions?query=branch%3Amaster) -[![Coveralls Status](https://coveralls.io/repos/github/HEPData/hepdata-converter-ws/badge.svg?branch=master)](https://coveralls.io/github/HEPData/hepdata-converter-ws?branch=master) -[![License](https://img.shields.io/github/license/HEPData/hepdata-converter-ws.svg)](https://github.com/HEPData/hepdata-converter-ws/blob/master/LICENSE.txt) +[![GitHub Actions Status](https://github.com/HEPData/hepdata-converter-ws/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/HEPData/hepdata-converter-ws/actions?query=branch%3Amain) +[![Coveralls Status](https://coveralls.io/repos/github/HEPData/hepdata-converter-ws/badge.svg?branch=main)](https://coveralls.io/github/HEPData/hepdata-converter-ws?branch=main) +[![License](https://img.shields.io/github/license/HEPData/hepdata-converter-ws.svg)](https://github.com/HEPData/hepdata-converter-ws/blob/main/LICENSE.txt) [![GitHub Releases](https://img.shields.io/github/release/hepdata/hepdata-converter-ws.svg?maxAge=2592000)](https://github.com/HEPData/hepdata-converter-ws/releases) [![PyPI Version](https://img.shields.io/pypi/v/hepdata-converter-ws)](https://pypi.org/project/hepdata-converter-ws/) [![GitHub Issues](https://img.shields.io/github/issues/hepdata/hepdata-converter-ws.svg?maxAge=2592000)](https://github.com/HEPData/hepdata-converter-ws/issues) @@ -30,7 +30,7 @@ input: Base64 encoded tar.gz file containing hepdata-converter-ws-data entry (di id: str used for caching purposes (same input files have to have same ID), not implemented? options: dictionary with options accepted by hepdata_converter.convert function. The most important are: input_format: (input format identifier e.g. yaml, oldhepdata, etc.) - output_format: (output format identifier e.g. yaml, root, yoda, csv, etc.) + output_format: (output format identifier e.g. yaml, root, yoda, yoda1, csv, etc.) other options are dependent on the input / output format and are documented in their respective parsers / readers in https://github.com/HEPData/hepdata-converter } @@ -40,7 +40,7 @@ options: dictionary with options accepted by hepdata_converter.convert function. The response has MIME type `application/x-gzip` and is a tar.gz file containing the hepdata-converter-ws-data directory with the -requested file / files. +requested file/files. ## API Usage diff --git a/hepdata_converter_ws/api.py b/hepdata_converter_ws/api.py index d67ebe7..b65a68e 100644 --- a/hepdata_converter_ws/api.py +++ b/hepdata_converter_ws/api.py @@ -13,7 +13,7 @@ __author__ = 'MichaƂ Szostak' -SINGLEFILE_FORMATS = ['root', 'yoda'] +SINGLEFILE_FORMATS = ['root', 'yoda', 'yoda1'] @api.route('/debug-sentry') @@ -60,6 +60,7 @@ def convert(): kwargs.get('options', {})) if not os.path.isdir(conversion_output): + output_format = output_format[:-1] if output_format == 'yoda1' else output_format archive_name = archive_name + '.' + output_format with tarfile.open(mode='w:gz', fileobj=output) as tar: diff --git a/hepdata_converter_ws/testsuite/test_server.py b/hepdata_converter_ws/testsuite/test_server.py index 9982a27..9e17c99 100644 --- a/hepdata_converter_ws/testsuite/test_server.py +++ b/hepdata_converter_ws/testsuite/test_server.py @@ -1,6 +1,5 @@ # -*- encoding: utf-8 -*- from io import BytesIO -from distlib._backport import tarfile import os import tarfile from flask import jsonify, json diff --git a/hepdata_converter_ws/version.py b/hepdata_converter_ws/version.py index ee75f70..91b0e0b 100644 --- a/hepdata_converter_ws/version.py +++ b/hepdata_converter_ws/version.py @@ -2,4 +2,4 @@ # this file ideally should only contain __version__ declaration, as anything else # may break setup.py and PyPI uploads -__version__ = '0.2.0' +__version__ = '0.3.0' diff --git a/setup.py b/setup.py index 32f724e..c4c072e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import re test_requirements = [ - 'distlib', + 'coverage', ] extras_require = { @@ -29,9 +29,9 @@ def get_version(): name='hepdata-converter-ws', version=get_version(), install_requires=[ - 'hepdata-converter>=0.2', - 'flask>=1.1.1,<2', - 'sentry-sdk[flask]==0.15.1' + 'hepdata-converter>=0.3', + 'flask', + 'sentry-sdk[flask]', ], extras_require=extras_require, tests_require=test_requirements,