From 8164d5f173084e7798d5c1b98983af142306ef5f Mon Sep 17 00:00:00 2001 From: Runar Ask Johannessen <89020325+equinor-ruaj@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:11:01 +0100 Subject: [PATCH] Pyproject toml config (#259) * remove redundant gitignore * move content from setup.py to pyproject.toml * move version export to Explorer __init__ * update docs: uploader has been moved * workflows use python 3.10 * use sphinx-build * remove old requirements txt files * update readthedocs python build config --- .github/workflows/build_docs.yaml | 6 +- .github/workflows/publish_release.yaml | 2 +- .github/workflows/run_tests.yaml | 2 +- .gitignore | 1 + .readthedocs.yml | 11 ++-- docs/conf.py | 4 +- docs/index.rst | 8 ++- docs/uploader.rst | 71 --------------------- pyproject.toml | 53 +++++++++++++--- requirements/requirements.txt | 9 --- requirements/requirements_docs.txt | 5 -- requirements/requirements_setup.txt | 8 --- requirements/requirements_test.txt | 2 - setup.py | 86 -------------------------- src/.gitignore | 2 - src/fmu/sumo/__init__.py | 6 -- src/fmu/sumo/explorer/__init__.py | 7 +++ 17 files changed, 70 insertions(+), 213 deletions(-) delete mode 100644 docs/uploader.rst delete mode 100644 requirements/requirements.txt delete mode 100644 requirements/requirements_docs.txt delete mode 100644 requirements/requirements_setup.txt delete mode 100644 requirements/requirements_test.txt delete mode 100644 setup.py delete mode 100644 src/.gitignore diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml index f6bfcff4..1f7e0045 100644 --- a/.github/workflows/build_docs.yaml +++ b/.github/workflows/build_docs.yaml @@ -13,14 +13,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8.17"] + python-version: ["3.10"] os: [ubuntu-latest] steps: - uses: actions/checkout@v1 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -28,4 +28,4 @@ jobs: run: | pip install pip -U && pip install wheel -U pip install .[docs] - python setup.py build_sphinx + sphinx-build docs build/sphinx/html diff --git a/.github/workflows/publish_release.yaml b/.github/workflows/publish_release.yaml index a032ac51..2816d6b3 100644 --- a/.github/workflows/publish_release.yaml +++ b/.github/workflows/publish_release.yaml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" - name: build run: | diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 2ec0a921..551fcee0 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -46,5 +46,5 @@ jobs: access_token=$(az account get-access-token --scope api://88d2b022-3539-4dda-9e66-853801334a86/.default --query accessToken --output tsv) export ACCESS_TOKEN=$access_token - pip install -r requirements/requirements_test.txt + pip install pytest>=6.1.1 pytest-timeout pytest -s --timeout=300 diff --git a/.gitignore b/.gitignore index e48de435..43ffe970 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +_version.py # PyInstaller # Usually these files are written by a python script from a template diff --git a/.readthedocs.yml b/.readthedocs.yml index b6177c59..83aaa81c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,15 +1,16 @@ version: 2 build: - image: latest + os: ubuntu-22.04 + tools: + python: "3.10" python: - version: "3.8" install: - - requirements: requirements/requirements_docs.txt - - method: setuptools + - method: pip path: . - system_packages: true + extra_requirements: + - docs sphinx: configuration: docs/conf.py diff --git a/docs/conf.py b/docs/conf.py index 926457c9..f587ea7d 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -34,8 +34,6 @@ "sumo", "xtgeo", "pandas", - "yaml", - "azure", ] os.environ[ @@ -44,7 +42,7 @@ apidoc_module_dir = "../src/fmu" apidoc_output_dir = "apiref" -apidoc_excluded_paths = ["version.py", "hook_implementations"] +apidoc_excluded_paths = ["_version.py", "hook_implementations"] apidoc_separate_modules = True apidoc_module_first = True apidoc_extra_args = ["-H", "API reference for fmu.sumo"] diff --git a/docs/index.rst b/docs/index.rst index 9f525c09..7e075b43 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,13 +11,15 @@ Sumo provides a data-backend for services for e.g post-processing. For documentation of Sumo in the FMU context, see the `Sumo front-end for FMU `_ ``fmu-sumo`` is a Python library for interaction with Sumo in the FMU context. It contains -two modules: The **Uploader** for *writing* data to Sumo during FMU runs, and the -**Explorer** for *reading* data from Sumo in the FMU context. +multiple modules: + +* **Explorer** (This module) for *reading* data from Sumo in the FMU context. +* `Uploader `_ for *writing* data to Sumo during FMU runs. +* `Sim2sumo `_ for making reservoir simulator (Eclipse, OPM) results available through Sumo. .. toctree:: :maxdepth: 2 :hidden: self - uploader explorer \ No newline at end of file diff --git a/docs/uploader.rst b/docs/uploader.rst deleted file mode 100644 index f76a94b8..00000000 --- a/docs/uploader.rst +++ /dev/null @@ -1,71 +0,0 @@ -Sumo Uploader -############ - -The ``fmu.sumo.uploader`` is a python plugin for FMU for uploading data to Sumo. - - -API reference -------------- - -- `API reference `_ - -Usage and examples ----------- - -Assumptions: - -- An FMU case is being ran. -- fmu-dataio is being used to export data with rich metadata. - -.. note:: - - **fmu-dataio** is the FMU plugin for exporting data out of FMU workflows with rich metadata. - For more information and instructions/documentation, please see the - `fmu-dataio documentation `_ - -- User has necessary accesses - -.. note:: - - Within Equinor, apply for Sumo on your respective asset in AccessIT. With Komodo activated, - run ``sumo_login`` from the Equinor unix command line to confirm/establish the local access. - -- Case metadata is being generated for this case, and the case is registered on Sumo. - -.. note:: - - Use the ``--sumo`` argument flag to the `create_case_metadata` job in an ERT hook workflow, - see `fmu-dataio documentation `_ for more - details. - - -As a FORWARD_MODEL in ERT -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. code-block:: - - FORWARD_MODEL SUMO_UPLOAD(="share/results/maps/*.gri") - - -Example above uploads all surfaces dumped to ``share/results/maps``. You can add as many -instances of ```` FORWARD_JOB in your ERT workflow as you want. It is, -however, recommended that you rather use broad search strings and few instances. - -Using ```` in the *realization context* is the primary usage. All data exported -out of FMU workflows with the intention of being used outside the realization context should -be exported. E.g. if exported data is to be used for other purposes than feeding other -FORWARD_JOBS in the same workflow. - -As a workflow job in ERT: -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. code-block:: - - -- call -- case root directory -- absolute path to files - WF_SUMO_UPLOAD // "/abs/path/mycase/share/results/maps/*.gri" - - -Example above show how ``SUMO_UPLOAD`` can be used as an ERT workflow job, e.g. if doing -local post-processing. This feature is mainly added for legacy reasons. Generally, it -would be recommended to upload from realizations, and post-process using Sumo as data -source. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d2828af8..92a0cca0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,50 @@ +[build-system] +requires = ["setuptools", "setuptools-scm", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_file = "src/fmu/sumo/explorer/_version.py" + [tool.isort] profile = "black" -[build-system] -requires = [ - "pip>=19.1.1", - "setuptools>=28", - "setuptools_scm>=3.2.0", - "wheel", +[tool.black] +line-length = 79 + +[project] +name = "fmu-sumo-explorer" +description = "Python package for interacting with Sumo in an FMU setting" +requires-python = ">=3.8" +dynamic = ["version"] +license = { file = "LICENSE" } +readme = { file = "README.md", content-type = "text/markdown" } +authors = [{ name = "Equinor" }] +classifiers = ["Programming Language :: Python"] +dependencies = [ + "pandas>=1.1.3", + "sumo-wrapper-python", + "xtgeo", + "pyarrow; python_version > '3.6.1'", + "OpenVDS; sys_platform != 'darwin'", ] -[tool.black] -line-length = 79 \ No newline at end of file +[project.urls] +Repository = "https://github.com/equinor/fmu-sumo" + +[project.optional-dependencies] +dev = ["black", "flake8", "pytest"] +docs = [ + "sphinx==6.2.1", + "sphinx-rtd-theme", + "autoapi", + "sphinx-autodoc-typehints", + "sphinxcontrib-apidoc", +] + +[tool.setuptools] +package-dir = { "" = "src" } +include-package-data = true +platforms = ["any"] + +[tool.setuptools.packages.find] +where = ["src"] diff --git a/requirements/requirements.txt b/requirements/requirements.txt deleted file mode 100644 index c73348b6..00000000 --- a/requirements/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -PyYAML>=5.4 -pandas>=1.1.3 -deprecation -sumo-wrapper-python -xtgeo -azure-core -pyarrow; python_version > "3.6.1" -OpenVDS; sys_platform != 'darwin' -fmu-dataio diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt deleted file mode 100644 index 7734f20d..00000000 --- a/requirements/requirements_docs.txt +++ /dev/null @@ -1,5 +0,0 @@ -sphinx==6.2.1 -sphinx-rtd-theme -autoapi -sphinx-autodoc-typehints -sphinxcontrib-apidoc \ No newline at end of file diff --git a/requirements/requirements_setup.txt b/requirements/requirements_setup.txt deleted file mode 100644 index 6b19c077..00000000 --- a/requirements/requirements_setup.txt +++ /dev/null @@ -1,8 +0,0 @@ -setuptools>=45 -setuptools_scm -pytest-runner -black -pylint -flake8 -types-PyYAML -mypy \ No newline at end of file diff --git a/requirements/requirements_test.txt b/requirements/requirements_test.txt deleted file mode 100644 index 0bf0a7a7..00000000 --- a/requirements/requirements_test.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest>=6.1.1 -pytest-timeout diff --git a/setup.py b/setup.py deleted file mode 100644 index 60361fc8..00000000 --- a/setup.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import pathlib -from urllib.parse import urlparse - -from pip._internal.req import parse_requirements as parse -from setuptools import find_packages, setup - - -def _format_requirement(req): - if req.is_editable: - # parse out egg=... fragment from VCS URL - parsed = urlparse(req.requirement) - egg_name = parsed.fragment.partition("egg=")[-1] - without_fragment = parsed._replace(fragment="").geturl() - return f"{egg_name} @ {without_fragment}" - return req.requirement - - -def parse_requirements(fname): - """Turn requirements.txt into a list""" - reqs = parse(fname, session="test") - return [_format_requirement(ir) for ir in reqs] - - -CMDCLASS = {} - -try: - from sphinx.setup_command import BuildDoc - - CMDCLASS.update({"build_sphinx": BuildDoc}) -except ImportError: - # sphinx not installed - do not provide build_sphinx cmd - pass - -is_docs = os.getenv("READTHEDOCS") == "True" - -REQUIREMENTS = ( - [] if is_docs else parse_requirements("requirements/requirements.txt") -) -TEST_REQUIREMENTS = parse_requirements("requirements/requirements_test.txt") -DOCS_REQUIREMENTS = parse_requirements("requirements/requirements_docs.txt") -SETUP_REQUIREMENTS = parse_requirements("requirements/requirements_setup.txt") -EXTRAS_REQUIRE = {"tests": TEST_REQUIREMENTS, "docs": DOCS_REQUIREMENTS} - -setup( - name="fmu-sumo", - description="Python package for interacting with Sumo in an FMU setting", - long_description=pathlib.Path("README.md").read_text(), - long_description_content_type="text/markdown", - url="https://github.com/equinor/fmu-sumo", - use_scm_version={"write_to": "src/fmu/sumo/version.py"}, - author="Equinor", - license="Apache 2.0", - keywords="fmu, sumo", - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Natural Language :: English", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - entry_points={ - "ert": [ - "fmu_sumo_jobs = fmu.sumo.hook_implementations.jobs", - "sumo_upload = fmu.sumo.uploader.scripts.sumo_upload", - ], - "console_scripts": [ - "sumo_upload=fmu.sumo.uploader.scripts.sumo_upload:main", - ], - }, - cmdclass=CMDCLASS, - install_requires=REQUIREMENTS, - setup_requires=SETUP_REQUIREMENTS, - test_suite="tests", - extras_require=EXTRAS_REQUIRE, - python_requires=">=3.8", - packages=find_packages("src"), - package_dir={"": "src"}, - include_package_data=True, - zip_safe=False, -) diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 263b556b..00000000 --- a/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.egg-info -experimenting.py \ No newline at end of file diff --git a/src/fmu/sumo/__init__.py b/src/fmu/sumo/__init__.py index fde48d2f..e69de29b 100644 --- a/src/fmu/sumo/__init__.py +++ b/src/fmu/sumo/__init__.py @@ -1,6 +0,0 @@ -try: - from .version import version - - __version__ = version -except ImportError: - __version__ = "0.0.0" diff --git a/src/fmu/sumo/explorer/__init__.py b/src/fmu/sumo/explorer/__init__.py index 5f1452b4..8b542193 100644 --- a/src/fmu/sumo/explorer/__init__.py +++ b/src/fmu/sumo/explorer/__init__.py @@ -1,4 +1,11 @@ """Top-level package for fmu.sumo.explorer""" +try: + from ._version import version + + __version__ = version +except ImportError: + __version__ = "0.0.0" + from fmu.sumo.explorer.explorer import Explorer from fmu.sumo.explorer.timefilter import TimeType, TimeFilter