Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFSBench: Install via pyproject.toml, absolute import paths and internalised entry points #14

Merged
merged 7 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions ifsbench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@

from importlib.metadata import version, PackageNotFoundError

from .arch import * # noqa
from .benchmark import * # noqa
from .cli import * # noqa
from .config_mixin import * # noqa
from .config_utils import * # noqa
from .darshanreport import * # noqa
from .drhook import * # noqa
from .files import * # noqa
from .gribfile import * # noqa
from .ifs import * # noqa
from .job import * # noqa
from .launcher import * # noqa
from .logging import * # noqa
from .namelist import * # noqa
from .nodefile import * # noqa
from .paths import * # noqa
from .runrecord import * # noqa
from .util import * # noqa
from ifsbench.arch import * # noqa
from ifsbench.benchmark import * # noqa
from ifsbench.cli import * # noqa
from ifsbench.config_mixin import * # noqa
from ifsbench.config_utils import * # noqa
from ifsbench.darshanreport import * # noqa
from ifsbench.drhook import * # noqa
from ifsbench.files import * # noqa
from ifsbench.gribfile import * # noqa
from ifsbench.ifs import * # noqa
from ifsbench.job import * # noqa
from ifsbench.launcher import * # noqa
from ifsbench.logging import * # noqa
from ifsbench.namelist import * # noqa
from ifsbench.nodefile import * # noqa
from ifsbench.paths import * # noqa
from ifsbench.runrecord import * # noqa
from ifsbench.util import * # noqa

try:
__version__ = version("ifsbench")
Expand Down
6 changes: 3 additions & 3 deletions ifsbench/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from abc import ABC, abstractmethod
import os

from .job import CpuConfiguration, CpuBinding, Job
from .launcher import Launcher, MpirunLauncher, SrunLauncher, AprunLauncher
from .util import as_tuple, execute
from ifsbench.job import CpuConfiguration, CpuBinding, Job
from ifsbench.launcher import Launcher, MpirunLauncher, SrunLauncher, AprunLauncher
from ifsbench.util import as_tuple, execute


__all__ = ['Arch', 'Workstation', 'XC40Cray', 'XC40Intel', 'AtosAaIntel',
Expand Down
8 changes: 4 additions & 4 deletions ifsbench/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from pprint import pformat
import sys

from .drhook import DrHook
from .logging import warning, error, debug
from .util import copy_data, symlink_data, as_tuple, flatten
from .runrecord import RunRecord
from ifsbench.drhook import DrHook
from ifsbench.logging import warning, error, debug
from ifsbench.util import copy_data, symlink_data, as_tuple, flatten
from ifsbench.runrecord import RunRecord


__all__ = ['Benchmark', 'ExperimentFilesBenchmark']
Expand Down
7 changes: 4 additions & 3 deletions setup.py → ifsbench/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
# nor does it submit to any jurisdiction.

"""
Install the ifsbench package.
Command Line Interfaces (CLI) and utilities for ifsbench functionalities.
"""
import setuptools

setuptools.setup()
from ifsbench.cli.cli import * # noqa
from ifsbench.cli.pack import * # noqa
from ifsbench.cli.nml_diff import * # noqa
4 changes: 2 additions & 2 deletions ifsbench/cli.py → ifsbench/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import click

from .logging import logger, DEBUG
from .util import auto_post_mortem_debugger
from ifsbench.logging import logger, DEBUG
from ifsbench.util import auto_post_mortem_debugger


__all__ = ['cli', 'RunOptions', 'run_options', 'ReferenceOptions', 'reference_options']
Expand Down
8 changes: 2 additions & 6 deletions scripts/nml-diff.py → ifsbench/cli/nml_diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

# (C) Copyright 2020- ECMWF.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand All @@ -10,7 +8,8 @@
import click
import f90nml

from ifsbench import namelist_diff, sanitize_namelist, colors, logger, INFO
from ifsbench.logging import colors, logger, INFO
from ifsbench.namelist import namelist_diff, sanitize_namelist


def print_neutral(indent, msg, *args, **kwargs):
Expand Down Expand Up @@ -82,6 +81,3 @@ def cli(color, namelist1, namelist2):
diff = namelist_diff(nml1, nml2)
if diff:
print_diff(diff)

if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
12 changes: 4 additions & 8 deletions scripts/ifs-bench.py → ifsbench/cli/pack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

# (C) Copyright 2020- ECMWF.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand All @@ -11,10 +9,12 @@
import tempfile
import click

from ifsbench import (
cli, header, debug, ExperimentFiles,
from ifsbench.cli import cli
from ifsbench.darshanreport import (
DarshanReport, read_files_from_darshan, write_files_from_darshan
)
from ifsbench.files import ExperimentFiles
from ifsbench.logging import debug, header


@cli.command()
Expand Down Expand Up @@ -184,7 +184,3 @@ def unpack_experiment(ctx, input_dir, output_dir, verify_checksum, with_ifsdata,
header('Reading %s...', summary_file)
ExperimentFiles.from_tarball(summary_file, input_dir, output_dir, ifsdata_dir=ifsdata_dir,
with_ifsdata=inplace_ifsdata, verify_checksum=verify_checksum)


if __name__ == "__main__":
cli(obj={}) # pylint: disable=unexpected-keyword-arg,no-value-for-parameter
4 changes: 2 additions & 2 deletions ifsbench/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import glob
import yaml

from .logging import header, success, warning
from .util import execute, as_tuple
from ifsbench.logging import header, success, warning
from ifsbench.util import execute, as_tuple


__all__ = ['InputFile', 'ExperimentFiles']
Expand Down
2 changes: 1 addition & 1 deletion ifsbench/gribfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pandas as pd
import xarray as xr

from .logging import error, warning
from ifsbench.logging import error, warning


CFGRIB_AVAILABLE = False
Expand Down
8 changes: 4 additions & 4 deletions ifsbench/ifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from pathlib import Path
from os import getenv

from .arch import arch_registry, Arch
from .drhook import DrHook
from .logging import warning
from .namelist import IFSNamelist
from ifsbench.arch import arch_registry, Arch
from ifsbench.drhook import DrHook
from ifsbench.logging import warning
from ifsbench.namelist import IFSNamelist

# Note: all IFS subclasses registered in cycle_registry are also exported
# at the end of this file
Expand Down
5 changes: 3 additions & 2 deletions ifsbench/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"""
from abc import ABC
from enum import Enum, auto
from .logging import error
from .util import classproperty

from ifsbench.logging import error
from ifsbench.util import classproperty


__all__ = ['CpuConfiguration', 'CpuBinding', 'CpuDistribution', 'Job']
Expand Down
6 changes: 3 additions & 3 deletions ifsbench/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"""
from abc import ABC, abstractmethod

from .job import CpuBinding, CpuDistribution
from .logging import debug, warning
from .util import as_tuple
from ifsbench.job import CpuBinding, CpuDistribution
from ifsbench.logging import debug, warning
from ifsbench.util import as_tuple


class Launcher(ABC):
Expand Down
53 changes: 52 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
# Make sure we use setuptools and have all required dependencies for that
[build-system]
requires = [
"setuptools >= 45",
"setuptools >= 61",
"wheel",
"setuptools_scm >= 6.2",
]
build-backend = "setuptools.build_meta"

[project]
name = "ifsbench"
authors = [
{name = "ECMWF", email = "[email protected]"},
]
description = "Toolbox for running, testing and benchmarking the IFS"
requires-python = ">=3.8"
license = {text = "Apache-2.0"}
dynamic = ["version", "readme"]
dependencies = [
"pandas", # essential for benchmarking data
"pyyaml", # essential for file handling
"pydantic", # essential for typing and configs
"click", # essential for CLI scripts
"f90nml", # essential for namelist handling
"xarray", # essential for data handling
]

[project.optional-dependencies]
tests = [
"pytest",
"pytest-cov",
"pylint",
]

grib = [
"cfgrib",
"eccodes",
"pygrib",
]

[project.scripts]
"ifs-bench.py" = "ifsbench.cli.pack:cli"
"nml-diff.py" = "ifsbench.cli.nml_diff:cli"

[tool.setuptools]
license-files = ["LICENSE", "CONTRIBUTORS.md"]

[tool.setuptools.dynamic]
readme = {file = ["README.md", "INSTALL.md"], content-type = "text/markdown"}

[tool.setuptools.packages.find]
where = ["."]
include = [
"ifsbench",
]
exclude = [
"tests",
]
namespaces = false

# Enable SCM versioning
[tool.setuptools_scm]
45 changes: 0 additions & 45 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from click.testing import CliRunner
import pytest

from ifsbench import cli, reference_options, run_options
from ifsbench.cli.cli import cli, reference_options, run_options


@pytest.fixture(scope='module', name='runner')
Expand Down