Skip to content

Commit

Permalink
Merge branch 'main' into submission-linking
Browse files Browse the repository at this point in the history
  • Loading branch information
ItIsJordan committed Jul 6, 2023
2 parents 6e0619c + 8a56cb8 commit 85458d6
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 34 deletions.
20 changes: 10 additions & 10 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 ]
schedule:
Expand All @@ -16,12 +16,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
python-version: [ '3.7', '3.8', '3.9' ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pip dependencies
Expand All @@ -39,7 +39,7 @@ jobs:
env:
COVERAGE_FILE: '.coverage_libyaml'
- name: Run coveralls
if: startsWith(matrix.python-version, '3.8')
if: startsWith(matrix.python-version, '3.9')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
Expand All @@ -52,17 +52,17 @@ jobs:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.9'
- name: Build PyPI package
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
25 changes: 25 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
fail_on_warning: true

# Optionally declare the Python requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- docs
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
HEPData Validator
==================

.. image:: https://github.com/HEPData/hepdata-validator/workflows/Continuous%20Integration/badge.svg?branch=master
:target: https://github.com/HEPData/hepdata-validator/actions?query=branch%3Amaster
.. image:: https://github.com/HEPData/hepdata-validator/workflows/Continuous%20Integration/badge.svg?branch=main
:target: https://github.com/HEPData/hepdata-validator/actions?query=branch%3Amain
:alt: GitHub Actions Build Status

.. image:: https://coveralls.io/repos/github/HEPData/hepdata-validator/badge.svg?branch=master
:target: https://coveralls.io/github/HEPData/hepdata-validator?branch=master
.. image:: https://coveralls.io/repos/github/HEPData/hepdata-validator/badge.svg?branch=main
:target: https://coveralls.io/github/HEPData/hepdata-validator?branch=main
:alt: Coveralls Status

.. image:: https://img.shields.io/github/license/HEPData/hepdata-validator.svg
:target: https://github.com/HEPData/hepdata-validator/blob/master/LICENSE.txt
:target: https://github.com/HEPData/hepdata-validator/blob/main/LICENSE.txt
:alt: License

.. image:: https://img.shields.io/github/release/hepdata/hepdata-validator.svg?maxAge=2592000
Expand All @@ -27,12 +27,12 @@
:alt: GitHub Issues

.. image:: https://readthedocs.org/projects/hepdata-validator/badge/?version=latest
:target: http://hepdata-validator.readthedocs.io/en/latest/?badge=latest
:target: https://hepdata-validator.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

JSON schema and validation code (in Python 3) for HEPData submissions

* Documentation: http://hepdata-validator.readthedocs.io
* Documentation: https://hepdata-validator.readthedocs.io


Installation
Expand Down Expand Up @@ -65,16 +65,17 @@ Developers should install from GitHub in a `virtual environment <https://docs.py
$ git clone https://github.com/HEPData/hepdata-validator
$ cd hepdata-validator
$ python3 -m venv ~/venv/hepdata-validator
$ source ~/venv/hepdata-validator/bin/activate
(hepdata-validator) $ pip install --upgrade -e ".[tests]"
$ python3.9 -m venv venv
$ source venv/bin/activate
(venv)$ pip install --upgrade pip
(venv)$ pip install --upgrade -e ".[all]"
Tests should be run both with and without LibYAML, as error messages from the different YAML parsers vary:

.. code:: bash
(hepdata-validator) $ USE_LIBYAML=True pytest testsuite
(hepdata-validator) $ USE_LIBYAML=False pytest testsuite
(venv) $ USE_LIBYAML=True pytest testsuite
(venv) $ USE_LIBYAML=False pytest testsuite
Usage
-----
Expand Down Expand Up @@ -266,7 +267,7 @@ Schema Versions
---------------

When considering **native HEPData JSON schemas**, there are multiple `versions
<https://github.com/HEPData/hepdata-validator/tree/master/hepdata_validator/schemas>`_.
<https://github.com/HEPData/hepdata-validator/tree/main/hepdata_validator/schemas>`_.
In most cases you should use the **latest** version (the default). If you need to use a different version,
you can pass a keyword argument ``schema_version`` when initialising the validator:

Expand Down
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
# The root toctree document.
root_doc = 'index'

# General information about the project.
project = u''
Expand All @@ -85,7 +85,7 @@
#
# 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:
Expand Down Expand Up @@ -265,7 +265,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'HEPData-Validator.tex', u'HEPData Documentation',
(root_doc, 'HEPData-Validator.tex', u'HEPData Documentation',
u'CERN', 'manual'),
]

Expand Down Expand Up @@ -295,7 +295,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'HEPData Validator', u'HEPData Validator Documentation',
(root_doc, 'HEPData Validator', u'HEPData Validator Documentation',
[author], 1)
]

Expand All @@ -309,7 +309,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'HEPData Validator', u'HEPData Validator Documentation',
(root_doc, 'HEPData Validator', u'HEPData Validator Documentation',
author, 'HEPData Validator', 'Submission schemas and validation for HEPData.',
'Miscellaneous'),
]
Expand All @@ -328,4 +328,4 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3/': None}
intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)}
1 change: 0 additions & 1 deletion hepdata_validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import abc
import os

from jsonschema import validate as json_validate, ValidationError
from jsonschema.validators import validator_for
from jsonschema.exceptions import by_relevance
from packaging import version as packaging_version
Expand Down
10 changes: 9 additions & 1 deletion hepdata_validator/data_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def check_length_values(self, file_path, data):
"""
Check that the length of the 'values' list is consistent for
each of the independent_variables and dependent_variables.
Adds validation error if uncertainties are all zero.
Invalidate only independent_variables but no dependent_variables.
:param data: data table in YAML format
"""
Expand All @@ -260,6 +260,14 @@ def check_length_values(self, file_path, data):
instance=data
)
self.add_validation_error(file_path, error)
if indep_count and not dep_count: # only independent_variables
error = ValidationError(
"Case of only independent_variables but no dependent_variables is not supported: " +
"independent_variables %s, dependent_variables %s" % (str(indep_count), str(dep_count)),
instance=data
)
self.add_validation_error(file_path, error)


def convert_to_float(self, error, file_path, path, instance):
"""
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

extras_require = {
'all': [],
'docs': ['Sphinx>=1.4.2'],
'docs': ['Sphinx>7'],
'tests': test_requirements,
}

for name, reqs in extras_require.items():
extras_require['all'].extend(reqs)

class PyTest(TestCommand):
"""PyTest Test."""
Expand Down Expand Up @@ -92,7 +94,7 @@ def run_tests(self):
test_suite='hepdata_validator.testsuite',
tests_require=test_requirements,
cmdclass={'test': PyTest},
python_requires='>=3.6',
python_requires='>=3.7',
entry_points={
'console_scripts': ['hepdata-validate=hepdata_validator.cli:validate'],
}
Expand Down
128 changes: 128 additions & 0 deletions testsuite/test_data/binning_average.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
dependent_variables: []
independent_variables:
- header:
name: Bin
values:
- value: 0
- value: 1
- value: 2
- value: 3
- value: 4
- value: 5
- value: 6
- value: 7
- value: 8
- value: 9
- value: 10
- value: 11
- value: 12
- value: 13
- value: 14
- value: 15
- value: 16
- value: 17
- value: 18
- value: 19
- value: 20
- value: 21
- value: 22
- value: 23
- value: 24
- value: 25
- value: 26
- value: 27
- value: 28
- value: 29
- value: 30
- value: 31
- value: 32
- value: 33
- value: 34
- value: 35
- value: 36
- value: 37
- value: 38
- value: 39
- header:
name: Bin
values:
- high: 1.05
low: 1.0
- high: 1.1
low: 1.05
- high: 1.15
low: 1.1
- high: 1.2
low: 1.15
- high: 1.25
low: 1.2
- high: 1.3
low: 1.25
- high: 1.35
low: 1.3
- high: 1.4
low: 1.35
- high: 1.45
low: 1.4
- high: 1.5035
low: 1.45
- high: -0.8
low: -1.0
- high: -0.6
low: -0.8
- high: -0.4
low: -0.6
- high: -0.2
low: -0.4
- high: 0.0
low: -0.2
- high: 0.2
low: 0.0
- high: 0.4
low: 0.2
- high: 0.6
low: 0.4
- high: 0.8
low: 0.6
- high: 1.0
low: 0.8
- high: -0.8
low: -1.0
- high: -0.6
low: -0.8
- high: -0.4
low: -0.6
- high: -0.2
low: -0.4
- high: 0.0
low: -0.2
- high: 0.2
low: 0.0
- high: 0.4
low: 0.2
- high: 0.6
low: 0.4
- high: 0.8
low: 0.6
- high: 1.0
low: 0.8
- high: 0.62832
low: 0.0
- high: 1.2566
low: 0.62832
- high: 1.885
low: 1.2566
- high: 2.5133
low: 1.885
- high: 3.1416
low: 2.5133
- high: 3.7699
low: 3.1416
- high: 4.3982
low: 3.7699
- high: 5.0265
low: 4.3982
- high: 5.6549
low: 5.0265
- high: 6.2832
low: 5.6549
Loading

0 comments on commit 85458d6

Please sign in to comment.