From 25646a9e7e0fb66fcd3474782bd72a0c67789486 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Wed, 24 Jan 2024 11:28:48 +0100 Subject: [PATCH] Update dependencies and Python version>=3.10 (#57) * Update dependencies and Python version>=3.10 * Add GH workflows * remove travis configuration * Remove unused badges and bump up version * add RTD config * Populate yml * Update rtd yaml path * UPdate .readthedocs * another try * Update makefile * correct conf.py path * Use RTD theme --- .github/workflows/full_tests.yml | 27 +++++++++++++++++++++++++ .github/workflows/publish-to-pypi.yml | 29 +++++++++++++++++++++++++++ .readthedocs.yaml | 15 ++++++++++++++ .travis.yml | 20 ------------------ README.md | 5 +---- docs/Makefile | 8 ++++---- docs/conf.py | 17 +++++++--------- docs/requirements.txt | 2 ++ environment.yml | 4 ++-- expipe/backends/filesystem.py | 11 +++++----- expipe/config.py | 10 ++++----- expipe/core.py | 11 ++++++++-- expipe/version.py | 2 +- requirements.txt | 12 +++++------ setup.py | 1 + 15 files changed, 114 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/full_tests.yml create mode 100644 .github/workflows/publish-to-pypi.yml create mode 100644 .readthedocs.yaml delete mode 100644 .travis.yml create mode 100644 docs/requirements.txt diff --git a/.github/workflows/full_tests.yml b/.github/workflows/full_tests.yml new file mode 100644 index 0000000..ac6f9e7 --- /dev/null +++ b/.github/workflows/full_tests.yml @@ -0,0 +1,27 @@ +name: Test on Ubuntu + +on: + pull_request: + branches: [master] + types: [synchronize, opened, reopened] + + +jobs: + build-and-test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install package + run: | + python -m pip install --upgrade pip + pip install -e . + pip install pytest + - name: Pytest + run: | + pytest -v diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..ceeab25 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,29 @@ +name: Release to PyPI + +on: + push: + tags: + - '*' +jobs: + release: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install Tools + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine build + - name: Package and Upload + env: + STACKMANAGER_VERSION: ${{ github.event.release.tag_name }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python -m build --sdist --wheel + twine upload dist/* diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..ac0fbce --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,15 @@ +version: 2 + +build: + os: ubuntu-20.04 + tools: + python: "3.10" + +sphinx: + configuration: docs/conf.py + +python: + install: + - method: pip + path: . + - requirements: docs/requirements.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4d5f42c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: python -os: -- linux -python: -- '3.6' -install: -- pip install . -- pip install sphinx -- pip install pytest==3.6 -script: -- python -m pytest --ignore=docs/ -- cd docs -- make html -deploy: - provider: pypi - user: cinpla - on: - tags: true - password: - secure: B+3fKh3obkSFbVG8XtUqQdhd37bfyIMyhgEC9NIvfE+98zmq8FWJiVsGYRA+SmIgPIOSftYOmYhu8WOvjSp/okWzAnifzcpWbI4/bsn8d95PpzBscddeA06abT2qfQ5tSQEVsGMD7vHhzljytiGEa4vO/0l5+JPfEaI6AL01eexvI8EmNHFb7iSyQad4AJUY2rV8ai5iPB2nSAKB5YNUCdv5wxM/lpHAVlvGaPqc0JOX1e8ds3wCdG6oH8wdheKCtSp+cYNBCTCNR54L8WZ4VOWdTLSOtmGH76QaU7qlCS8RzOPR1cX9zjRmiSkudA9+UsgZc9KyEWkb7PK9kqpwgck4eW6QDxu3ejh2EAdlKQF3xeGBWEAzVHgt3Q0OpIHahdZbG6esz2t9A1rgj/LWALd3d0axUvkE7bfhyLP/FxHsGY/H6wHCK7sV/IpE/Pj8eVNzEzqjQtHlMFVIG81ieNLORlkK3QPeHSgySlLv6Lcy+0ow5jtazRwTNMBkHW7bTQWfI47i0ObGHrpyazp2P4EwsnrN33kdalREECRMI/Y6yBbw04+9P/BDEpV0TbxS8SWpMK7gIZPEzK326tZmN8L0KZPusMzwwAUjnn2jjxgnRhnN7VbTo8x8H7+M4fN3LhFNHJFoHQ2naIPVa7/DrWDgfhCiPZiBjuxcvqxHwJk= diff --git a/README.md b/README.md index b6a5d22..f430e87 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ -[![Build Status](https://travis-ci.org/CINPLA/expipe.svg?branch=dev)](https://travis-ci.org/CINPLA/expipe) -[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip) +[![Build Status](https://github.com/CINPLA/expipe/actions/workflows/full_tests.yml/badge.svg)](https://github.com/CINPLA/expipe/actions/workflows/full_tests.yml/badge.svg)[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip) [![PyPI version](https://badge.fury.io/py/expipe.svg)](https://badge.fury.io/py/expipe) -[![Anaconda-Server Badge](https://anaconda.org/cinpla/expipe/badges/installer/conda.svg)](https://conda.anaconda.org/cinpla/expipe) -[![codecov](https://codecov.io/gh/CINPLA/expipe/branch/dev/graph/badge.svg)](https://codecov.io/gh/CINPLA/expipe) # Expipe diff --git a/docs/Makefile b/docs/Makefile index 37952cb..d4bb2cb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,10 +1,10 @@ # Minimal makefile for Sphinx documentation # -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SPHINXPROJ = expipe +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build diff --git a/docs/conf.py b/docs/conf.py index f0b572d..1bc71ed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,19 +21,16 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) -import os import re import expipe -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' -if not on_rtd: # only import and set the theme if we're building docs locally - try: - import sphinx_rtd_theme - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - except ImportError: - print("RTD theme not installed, using default") - pass +try: + import sphinx_rtd_theme + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +except ImportError: + print("RTD theme not installed, using default") + pass # -- General configuration ------------------------------------------------ diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..856b3f4 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx_rtd_theme \ No newline at end of file diff --git a/environment.yml b/environment.yml index 5cf697d..299a48b 100644 --- a/environment.yml +++ b/environment.yml @@ -1,6 +1,6 @@ -name: expipe +name: expipe-test dependencies: - - python=3.5 + - python=3.10 - numpy - matplotlib - scipy diff --git a/expipe/backends/filesystem.py b/expipe/backends/filesystem.py index d372045..2318fa3 100644 --- a/expipe/backends/filesystem.py +++ b/expipe/backends/filesystem.py @@ -54,7 +54,7 @@ def convert_quantities(value): result = value.tolist() elif isinstance(value, np.integer): result = int(value) - elif isinstance(value, np.float): + elif isinstance(value, float): result = float(value) else: # try if dictionary like objects can be converted if not return the @@ -76,17 +76,16 @@ def convert_quantities(value): def yaml_dump(f, data): assert f.suffix == '.yaml' with f.open("w", encoding="utf-8") as fh: - yaml.dump( + yaml_ = yaml.YAML(typ='safe', pure=True) + yaml_.dump( convert_quantities(data), fh, - default_flow_style=False, - allow_unicode=True, - Dumper=yaml.RoundTripDumper ) def yaml_load(path): with path.open('r', encoding='utf-8') as f: - result = yaml.load(f, Loader=yaml.Loader) + yaml_ = yaml.YAML(typ='safe', pure=True) + result = yaml_.load(f) return convert_back_quantities(result) diff --git a/expipe/config.py b/expipe/config.py index 9ad01e9..9f6a5dc 100644 --- a/expipe/config.py +++ b/expipe/config.py @@ -35,7 +35,8 @@ def _load_config(path): result = {} else: with path.open('r') as f: - result = yaml.safe_load(f) + yaml_ = yaml.YAML(typ='safe', pure=True) + result = yaml_.load(f) return result @@ -43,11 +44,10 @@ def _dump_config(path, contents): assert path.suffix == '.yaml' path.parent.mkdir(exist_ok=True, parents=True) with path.open("w", encoding="utf-8") as f: - yaml.dump( + yaml_ = yaml.YAML(typ='safe', pure=True) + yaml_.dump( contents, f, - default_flow_style=False, - allow_unicode=True, - Dumper=yaml.RoundTripDumper) + ) def _load_config_by_name(config=None): diff --git a/expipe/core.py b/expipe/core.py index 2893880..d7027f1 100644 --- a/expipe/core.py +++ b/expipe/core.py @@ -406,6 +406,7 @@ def type(self, value): raise TypeError('Expected "str" got "' + str(type(value)) + '"') self._backend.attributes.set('type', value) + @property def datetime(self): dtime = self._backend.attributes.get('datetime') @@ -671,11 +672,13 @@ def delete_project(self, name, remove_all_children=None): # Entry API def get_project(path, name=None): import expipe.backends.filesystem + from expipe.config import settings + path = pathlib.Path(path).absolute() name = name or path.stem - global_config = config.settings.copy() + global_config = settings.copy() local_config_path = path / "expipe.yaml" if not local_config_path.exists(): @@ -723,9 +726,13 @@ def create_project(path, name=None, init=False): "type": "project", "project": name } + print(local_config) with local_config_path.open('w') as f: - yaml.dump(local_config, f) + yaml_ = yaml.YAML(typ='safe', pure=True) + yaml_.dump( + local_config, f, + ) return get_project(path) diff --git a/expipe/version.py b/expipe/version.py index 7b96c4d..5da0c29 100644 --- a/expipe/version.py +++ b/expipe/version.py @@ -1 +1 @@ -version = '0.5.1' +version = '0.6.0' diff --git a/requirements.txt b/requirements.txt index 5c27f49..6f68cca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -numpy -ruamel.yaml -quantities -pandas -ipywidgets -click +numpy>=1.25 +ruamel.yaml>=0.18.5 +quantities>=0.14.1 +pandas>=2.1.2 +ipywidgets>=8.1.1 +click>=8.1.7 \ No newline at end of file diff --git a/setup.py b/setup.py index 3ccf920..96a1b50 100644 --- a/setup.py +++ b/setup.py @@ -39,4 +39,5 @@ 'Natural Language :: English', 'Programming Language :: Python :: 3', 'Topic :: Scientific/Engineering'], + python_requires='>=3.9', )