[project]
name = "access_moppy"

authors = [
    {name = "Romain Beucher", email = "romain.beucher@anu.edu.au"},
]
description = "ACCESS Model Output Post-Processor, maps raw model output to CMIP-style defined variables and produce post-processed output using CMOR3"
readme = "README.md"
requires-python = ">=3.11,<3.14"
keywords = ["ACCESS", "post-processing"]
license = {text = "Apache-2.0"}
classifiers = [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: Apache Software License",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
]
dependencies = [
    "numpy",
    "pandas",
    "xarray",
    "netCDF4",
    "cftime",
    "dask",
    "distributed>=2024.0.0",
    "pyyaml",
    "tqdm",
    "requests",
    "parsl",
    "jinja2",
    "CMIP7-data-request-api>=1.3"
]
dynamic = ["version"]

[project.optional-dependencies]
# pip install access_moppy[dashboard]
dashboard = [
  "streamlit>=1.35.0"
]
# pip install access_moppy[atmos-tools]
# Required for the moppy-calc-ab-coeffts utility that reads UM vertlevs
# Fortran namelist files to compute correct hybrid-height b coefficients.
atmos-tools = [
  "f90nml"
]
# pip install access_moppy[esmval]
# Required for the esmvaltool integration (moppy-esmval-* commands and
# the 'esmvaltool cmorise' sub-command).
esmval = [
  "esmvalcore>=2.14",
  "pyyaml",
]
test = [
    "pytest",
    "pytest-cov",
    "pytest-subtests",
    "ruff",
    "f90nml"
]
docs = [
    "sphinx>=7.0.0",
    "sphinx-rtd-theme>=1.3.0",
    "sphinx-autodoc-typehints>=1.23.0",
    "myst-parser>=2.0.0",
    "linkify-it-py>=2.0.0",
    "sphinx-autoapi>=3.0.0",
    "nbsphinx>=0.9.0",
    "ipython>=8.0.0",
    "pygments>=2.15.0"
]

[project.scripts]
moppy-cmorise = "access_moppy.batch_cmoriser:main"
moppy-dashboard = "access_moppy.dashboard.cmor_dashboard:main"
moppy-example-config = "access_moppy.examples.show_config:main"
moppy-calc-ab-coeffts = "access_moppy.legacy_utilities.calc_hybrid_height_coeffs:main"
moppy-esmval-prepare = "access_moppy.esmval.cli_commands:main_prepare"
moppy-esmval-run = "access_moppy.esmval.cli_commands:main_run"

[project.entry-points."esmvaltool_commands"]
cmorise = "access_moppy.esmval.cli_commands:CMORiseCommand"

[build-system]
build-backend = "setuptools.build_meta"
requires = [
  "setuptools>=64.0.0",
  "versioneer[toml]",
]

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

[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
access_moppy = ["*.yml", "mappings/*.json",
                "vocabularies/**/*",
                "dashboard/*.py", "examples/*.yml",
                "templates/*.jinja2", "templates/*.yaml",
                "resources/**/*"
]

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/access_moppy/_version.py"
versionfile_build = "access_moppy/_version.py"
tag_prefix = "moppy-v"
parentdir_prefix = "access_moppy-"

[tool.ruff]
exclude = ["versioneer.py"]
line-length = 88  # Matches Black's default
target-version = "py311"  # Adjust to match your minimum Python version

[tool.ruff.lint]
select = ["E", "F", "W", "I"]  # E: pycodestyle, F: Pyflakes, W: warnings, I: isort
ignore = ["E203", "E501"]  # Ignore line-length issues (handled by formatter)

[tool.ruff.format]
quote-style = "double"  # Use double quotes

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"test_mop.py" = ["I001"]

[tool.pixi.workspace]
channels = ["conda-forge", "accessnri"]
platforms = ["linux-64"]

[tool.pixi.pypi-dependencies]
access_moppy = { path = ".", editable = true }
cc-plugin-wcrp = "*"
esgvoc = "*"

[tool.pixi.feature.dev.dependencies]
notebook = ">=7.4.4,<8"
jupyterlab = ">=4.4.4,<5"
ipywidgets = ">=8.0.0"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
ruff = "*"
cmor = "==3.11.0"

[tool.pixi.feature.docs.dependencies]
sphinx = ">=7.0.0"
sphinx-rtd-theme = ">=1.3.0"
sphinx-autodoc-typehints = ">=1.23.0"
myst-parser = ">=2.0.0"
sphinx-autoapi = ">=3.0.0"
nbsphinx = ">=0.9.0"
pygments = ">=2.15.0"

# ESMValTool integration testing environment.
# Installs esmvalcore from PyPI alongside access_moppy[esmval] so that
# the tests/unit/test_esmval_*.py suite can be run in isolation without
# needing a full esmvaltool conda environment.
[tool.pixi.feature.esmval.dependencies]
python = ">=3.11,<3.14"
pytest = "*"
pytest-cov = "*"

[tool.pixi.feature.esmval.pypi-dependencies]
access_moppy = { path = ".", editable = true, extras = ["esmval"] }

[tool.pixi.feature.esmval.tasks]
test-esmval = "pytest tests/unit/test_esmval_recipe_reader.py tests/unit/test_esmval_variable_mapper.py tests/unit/test_esmval_config_gen.py tests/unit/test_esmval_file_finder.py -v"

[tool.pixi.environments]
default = { solve-group = "default" }
esmval = { features = ["esmval"], solve-group = "esmval" }
dev = { features = ["dev"], solve-group = "default" }
test = { features = ["test"], solve-group = "default" }
docs = { features = ["docs"], solve-group = "default" }

[tool.pixi.tasks]

[tool.pixi.dependencies]
python = ">=3.11,<3.14"
xarray = ">=2025.7.1,<2026"
numpy = ">=2.3.1,<3"
pandas = ">=2.3.1,<4"
cftime = ">=1.6.4,<2"
esmpy = ">=8.9.1,<9"
rdflib = ">=7.6.0,<8"

[tool.pixi.feature.dev.tasks.start]
description = "Test in Jupyterlab"
cmd = "jupyter lab"

[tool.pixi.feature.docs.tasks.docs-build]
description = "Build documentation with Sphinx"
cmd = "sphinx-build -b html docs/source docs/_build/html"

[tool.pixi.feature.docs.tasks.docs-serve]
description = "Serve documentation locally"
cmd = "python -m http.server 8000 --directory docs/_build/html"

[tool.pixi.feature.docs.tasks.docs-clean]
description = "Clean documentation build"
cmd = "rm -rf docs/_build"
