TNO Intern

Commit 506c2693 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

adding a pyproject2.toml to test if that works

parent e36c7d70
Loading
Loading
Loading
Loading
+69 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/certifi-2025.1.31-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/cffi-1.17.1-py313ha7868ed_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/charset-normalizer-3.4.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/click-8.1.8-pyh7428d3b_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/cmarkgfm-2024.11.20-py313ha7868ed_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.13.2-py313hd8ed1ab_101.conda
@@ -78,6 +79,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/rich-13.9.4-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/roman-numerals-py-3.1.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-75.8.2-pyhff2d567_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/snowballstemmer-2.2.0-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/sphinx-8.2.3-pyhd8ed1ab_0.conda
@@ -92,6 +94,9 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/win-64/tbb-2021.13.0-h62715c5_1.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/tk-8.6.13-h5226925_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/twine-6.1.0-pyh29332c3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/typer-0.15.3-pyhf21524f_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/typer-slim-0.15.3-pyh29332c3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/typer-slim-standard-0.15.3-h1a15894_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/ucrt-10.0.22621.0-h57928b3_1.conda
@@ -107,7 +112,6 @@ environments:
      - pypi: https://files.pythonhosted.org/packages/77/06/bb80f5f86020c4551da315d78b3ab75e8228f89f0162f2c3a819e407941a/attrs-25.3.0-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/84/c2/80633736cd183ee4a62107413def345f7e6e3c01563dbca1417363cf957e/build-1.2.2.post1-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/f3/2d/980323fb5ec1ef369604b61ba259a41d0336cc1a85b639ed7bd210bd1290/cftime-1.6.4.post1-cp313-cp313-win_amd64.whl
      - pypi: https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/e9/da/824b92d9942f4e472702488857914bdd50f73021efea15b4cad9aca8ecef/click_plugins-1.1.1-py2.py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/73/86/43fa9f15c5b9fb6e82620428827cd3c284aa933431405d1bcf5231ae3d3e/cligj-0.7.2-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/e3/d5/28bca491f65312b438fbf076589dcde7f6f966b196d900777f5811b9c4e2/contourpy-1.3.1-cp313-cp313-win_amd64.whl
@@ -360,14 +364,19 @@ packages:
  - pkg:pypi/charset-normalizer?source=hash-mapping
  size: 47438
  timestamp: 1735929811779
- pypi: https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl
  name: click
  version: 8.1.8
  sha256: 63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2
  requires_dist:
  - colorama ; sys_platform == 'win32'
  - importlib-metadata ; python_full_version < '3.8'
  requires_python: '>=3.7'
- conda: https://conda.anaconda.org/conda-forge/noarch/click-8.1.8-pyh7428d3b_0.conda
  sha256: c889ed359ae47eead4ffe8927b7206b22c55e67d6e74a9044c23736919d61e8d
  md5: 90e5571556f7a45db92ee51cb8f97af6
  depends:
  - __win
  - colorama
  - python >=3.9
  license: BSD-3-Clause
  license_family: BSD
  purls:
  - pkg:pypi/click?source=hash-mapping
  size: 85169
  timestamp: 1734858972635
- pypi: https://files.pythonhosted.org/packages/e9/da/824b92d9942f4e472702488857914bdd50f73021efea15b4cad9aca8ecef/click_plugins-1.1.1-py2.py3-none-any.whl
  name: click-plugins
  version: 1.1.1
@@ -1539,6 +1548,17 @@ packages:
  - sphinx-book-theme ; extra == 'docs'
  - sphinx-remove-toctrees ; extra == 'docs'
  requires_python: '>=3.7'
- conda: https://conda.anaconda.org/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_1.conda
  sha256: 0557c090913aa63cdbe821dbdfa038a321b488e22bc80196c4b3b1aace4914ef
  md5: 7c3c2a0f3ebdea2bbc35538d162b43bf
  depends:
  - python >=3.9
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/shellingham?source=compressed-mapping
  size: 14462
  timestamp: 1733301007770
- conda: https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda
  sha256: 41db0180680cc67c3fa76544ffd48d6a5679d96f4b71d7498a759e94edc9a2db
  md5: a451d576819089b0d672f18768be0f65
@@ -1732,6 +1752,46 @@ packages:
  - pkg:pypi/twine?source=hash-mapping
  size: 40401
  timestamp: 1737553658703
- conda: https://conda.anaconda.org/conda-forge/noarch/typer-0.15.3-pyhf21524f_0.conda
  sha256: 8cd849ceb5e2f50481b1f30f083ee134fac706a56d7879c61248f0aadad4ea5b
  md5: b4bed8eb8dd4fe076f436e5506d31673
  depends:
  - typer-slim-standard ==0.15.3 h1a15894_0
  - python >=3.9
  - python
  license: MIT
  purls:
  - pkg:pypi/typer?source=compressed-mapping
  size: 77044
  timestamp: 1745886712803
- conda: https://conda.anaconda.org/conda-forge/noarch/typer-slim-0.15.3-pyh29332c3_0.conda
  sha256: 1768d1d9914d4237b0a1ae8bcb30dace44ac80b9ab1516a2d429d0b27ad70ab9
  md5: 20c0f2ae932004d7118c172eeb035cea
  depends:
  - python >=3.9
  - click >=8.0.0
  - typing_extensions >=3.7.4.3
  - python
  constrains:
  - typer 0.15.3.*
  - rich >=10.11.0
  - shellingham >=1.3.0
  license: MIT
  purls:
  - pkg:pypi/typer-slim?source=compressed-mapping
  size: 46152
  timestamp: 1745886712803
- conda: https://conda.anaconda.org/conda-forge/noarch/typer-slim-standard-0.15.3-h1a15894_0.conda
  sha256: 72f77e8e61b28058562f2782cf32ff84f14f6c11c6cea7a3fe2839d34654ea45
  md5: 120216d3a2e51dfbb87bbba173ebf210
  depends:
  - typer-slim ==0.15.3 pyh29332c3_0
  - rich
  - shellingham
  license: MIT
  purls: []
  size: 5411
  timestamp: 1745886712803
- conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda
  sha256: 337be7af5af8b2817f115b3b68870208b30c31d3439bec07bfb2d8f4823e3568
  md5: d17f13df8b65464ca316cbc000a3cb64
+2 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ platforms = ["win-64"]
version = "0.1.0"

[tasks]
tg = "main:calculate"

[dependencies]
python = ">=3.13.2,<3.14"
@@ -20,6 +21,7 @@ twine = ">=6.1.0,<7"
pip = ">=25.0.1,<26"
sphinx = ">=8.2.3,<9"
sphinx_rtd_theme = ">=3.0.1,<4"
typer = ">=0.15.3,<0.16"

[tool.pixi]
pypi_index_url = "https://pypi.org/simple"

pyproject2.toml

0 → 100644
+63 −0
Original line number Diff line number Diff line
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pythermoGIS"
version = "0.1.16"
description = "This repository is used as a python API for the ThermoGIS Doublet simulations"
authors = [
    { name = "Hen Brett", email = "hen.brett@tno.nl" },
    { name = "Florian Knappers", email = "florian.knappers@tno.nl" },
]
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.11"
dependencies = [
    "jpype1>=1.5.2,<2",
    "xarray==2024.9.0.*",
    "pandas>=2.2.3,<3",
    "pytz>=2024.1,<2025",
    "pygridsio>=0.3.11,<0.4"
]


[tool.pytest.ini_options]
minversion = "7.0"
addopts = "--strict-markers -ra"
testpaths = ["."]
markers = [
    "integration: Marks integration tests (deselect with '-m \"not integration\"')"
]

[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]

[project.scripts]
calculate = "main:calculate"

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["win-64", "linux-64"]

[tool.pixi.pypi-dependencies]
pythermogis = { path = ".", editable = true }

[tool.pixi.tasks]

[tool.pixi.dependencies]
python = ">=3.13.2,<3.14"
jpype1 = ">=1.5.2,<2"
xarray = "2024.9.0.*"
pandas = ">=2.2.3,<3"
pytz = ">=2024.1,<2025"
setuptools = ">=75.8.2,<76"
wheel = ">=0.45.1,<0.46"
twine = ">=6.1.0,<7"
pip = ">=25.0.1,<26"
sphinx = ">=8.2.3,<9"
sphinx_rtd_theme = ">=3.0.1,<4"
typer = ">=0.15.3,<0.16"
 No newline at end of file

pythermogis/main.py

0 → 100644
+58 −0
Original line number Diff line number Diff line
import time
import traceback
import typing as t
import xarray as xr
import typer

from thermogis_classes.doublet import calculate_doublet_performance

app = typer.Typer(pretty_exceptions_enable=False)
calculate = typer.Typer(pretty_exceptions_enable=False)
app.add_typer(calculate, name="calculate")

def run_script(func: t.Callable[[str], None], config_file_path: str) -> None:
    """
    Wrapper around the script functions, which adds error handling.
    """
    status = "not started"
    module_name = getattr(func, "__module__", "unknown").split(".")[-1]
    typer.echo(f"Start of the {module_name} script")

    start_time = time.time()
    try:
        func(config_file_path)
        status = "finished"
    except Exception as e:
        typer.echo(f"An error occurred: {e}", err=True)
        typer.echo(traceback.format_exc(), err=True)
        status = "failed"
    finally:
        end_time = time.time()
        duration = end_time - start_time
        typer.echo(f"{module_name} {status} after: {duration:.2f} seconds")


@calculate.command()
def info():
    print("This is the pyThermoGIS Repository; it is a python API to the ThermoGIS Simulation code.")
    print("You can run commands by typing:\n")
    print("\t tg simulate-doublet")


@calculate.command()
def simulate_doublet(
) -> None:
    input_data = xr.Dataset({
        "thickness_mean": ((), 300),
        "thickness_sd": ((), 50),
        "ntg": ((), 0.5),
        "porosity": ((), 0.5),
        "depth": ((), 5000),
        "ln_permeability_mean": ((), 5),
        "ln_permeability_sd": ((), 0.5),
    })
    run_script(calculate_doublet_performance, input_data)


if __name__ == "__main__":
    app()
 No newline at end of file