Skip to content

Commit

Permalink
global: changes for YODA1 format and other updates
Browse files Browse the repository at this point in the history
* Changes needed to work with hepdata-converter v0.3.0 release.
* Upgrade actions to their latest versions and switch to Python 3.10.
* Rename 'master' branch to 'main'.
* Switch to PyPI's trusted publishing.
* Remove dependence on distlib.
* Use file extension .yoda for both YODA1 and YODA2 formats.
* Bump version to 0.3.0 for new release.
  • Loading branch information
GraemeWatt committed Nov 14, 2023
1 parent cff1377 commit 15dd396
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Continuous Integration
on:
push:
pull_request:
branches: [ master ]
branches: [ main ]
release:
types: [ published ]

Expand All @@ -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 }}
Expand All @@ -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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion hepdata_converter_ws/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

__author__ = 'Michał Szostak'

SINGLEFILE_FORMATS = ['root', 'yoda']
SINGLEFILE_FORMATS = ['root', 'yoda', 'yoda1']


@api.route('/debug-sentry')
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion hepdata_converter_ws/testsuite/test_server.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion hepdata_converter_ws/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

test_requirements = [
'distlib',
'coverage',
]

extras_require = {
Expand All @@ -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,
Expand Down

0 comments on commit 15dd396

Please sign in to comment.