Skip to content

Commit da8e532

Browse files
Merge pull request #31 from N3PDF/checks
Add checks and Implement better packaging & versioning
2 parents 24a297f + e5f65ed commit da8e532

22 files changed

+264
-262
lines changed

.bumpversion.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[bumpversion]
2+
commit = True
3+
tag = True
4+
current_version = 1.0.0-dev
5+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
6+
serialize =
7+
{major}.{minor}.{patch}-{release}
8+
{major}.{minor}.{patch}
9+
10+
[bumpversion:file:setup.py]
11+
12+
[bumpversion:file:./src/pycompressor/__init__.py]
13+
14+
[bumpversion:part:release]
15+
optional_value = prod
16+
first_value = dev
17+
values =
18+
dev
19+
prod

.github/workflows/deploy_doc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install packages 📦
2222
run: |
23-
# install pip
2423
python -m pip install --upgrade pip
25-
pip install .[docs]
24+
pip install .
25+
pip install -r docs-requirements.txt
2626
- name: Build 🔨
2727
run: |
2828
cd doc/

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Test modules and coverage with pytest
4848
shell: bash --login {0}
4949
run: |
50-
pip install .[tests]
50+
pip install -r tests-requirements.txt
5151
pytest -v tests/ --cov=./src/pycompressor --cov-report=xml
5252
- name: Upload coverage report
5353
uses: codecov/codecov-action@v1

docs-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
recommonmark
2+
sphinx_rtd_theme
3+
sphinxcontrib-bibtex

ganpdfs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ nd_steps : 4 # Number of steps to train
7070
ng_steps : 3 # Number of steps to train the Generator for one training run
7171
batch_size : 70 # Batch size per epoch in terms of percentage
7272
epochs : 1000 # Number of epochs
73+
pdf: NNPDF40_nnlo_as_0118_1000

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cma
2+
numpy
3+
numba
4+
rich
5+
scipy
6+
tqdm

runcard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# PDF Set #
33
###################################################
44
pdfsetting:
5-
pdf: NNPDF40_nnlo_as_0118_1000rep
5+
pdf: NNPDF40_nnlo_as_0118_1000
66
existing_enhanced: False
77

88
###################################################

setup.py

Lines changed: 23 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,54 @@
11
"""
2-
pyCompressor is a Python implementation of a compressor code
3-
presented in this paper https://arxiv.org/pdf/1504.06469 and
4-
implemented here https://github.com/scarrazza/compressor.
2+
pyCompressor is q python package for Monte Carlo Parton Distribution Functions
3+
(PDFs) compression.
54
6-
This program has been developed within the N3PDF group.
7-
(n3pdf.mi.infn.it/)
5+
This program has been developed within the N3PDF group. (n3pdf.mi.infn.it/)
86
97
Authors: - Stefano Carrazza
10-
- Juan Cruz-Martinez
8+
- Juan M. Cruz-Martinez
119
- Tanjona R. Rabemananjara
1210
1311
License: GPL-3.0, 2020
1412
"""
1513

1614

17-
import os
18-
import re
15+
import pathlib
1916
from setuptools import setup
2017
from setuptools import find_packages
2118

2219
PACKAGE = "pycompressor"
20+
THIS_DIR = pathlib.Path(__file__).parent
21+
LONG_DESCRIPTION = (THIS_DIR / "README.md").read_text()
22+
REQUIREMENTS = (THIS_DIR / "requirements.txt").read_text()
2323

24-
# Used for pytest and code coverage
25-
TESTS_REQUIEREMENTS = [
26-
"pylint",
27-
"pytest",
28-
"pytest-cov",
29-
"pytest-env",
30-
"pygit2",
31-
"semver"
32-
]
33-
34-
# Dependencies for the packages
35-
PACKAGE_REQUIEREMENTS = [
36-
"cma",
37-
"tqdm",
38-
"scipy",
39-
"numpy",
40-
"numba",
41-
"rich"
42-
]
43-
44-
# Depending on the documents more dependencies can be added
45-
DOCS_REQUIEREMENTS = [
46-
"recommonmark",
47-
"sphinx_rtd_theme",
48-
"sphinxcontrib-bibtex"
49-
]
50-
51-
# Check if LHAPDF is installed
5224
try:
5325
import lhapdf
5426
except ImportError:
5527
print(f"Note: {PACKAGE} requires the installation of LHAPDF")
5628

57-
# Check if Validphys is installed
5829
try:
5930
import validphys
6031
except ImportError:
6132
print(f"Note: {PACKAGE} requires the installation of VALIDPHYS")
6233

63-
# Read through Readme
64-
try:
65-
this_directory = os.path.abspath(os.path.dirname(__file__))
66-
with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
67-
long_description = f.read()
68-
except IOError:
69-
print("Read me file not found.")
70-
71-
72-
# Get package version
73-
def get_version():
74-
"""
75-
Gets the version from the package's __init__ file
76-
if there is some problem, let it happily fail
77-
"""
78-
VERSIONFILE = os.path.join("src", PACKAGE, "__init__.py")
79-
initfile_lines = open(VERSIONFILE, "rt").readlines()
80-
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
81-
for line in initfile_lines:
82-
mo = re.search(VSRE, line, re.M)
83-
if mo:
84-
return mo.group(1)
85-
8634

8735
setup(
8836
name=PACKAGE,
89-
version=get_version(),
90-
description="PDF set compressor",
91-
author="Stefano Carrazza, Juan Cruz Martinez, Tanjona R. Rabemananjara",
37+
version='1.0.0-dev',
38+
description="PDF Compression",
39+
long_description=LONG_DESCRIPTION,
40+
long_description_content_type="text/markdown",
41+
author="N3PDF",
9242
author_email="tanjona.rabemananjara@mi.infn.it",
43+
license="GPL 3.0",
9344
url="https://github.com/N3PDF/pyCompressor",
94-
extras_require={"docs": DOCS_REQUIEREMENTS, "tests": TESTS_REQUIEREMENTS},
95-
long_description=long_description,
96-
long_description_content_type="text/markdown",
97-
install_requires=PACKAGE_REQUIEREMENTS,
98-
entry_points={"console_scripts":
99-
[
45+
zip_safe=False,
46+
project_urls={
47+
"Documentation": "https://n3pdf.github.io/pycompressor/",
48+
"Source": "https://github.com/N3PDF/pyCompressor"
49+
},
50+
entry_points={
51+
"console_scripts": [
10052
"pycomp = pycompressor.scripts.main:main",
10153
"validate = pycompressor.scripts.validate:main",
10254
"cmp-fids = pycompressor.scripts.fids:main",
@@ -107,10 +59,12 @@ def get_version():
10759
},
10860
package_dir={"": "src"},
10961
packages=find_packages("src"),
62+
install_requires=REQUIREMENTS,
11063
classifiers=[
11164
"Operating System :: Unix",
11265
"Programming Language :: Python",
11366
"Programming Language :: Python :: 3",
67+
"Programming Language :: Python :: 3 :: Only",
11468
"Topic :: Scientific/Engineering",
11569
"Topic :: Scientific/Engineering :: Physics",
11670
],

src/pycompressor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.0-dev"

src/pycompressor/app.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
# implement ValidPhys application
1+
# ValidPhys Action
22

3-
import re
43
import sys
5-
import shutil
64
import pathlib
75
import logging
8-
import hashlib
96
import warnings
107

11-
from validphys.app import App
128
from reportengine import colors
139
from reportengine.compat import yaml
10+
from validphys.app import App
1411
from validphys.config import Environment, Config
1512
from validphys.config import EnvironmentError_, ConfigError
1613

@@ -34,9 +31,8 @@ def init_output(self):
3431
# check file exists, is a file, has extension.
3532
if not self.config_yml.exists():
3633
raise CompressorError("Invalid runcard. File not found.")
37-
else:
38-
if not self.config_yml.is_file():
39-
raise CompressorError("Invalid runcard. Must be a file.")
34+
if not self.config_yml.is_file():
35+
raise CompressorError("Invalid runcard. Must be a file.")
4036
# Check if results folder exists
4137
self.output_path = pathlib.Path(self.output_path).absolute()
4238
try:

0 commit comments

Comments
 (0)