From db97dfdfed273bdac330b4bb6ab174ce9fb68f6f Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 15:44:24 +0200 Subject: [PATCH 01/11] Do not test Completer class as we might not need it in the future but keep it for now. --- .coveragerc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.coveragerc b/.coveragerc index c7ce4045..61e56460 100644 --- a/.coveragerc +++ b/.coveragerc @@ -21,6 +21,9 @@ exclude_lines = except ImportError: raise SystemExit + # Don't complain about the Completer class + class Completer + # Don't complain if non-runnable code isn't run: if 0: if perf_file *: From 5112a577ba6f28960d85022af4370e228b1b7153 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 15:44:45 +0200 Subject: [PATCH 02/11] Use flit as build system. --- freva-client/pyproject.toml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/freva-client/pyproject.toml b/freva-client/pyproject.toml index 8f497144..2eca584b 100644 --- a/freva-client/pyproject.toml +++ b/freva-client/pyproject.toml @@ -1,8 +1,9 @@ [build-system] -requires = ["setuptools>=61.0", "appdirs", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["flit_core >=3.2", "appdirs"] +build-backend = "flit_core.buildapi" [project] name = "freva-client" +dynamic = ["version"] description = "Search for climate data based on key-value pairs" authors = [{name = "DKRZ, Clint", email = "freva@dkrz.de"}] readme = "README.md" @@ -16,7 +17,6 @@ classifiers = [ "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", ] -dynamic = ["version"] requires-python = ">=3.8" dependencies = [ "appdirs", @@ -27,7 +27,7 @@ dependencies = [ "typer", ] [project.scripts] -freva-databrowser = "freva_databrowser:databrowser_cli.app" +freva-client = "freva_client:cli.app" [project.urls] Documentation = "https://freva-clint.github.io/databrowserAPI" Issues = "https://github.com/FREVA-CLINT/databrowserAPI/issues" @@ -36,8 +36,10 @@ Source = "https://github.com/FREVA-CLINT/databrowserAPI/" [project.optional-dependencies] dev = ["tox"] -[tool.distutils.bdist_wheel] -universal = true +[tool.flit.sdist] +include = ["assets/*"] -[tool.setuptools.dynamic] -version = {attr = "freva_client.__version__"} +[tool.flit.external-data] +directory = "assets" +[package-data] +freva_deployment = ["py.typed"] From 339656339bc9f1b51eaa4db0a5634a7100701471 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 15:45:05 +0200 Subject: [PATCH 03/11] Rename code. --- freva-client/src/freva_client/__init__.py | 2 +- freva-client/src/freva_client/__main__.py | 9 +++ freva-client/src/freva_client/cli/__init__.py | 6 ++ freva-client/src/freva_client/cli/cli_app.py | 23 +++++++ .../cli}/cli_utils.py | 22 ++++++- .../cli}/databrowser_cli.py | 65 +++++++++---------- .../py.typed | 0 .../query.py | 39 ++++------- .../src/freva_client/utils/__init__.py | 30 +++++++++ .../utils/databrowser_utils.py} | 47 +------------- .../utils}/logger.py | 0 .../src/freva_databrowser/__init__.py | 5 -- .../src/freva_databrowser/__main__.py | 18 ----- .../{freva_databrowser => }/tests/__init__.py | 0 .../{freva_databrowser => }/tests/conftest.py | 2 +- .../{freva_databrowser => }/tests/test_cli.py | 42 +++++------- .../tests/test_databrowser.py | 4 +- .../{freva_databrowser => }/tests/test_url.py | 2 +- 18 files changed, 152 insertions(+), 164 deletions(-) create mode 100644 freva-client/src/freva_client/__main__.py create mode 100644 freva-client/src/freva_client/cli/__init__.py create mode 100644 freva-client/src/freva_client/cli/cli_app.py rename freva-client/src/{freva_databrowser => freva_client/cli}/cli_utils.py (89%) rename freva-client/src/{freva_databrowser => freva_client/cli}/databrowser_cli.py (91%) rename freva-client/src/{freva_databrowser => freva_client}/py.typed (100%) rename freva-client/src/{freva_databrowser => freva_client}/query.py (95%) create mode 100644 freva-client/src/freva_client/utils/__init__.py rename freva-client/src/{freva_databrowser/utils.py => freva_client/utils/databrowser_utils.py} (80%) rename freva-client/src/{freva_databrowser => freva_client/utils}/logger.py (100%) delete mode 100644 freva-client/src/freva_databrowser/__init__.py delete mode 100644 freva-client/src/freva_databrowser/__main__.py rename freva-client/src/{freva_databrowser => }/tests/__init__.py (100%) rename freva-client/src/{freva_databrowser => }/tests/conftest.py (98%) rename freva-client/src/{freva_databrowser => }/tests/test_cli.py (75%) rename freva-client/src/{freva_databrowser => }/tests/test_databrowser.py (97%) rename freva-client/src/{freva_databrowser => }/tests/test_url.py (98%) diff --git a/freva-client/src/freva_client/__init__.py b/freva-client/src/freva_client/__init__.py index b140ffd5..3a27b7ad 100644 --- a/freva-client/src/freva_client/__init__.py +++ b/freva-client/src/freva_client/__init__.py @@ -14,7 +14,7 @@ need to apply data analysis plugins, please visit the """ -from freva_databrowser import databrowser +from .query import databrowser __version__ = "2404.0.0" __all__ = ["databrowser", "__version__"] diff --git a/freva-client/src/freva_client/__main__.py b/freva-client/src/freva_client/__main__.py new file mode 100644 index 00000000..903e53a9 --- /dev/null +++ b/freva-client/src/freva_client/__main__.py @@ -0,0 +1,9 @@ +"""Freva command line interface.""" + +import sys +from freva_client import cli + +__all__ = ["app"] + +if __name__ == "__main__": + sys.exit(cli.app()) diff --git a/freva-client/src/freva_client/cli/__init__.py b/freva-client/src/freva_client/cli/__init__.py new file mode 100644 index 00000000..f4083f97 --- /dev/null +++ b/freva-client/src/freva_client/cli/__init__.py @@ -0,0 +1,6 @@ +"""Command line interface for the freva-client library.""" + +from .databrowser_cli import * # noqa: F401 +from .cli_app import app + +__all__ = ["app"] diff --git a/freva-client/src/freva_client/cli/cli_app.py b/freva-client/src/freva_client/cli/cli_app.py new file mode 100644 index 00000000..b379029e --- /dev/null +++ b/freva-client/src/freva_client/cli/cli_app.py @@ -0,0 +1,23 @@ +"""Freva the Free Evaluation System command line interface.""" + +from rich import print as pprint +import typer + +from freva_client import __version__ +from freva_client.utils import logger + +APP_NAME: str = "freva-client" + +app = typer.Typer( + name=APP_NAME, + help=__doc__, + add_completion=False, + callback=logger.set_cli, +) + + +def version_callback(version: bool) -> None: + """Print the version and exit.""" + if version: + pprint(f"{APP_NAME}: {__version__}") + raise typer.Exit() diff --git a/freva-client/src/freva_databrowser/cli_utils.py b/freva-client/src/freva_client/cli/cli_utils.py similarity index 89% rename from freva-client/src/freva_databrowser/cli_utils.py rename to freva-client/src/freva_client/cli/cli_utils.py index a6f71618..387261bc 100644 --- a/freva-client/src/freva_databrowser/cli_utils.py +++ b/freva-client/src/freva_client/cli/cli_utils.py @@ -4,9 +4,25 @@ import inspect from typing import Any, Callable, Dict, List, Optional, Tuple, cast -from .databrowser_cli import app -from .query import databrowser -from .utils import parse_cli_args +import typer + +from freva_client.utils import logger +from freva_client.cli.cli_app import app +from freva_client import databrowser + + +def parse_cli_args(cli_args: List[str]) -> Dict[str, List[str]]: + """Convert the cli arguments to a dictionary.""" + logger.debug("parsing command line arguments.") + kwargs = {} + for entry in cli_args: + key, _, value = entry.partition("=") + if value and key not in kwargs: + kwargs[key] = [value] + elif value: + kwargs[key].append(value) + logger.debug(kwargs) + return kwargs class Completer: diff --git a/freva-client/src/freva_databrowser/databrowser_cli.py b/freva-client/src/freva_client/cli/databrowser_cli.py similarity index 91% rename from freva-client/src/freva_databrowser/databrowser_cli.py rename to freva-client/src/freva_client/cli/databrowser_cli.py index ca8fee4f..8d5621a8 100644 --- a/freva-client/src/freva_databrowser/databrowser_cli.py +++ b/freva-client/src/freva_client/cli/databrowser_cli.py @@ -8,30 +8,10 @@ from typing import Dict, List, Literal, Optional, Union, cast import typer -from freva_client import __version__ -from freva_databrowser.query import databrowser -from freva_databrowser.utils import ( - APP_NAME, - exception_handler, - logger, - parse_cli_args, -) -from rich import print as pprint - - -def version_callback(version: bool) -> None: - """Print the version and exit.""" - if version: - pprint(f"{APP_NAME}: {__version__}") - raise typer.Exit() - - -app = typer.Typer( - name=APP_NAME, - help=__doc__, - add_completion=False, - callback=logger.set_cli, -) +from freva_client import __version__, databrowser +from freva_client.utils import logger, exception_handler +from .cli_app import app, version_callback +from .cli_utils import parse_cli_args class UniqKeys(str, Enum): @@ -74,7 +54,10 @@ def get_help() -> str: ) -@app.command(name="overview", help="Get an overview over what is available.") +@app.command( + name="data-overview", + help="Get an overview over what is available in the databrowser.", +) @exception_handler def overview( host: Optional[str] = typer.Option( @@ -90,7 +73,9 @@ def overview( print(databrowser.overview(host=host)) -@app.command(name="metadata-search", help="Search for metadata (facets).") +@app.command( + name="metadata-search", help="Search databrowser for metadata (facets)." +) @exception_handler def metadata_search( search_keys: Optional[List[str]] = typer.Argument( @@ -160,7 +145,9 @@ def metadata_search( parse_json: bool = typer.Option( False, "-j", "--json", help="Parse output in json format." ), - verbose: int = typer.Option(0, "-v", help="Increase verbosity", count=True), + verbose: int = typer.Option( + 0, "-v", help="Increase verbosity", count=True + ), version: Optional[bool] = typer.Option( False, "-V", @@ -182,7 +169,9 @@ def metadata_search( result = databrowser.metadata_search( *(facets or []), time=time or "", - time_select=cast(Literal["file", "flexible", "strict"], time_select.value), + time_select=cast( + Literal["file", "flexible", "strict"], time_select.value + ), flavour=cast( Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"], flavour.value, @@ -200,7 +189,7 @@ def metadata_search( print(f"{key}: {', '.join(values)}") -@app.command(name="data-search", help="Search for datasets.") +@app.command(name="data-search", help="Search the databrowser for datasets.") @exception_handler def data_search( search_keys: Optional[List[str]] = typer.Argument( @@ -269,7 +258,9 @@ def data_search( "the hostname is read from a config file" ), ), - verbose: int = typer.Option(0, "-v", help="Increase verbosity", count=True), + verbose: int = typer.Option( + 0, "-v", help="Increase verbosity", count=True + ), multiversion: bool = typer.Option( False, "--mulit-version", @@ -312,7 +303,7 @@ def data_search( print(res) -@app.command(name="count", help="Count the search results") +@app.command(name="data-count", help="Count the databrowser search results") @exception_handler def count_values( search_keys: Optional[List[str]] = typer.Argument( @@ -388,7 +379,9 @@ def count_values( parse_json: bool = typer.Option( False, "-j", "--json", help="Parse output in json format." ), - verbose: int = typer.Option(0, "-v", help="Increase verbosity", count=True), + verbose: int = typer.Option( + 0, "-v", help="Increase verbosity", count=True + ), version: Optional[bool] = typer.Option( False, "-V", @@ -415,7 +408,9 @@ def count_values( result = databrowser.count_values( *facets, time=time or "", - time_select=cast(Literal["file", "flexible", "strict"], time_select), + time_select=cast( + Literal["file", "flexible", "strict"], time_select + ), flavour=cast( Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"], flavour.value, @@ -431,7 +426,9 @@ def count_values( databrowser( *facets, time=time or "", - time_select=cast(Literal["file", "flexible", "strict"], time_select), + time_select=cast( + Literal["file", "flexible", "strict"], time_select + ), flavour=cast( Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"], flavour.value, diff --git a/freva-client/src/freva_databrowser/py.typed b/freva-client/src/freva_client/py.typed similarity index 100% rename from freva-client/src/freva_databrowser/py.typed rename to freva-client/src/freva_client/py.typed diff --git a/freva-client/src/freva_databrowser/query.py b/freva-client/src/freva_client/query.py similarity index 95% rename from freva-client/src/freva_databrowser/query.py rename to freva-client/src/freva_client/query.py index 2b2d96c6..aad7b3ad 100644 --- a/freva-client/src/freva_databrowser/query.py +++ b/freva-client/src/freva_client/query.py @@ -10,9 +10,8 @@ import yaml from rich import print as pprint -from .utils import Config, logger - -__version__ = "2404.0.0" +from .utils import logger +from .utils.databrowser_utils import Config __all__ = ["databrowser"] @@ -156,9 +155,7 @@ def __init__( self, *facets: str, uniq_key: Literal["file", "uri"] = "file", - flavour: Literal[ - "freva", "cmip6", "cmip5", "cordex", "nextgems" - ] = "freva", + flavour: Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"] = "freva", time: Optional[str] = None, host: Optional[str] = None, time_select: Literal["flexible", "strict", "file"] = "flexible", @@ -191,8 +188,7 @@ def _add_search_keyword_args_from_facet( self, facets: Tuple[str, ...], search_kw: Dict[str, List[str]] ) -> None: metadata = { - k: v[::2] - for (k, v) in self._facet_search(extended_search=True).items() + k: v[::2] for (k, v) in self._facet_search(extended_search=True).items() } primary_key = list(metadata.keys() or ["project"])[0] num_facets = 0 @@ -217,9 +213,7 @@ def __iter__(self) -> Iterator[str]: for res in result.iter_lines(): yield res.decode("utf-8") except KeyboardInterrupt: - pprint( - "[red][b]User interrupt: Exit[/red][/b]", file=sys.stderr - ) + pprint("[red][b]User interrupt: Exit[/red][/b]", file=sys.stderr) def __repr__(self) -> str: params = ", ".join( @@ -246,9 +240,7 @@ def _repr_html_(self) -> str: # Create a table-like structure for available flavors and search facets style = 'style="text-align: left"' - facet_heading = ( - f"Available search facets for {self._flavour} flavour" - ) + facet_heading = f"Available search facets for {self._flavour} flavour" html_repr = ( "" f"
{self.__class__.__name__}" @@ -286,9 +278,7 @@ def __len__(self) -> int: def count_values( cls, *facets: str, - flavour: Literal[ - "freva", "cmip6", "cmip5", "cordex", "nextgems" - ] = "freva", + flavour: Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"] = "freva", time: Optional[str] = None, host: Optional[str] = None, time_select: Literal["flexible", "strict", "file"] = "flexible", @@ -385,9 +375,7 @@ def count_values( result = this._facet_search(extended_search=extended_search) counts = {} for facet, value_counts in result.items(): - counts[facet] = dict( - zip(value_counts[::2], map(int, value_counts[1::2])) - ) + counts[facet] = dict(zip(value_counts[::2], map(int, value_counts[1::2]))) return counts @cached_property @@ -412,17 +400,14 @@ def metadata(self) -> Dict[str, List[str]]: """ return { - k: v[::2] - for (k, v) in self._facet_search(extended_search=True).items() + k: v[::2] for (k, v) in self._facet_search(extended_search=True).items() } @classmethod def metadata_search( cls, *facets: str, - flavour: Literal[ - "freva", "cmip6", "cmip5", "cordex", "nextgems" - ] = "freva", + flavour: Literal["freva", "cmip6", "cmip5", "cordex", "nextgems"] = "freva", time: Optional[str] = None, host: Optional[str] = None, time_select: Literal["flexible", "strict", "file"] = "flexible", @@ -544,9 +529,7 @@ def metadata_search( ) return { k: v[::2] - for (k, v) in this._facet_search( - extended_search=extended_search - ).items() + for (k, v) in this._facet_search(extended_search=extended_search).items() } @classmethod diff --git a/freva-client/src/freva_client/utils/__init__.py b/freva-client/src/freva_client/utils/__init__.py new file mode 100644 index 00000000..facd31e1 --- /dev/null +++ b/freva-client/src/freva_client/utils/__init__.py @@ -0,0 +1,30 @@ +"""Utilities for the general freva-client lib.""" + +from functools import wraps +import logging +from typing import Any, Callable, Dict, Literal, Optional, Tuple, cast + +from .logger import Logger + +logger: Logger = cast(Logger, logging.getLogger("freva-client")) + + +def exception_handler(func: Callable[..., Any]) -> Callable[..., Any]: + """Wrap an exception handler around the cli functions.""" + + @wraps(func) + def wrapper(*args: Any, **kwargs: Any) -> Any: + """Wrapper function that handles the exeption.""" + try: + return func(*args, **kwargs) + except KeyboardInterrupt: + pprint("[red][b]User interrupt: Exit[/red][/b]", file=sys.stderr) + raise SystemExit(150) from None + except BaseException as error: + if logger.getEffectiveLevel() <= logging.DEBUG: + logger.exception(error) + else: + logger.error(error) + raise SystemExit(1) from None + + return wrapper diff --git a/freva-client/src/freva_databrowser/utils.py b/freva-client/src/freva_client/utils/databrowser_utils.py similarity index 80% rename from freva-client/src/freva_databrowser/utils.py rename to freva-client/src/freva_client/utils/databrowser_utils.py index 49d96bb0..b50b92fa 100644 --- a/freva-client/src/freva_databrowser/utils.py +++ b/freva-client/src/freva_client/utils/databrowser_utils.py @@ -1,59 +1,18 @@ """Various utilities for getting the databrowser working.""" -import logging import os import sys import sysconfig from configparser import ConfigParser, ExtendedInterpolation -from functools import cached_property, wraps +from functools import cached_property from pathlib import Path -from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, cast +from typing import Any, Dict, Literal, Optional, Tuple, cast import appdirs import requests import tomli -from rich import print as pprint -from .logger import Logger - -APP_NAME: str = "freva-databrowser" - -logger: Logger = cast(Logger, logging.getLogger(APP_NAME)) - - -def parse_cli_args(cli_args: List[str]) -> Dict[str, List[str]]: - """Convert the cli arguments to a dictionary.""" - logger.debug("parsing command line arguments.") - kwargs = {} - for entry in cli_args: - key, _, value = entry.partition("=") - if value and key not in kwargs: - kwargs[key] = [value] - elif value: - kwargs[key].append(value) - logger.debug(kwargs) - return kwargs - - -def exception_handler(func: Callable[..., Any]) -> Callable[..., Any]: - """Wrap an exception handler around the cli functions.""" - - @wraps(func) - def wrapper(*args: Any, **kwargs: Any) -> Any: - """Wrapper function that handles the exeption.""" - try: - return func(*args, **kwargs) - except KeyboardInterrupt: - pprint("[red][b]User interrupt: Exit[/red][/b]", file=sys.stderr) - raise SystemExit(150) from None - except BaseException as error: - if logger.getEffectiveLevel() <= logging.DEBUG: - logger.exception(error) - else: - logger.error(error) - raise SystemExit(1) from None - - return wrapper +from freva_client.utils import logger class Config: diff --git a/freva-client/src/freva_databrowser/logger.py b/freva-client/src/freva_client/utils/logger.py similarity index 100% rename from freva-client/src/freva_databrowser/logger.py rename to freva-client/src/freva_client/utils/logger.py diff --git a/freva-client/src/freva_databrowser/__init__.py b/freva-client/src/freva_databrowser/__init__.py deleted file mode 100644 index 923ef3d7..00000000 --- a/freva-client/src/freva_databrowser/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Search quickly and intuitively for many different climate datasets.""" - -from .query import databrowser - -__all__ = ["databrowser"] diff --git a/freva-client/src/freva_databrowser/__main__.py b/freva-client/src/freva_databrowser/__main__.py deleted file mode 100644 index 61f195a2..00000000 --- a/freva-client/src/freva_databrowser/__main__.py +++ /dev/null @@ -1,18 +0,0 @@ -"""Print command line argument options.""" - -import logging -import sys - -from freva_databrowser.cli_utils import Completer -from freva_databrowser.utils import logger - -logger.set_level(logging.CRITICAL) - - -try: - comp = Completer.parse_choices( - [arg.strip() for arg in sys.argv[1:] if arg.strip()] - ) - comp.formated_print() -except (ValueError, KeyboardInterrupt): - pass diff --git a/freva-client/src/freva_databrowser/tests/__init__.py b/freva-client/src/tests/__init__.py similarity index 100% rename from freva-client/src/freva_databrowser/tests/__init__.py rename to freva-client/src/tests/__init__.py diff --git a/freva-client/src/freva_databrowser/tests/conftest.py b/freva-client/src/tests/conftest.py similarity index 98% rename from freva-client/src/freva_databrowser/tests/conftest.py rename to freva-client/src/tests/conftest.py index 9340c1fc..ede5c3f0 100644 --- a/freva-client/src/freva_databrowser/tests/conftest.py +++ b/freva-client/src/tests/conftest.py @@ -7,7 +7,7 @@ import mock import pytest -from freva_databrowser.utils import logger +from freva_client.utils import logger from typer.testing import CliRunner diff --git a/freva-client/src/freva_databrowser/tests/test_cli.py b/freva-client/src/tests/test_cli.py similarity index 75% rename from freva-client/src/freva_databrowser/tests/test_cli.py rename to freva-client/src/tests/test_cli.py index b95d3c29..b8f8c7f3 100644 --- a/freva-client/src/freva_databrowser/tests/test_cli.py +++ b/freva-client/src/tests/test_cli.py @@ -2,14 +2,14 @@ import json -from freva_databrowser.databrowser_cli import app +from freva_client.cli import app from pytest import LogCaptureFixture from typer.testing import CliRunner def test_overview(cli_runner: CliRunner) -> None: """Test the overview sub command.""" - res = cli_runner.invoke(app, ["overview", "--host", "localhost:8080"]) + res = cli_runner.invoke(app, ["data-overview", "--host", "localhost:8080"]) assert res.exit_code == 0 assert res.stdout @@ -32,18 +32,14 @@ def test_search_files(cli_runner: CliRunner) -> None: ) assert res.exit_code == 0 assert not res.stdout - res = cli_runner.invoke( - app, ["data-search", "--host", "localhost:8080", "--json"] - ) + res = cli_runner.invoke(app, ["data-search", "--host", "localhost:8080", "--json"]) assert res.exit_code == 0 assert isinstance(json.loads(res.stdout), list) def test_metadata_search(cli_runner: CliRunner) -> None: """Test the metadata-search sub command.""" - res = cli_runner.invoke( - app, ["metadata-search", "--host", "localhost:8080"] - ) + res = cli_runner.invoke(app, ["metadata-search", "--host", "localhost:8080"]) assert res.exit_code == 0 assert res.stdout res = cli_runner.invoke( @@ -67,22 +63,20 @@ def test_metadata_search(cli_runner: CliRunner) -> None: def test_count_values(cli_runner: CliRunner) -> None: """Test the count sub command.""" - res = cli_runner.invoke(app, ["count", "--host", "localhost:8080"]) + res = cli_runner.invoke(app, ["data-count", "--host", "localhost:8080"]) assert res.exit_code == 0 assert res.stdout - res = cli_runner.invoke( - app, ["count", "--host", "localhost:8080", "--json"] - ) + res = cli_runner.invoke(app, ["data-count", "--host", "localhost:8080", "--json"]) assert res.exit_code == 0 assert isinstance(json.loads(res.stdout), int) - res = cli_runner.invoke(app, ["count", "*", "--host", "localhost:8080"]) + res = cli_runner.invoke(app, ["data-count", "*", "--host", "localhost:8080"]) assert res.exit_code == 0 assert res.stdout res = cli_runner.invoke( app, [ - "count", + "data-count", "--facet", "ocean", "--host", @@ -94,14 +88,14 @@ def test_count_values(cli_runner: CliRunner) -> None: assert res.exit_code == 0 assert isinstance(json.loads(res.stdout), dict) res = cli_runner.invoke( - app, ["count", "--facet", "ocean", "--host", "localhost:8080", "-d"] + app, ["data-count", "--facet", "ocean", "--host", "localhost:8080", "-d"] ) assert res.exit_code == 0 assert res.stdout res = cli_runner.invoke( app, [ - "count", + "data-count", "--facet", "ocean", "--host", @@ -114,21 +108,15 @@ def test_count_values(cli_runner: CliRunner) -> None: assert json.loads(res.stdout) == 0 -def test_failed_command( - cli_runner: CliRunner, caplog: LogCaptureFixture -) -> None: +def test_failed_command(cli_runner: CliRunner, caplog: LogCaptureFixture) -> None: """Test the handling of bad commands.""" - for cmd in ("count", "data-search", "metadata-search"): + for cmd in ("data-count", "data-search", "metadata-search"): caplog.clear() - res = cli_runner.invoke( - app, [cmd, "--host", "localhost:8080", "foo=b"] - ) + res = cli_runner.invoke(app, [cmd, "--host", "localhost:8080", "foo=b"]) assert res.exit_code == 0 assert caplog.records assert caplog.records[-1].levelname == "WARNING" - res = cli_runner.invoke( - app, [cmd, "--host", "localhost:8080", "-f", "foo"] - ) + res = cli_runner.invoke(app, [cmd, "--host", "localhost:8080", "-f", "foo"]) assert res.exit_code != 0 caplog.clear() res = cli_runner.invoke(app, [cmd, "--host", "foo"]) @@ -143,6 +131,6 @@ def test_failed_command( def test_check_versions(cli_runner: CliRunner) -> None: """Check the versions.""" - for cmd in ("count", "data-search", "metadata-search"): + for cmd in ("data-count", "data-search", "metadata-search"): res = cli_runner.invoke(app, [cmd, "-V"]) assert res.exit_code == 0 diff --git a/freva-client/src/freva_databrowser/tests/test_databrowser.py b/freva-client/src/tests/test_databrowser.py similarity index 97% rename from freva-client/src/freva_databrowser/tests/test_databrowser.py rename to freva-client/src/tests/test_databrowser.py index 842dc34f..d0852f6f 100644 --- a/freva-client/src/freva_databrowser/tests/test_databrowser.py +++ b/freva-client/src/tests/test_databrowser.py @@ -1,8 +1,8 @@ """Tests for the databrowser class.""" import pytest -from freva_databrowser import databrowser -from freva_databrowser.logger import DatabrowserWarning +from freva_client import databrowser +from freva_client.utils.logger import DatabrowserWarning def test_search_files() -> None: diff --git a/freva-client/src/freva_databrowser/tests/test_url.py b/freva-client/src/tests/test_url.py similarity index 98% rename from freva-client/src/freva_databrowser/tests/test_url.py rename to freva-client/src/tests/test_url.py index 2923c14a..757785f4 100644 --- a/freva-client/src/freva_databrowser/tests/test_url.py +++ b/freva-client/src/tests/test_url.py @@ -5,7 +5,7 @@ import mock import pytest -from freva_databrowser import databrowser +from freva_client import databrowser def test_invalid_eval_config(invalid_eval_conf_file: Path) -> None: From 99ecc76b197823c3f55cf6b4c55f43c140f9c605 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 15:57:11 +0200 Subject: [PATCH 04/11] Update docs. --- docs/source/databrowser/cli.rst | 72 +++++++++++++------------- docs/source/databrowser/python-lib.rst | 12 ++--- docs/source/index.rst | 14 ++++- 3 files changed, 54 insertions(+), 44 deletions(-) diff --git a/docs/source/databrowser/cli.rst b/docs/source/databrowser/cli.rst index c5a96523..439daadc 100644 --- a/docs/source/databrowser/cli.rst +++ b/docs/source/databrowser/cli.rst @@ -5,22 +5,22 @@ The databrowser command line interface .. toctree:: :maxdepth: 3 -This section introduces the usage of the ``freva-databrowser`` command. +This section introduces the usage of the ``freva-client`` command. Please see the :ref:`install+configure` section on how to install and configure the command line interface. -After successful installation you will have the ``freva-databrowser`` command +After successful installation you will have the ``freva-client`` command .. code:: console - freva-databrowser --help + freva-client --help .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "--help"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "--help"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -32,13 +32,13 @@ databrowser application. You can search for data locations by applying the .. code:: console - freva-databrowser --help + freva-client data-search --help .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "data-search", "--help"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-search", "--help"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -54,13 +54,13 @@ variables available that satisfies a certain constraint (e.g. sampled .. code:: console - freva-databrowser project=observations variable=pr model=cp* + freva-client project=observations variable=pr model=cp* .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "data-search", "experiment=cmorph"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-search", "experiment=cmorph"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) There are many more options for defining a value for a given key: @@ -131,13 +131,13 @@ ranges: .. code:: console - freva-databrowser data-search project=observations -t '2016-09-02T22:15 to 2016-10' + freva-client data-search project=observations -t '2016-09-02T22:15 to 2016-10' .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "data-search", + res = run(["freva-client", "data-search", "-t", "2016-09-02T22:15 to 2016-10", ], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -151,26 +151,26 @@ start of the time period: .. code:: console - freva-databrowser data-search project=observations -t '2016-09-02T22:15 to 2016-10' -ts strict + freva-client data-search project=observations -t '2016-09-02T22:15 to 2016-10' -ts strict .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "data-search", "-t", "2016-09-02T22:15 to 2016-10", "-ts", "strict"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-search", "-t", "2016-09-02T22:15 to 2016-10", "-ts", "strict"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) Giving single time steps is also possible: .. code:: console - freva-databrowser data-search project=observations -t 2016-09-02T22:10 + freva-client data-search project=observations -t 2016-09-02T22:10 .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "count", "-t", "2016-09-02T22:00"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-search", "-t", "2016-09-02T22:00"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) .. note:: @@ -186,32 +186,32 @@ Query the number of occurrences ------------------------------- In some cases it might be useful to know how many files are found in the databrowser for certain search constraints. In such cases you can use the -``count`` sub command to count the number of *found* files instead of getting +``data-count`` sub command to count the number of *found* files instead of getting the files themselves. .. code:: console - freva-databrowser count --help + freva-client data-count --help .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "count", "--help"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-count", "--help"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) -By default the ``count`` sub command will display the total number of items +By default the ``data-count`` sub command will display the total number of items matching your search query. For example: .. code:: console - freva-databrowser count project=observations + freva-client data-count project=observations .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "count", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-count", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) If you want to group the number of occurrences by search categories (facets) @@ -219,13 +219,13 @@ use the ``-d`` or ``--detail`` flag: .. code:: console - freva-databrowser count -d project=observations + freva-client data-count -d project=observations .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "count", "-d", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "data-count", "-d", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -237,13 +237,13 @@ For this you use the ``metadata-search`` sub command: .. code:: console - freva-databrowser metadata-search --help + freva-client metadata-search --help .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search", "--help"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search", "--help"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) Just like with any other databrowser command you can apply different search @@ -251,13 +251,13 @@ constraints when acquiring metadata .. code:: console - freva-databrowser metadata-search project=observations + freva-client metadata-search project=observations .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -267,13 +267,13 @@ flag. .. code:: console - freva-databrowser metadata-search -e project=observations + freva-client metadata-search -e project=observations .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search", "-e", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search", "-e", "project=observations"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) Sometimes you don't exactly know the exact names of the search keys and @@ -282,13 +282,13 @@ for getting all ocean reanalysis datasets you can apply the ``--facet`` flag: .. code:: console - freva-databrowser metadata-search -e realm=ocean --facet 'rean*' + freva-client metadata-search -e realm=ocean --facet 'rean*' .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search","--facet", "rean*", "realm=ocean"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search","--facet", "rean*", "realm=ocean"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) @@ -302,13 +302,13 @@ metadata of those files on tape: .. code:: console - freva-databrowser metadata-search -e file="/arch/*" + freva-client metadata-search -e file="/arch/*" .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search", "-e", "file=/arch*"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search", "-e", "file=/arch*"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) Parsing the command output @@ -322,21 +322,21 @@ search to the `command line json processor jq `_: .. code:: console - freva-databrowser metadata-search -e file="/arch/*" --json + freva-client metadata-search -e file="/arch/*" --json .. execute_code:: :hide_code: from subprocess import run, PIPE - res = run(["freva-databrowser", "metadata-search", "-e", "file=/arch*", "--json"], check=True, stdout=PIPE, stderr=PIPE) + res = run(["freva-client", "metadata-search", "-e", "file=/arch*", "--json"], check=True, stdout=PIPE, stderr=PIPE) print(res.stdout.decode()) -By using the pipe operator ``|`` the JSON output of the `freva-databrowser` +By using the pipe operator ``|`` the JSON output of the `freva-client` commands can be piped and processed by ``jq``: .. code:: console - freva-databrowser metadata-search -e file="/arch/*" --json | jq -r .ensemble[0] + freva-client metadata-search -e file="/arch/*" --json | jq -r .ensemble[0] .. execute_code:: :hide_code: diff --git a/docs/source/databrowser/python-lib.rst b/docs/source/databrowser/python-lib.rst index 650f23c5..0f3d8500 100644 --- a/docs/source/databrowser/python-lib.rst +++ b/docs/source/databrowser/python-lib.rst @@ -14,8 +14,8 @@ TLDR: Too long didn't read To query data databrowser and search for data you have three different options. You can the to following methods -- :py:class:`databrowser`: The main class for searching data is the - :py:class:`freva.databrowser` class. After creating in instance of the +- :py:class:`freva_client.databrowser`: The main class for searching data is the + :py:class:`freva_client.databrowser` class. After creating in instance of the databrowser class with your specific search constraints you can get retrieve all *files* or *uris* that matching your search constraints. You can also retrieve a count of the number objects matching the search, as well as @@ -24,11 +24,11 @@ You can the to following methods can be useful to get information on the storage system where the *files* or object stores are located. -- :py:meth:`databrowser.metadata_search`: This class method lists all search - categories (facets) and their values. +- :py:meth:`freva_client.databrowser.metadata_search`: This class method lists + all search categories (facets) and their values. -- :py:meth:`freva.count_values`: You can count the occurrences of - search results with this method. +- :py:meth:`freva_client.databrowser.count_values`: You can count the + occurrences of search results with this method. Library Reference diff --git a/docs/source/index.rst b/docs/source/index.rst index eb54cdaf..c823767c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -52,12 +52,22 @@ Installation of the client library is straight forward and can be achieved via: .. code:: console - python3 -m pip install freva-databrowser + python3 -m pip install freva-client After successful installation you will also have to following command line interfaces (cli) available: -- ``freva-databrowser``: cli to search for data. +.. code:: console + + freva-client --help + +.. execute_code:: + :hide_code: + + from subprocess import run, PIPE + res = run(["freva-client", "--help"], check=True, stdout=PIPE, stderr=PIPE) + print(res.stdout.decode()) + Configuration +++++++++++++ From a6b850eedc4e1e5952d65384bf0ef75a64261dea Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:06:32 +0200 Subject: [PATCH 05/11] Add pypi workflow. --- .github/workflows/build_job.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build_job.yml b/.github/workflows/build_job.yml index b8556fef..c0057618 100644 --- a/.github/workflows/build_job.yml +++ b/.github/workflows/build_job.yml @@ -97,6 +97,38 @@ jobs: tags: | ghcr.io/freva-clint/freva-rest-api:${{ steps.repository.outputs.tag }} ghcr.io/freva-clint/freva-rest-api:latest + pypi: + name: Create Pip package + permissions: + id-token: write + needs: [tests, build-and-push-vault-image] + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - + name: Install flit + run: python -m pip install flit + - + name: Copy LICENSE file + run: cp LICENSE freva-client + - + name: Building freva-deployment 📦 with flit + run: flit build + working-directory: freva-client + - + name: publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + skip-existing: true + verbose: true bump-databrowser-version: runs-on: ubuntu-latest From d951c62dc6f2a4c769cf8dcddfc383c5d331465e Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:07:16 +0200 Subject: [PATCH 06/11] Update .gitignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index af79f098..e58a66b0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,9 @@ __pycache__/ # C extensions *.so + # Distribution / packaging +freva-client/LICENSE .Python build/ develop-eggs/ From 5ccad3cec5efce391e156982b23ca23f961dc5c0 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:14:58 +0200 Subject: [PATCH 07/11] Update release procedure. --- .github/workflows/build_job.yml | 4 +--- freva-client/pyproject.toml | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build_job.yml b/.github/workflows/build_job.yml index c0057618..df0f2eda 100644 --- a/.github/workflows/build_job.yml +++ b/.github/workflows/build_job.yml @@ -115,9 +115,6 @@ jobs: - name: Install flit run: python -m pip install flit - - - name: Copy LICENSE file - run: cp LICENSE freva-client - name: Building freva-deployment 📦 with flit run: flit build @@ -129,6 +126,7 @@ jobs: password: ${{ secrets.PYPI_API_TOKEN }} skip-existing: true verbose: true + packages-dir: freva-client/dist bump-databrowser-version: runs-on: ubuntu-latest diff --git a/freva-client/pyproject.toml b/freva-client/pyproject.toml index 2eca584b..6d773a8f 100644 --- a/freva-client/pyproject.toml +++ b/freva-client/pyproject.toml @@ -7,7 +7,6 @@ dynamic = ["version"] description = "Search for climate data based on key-value pairs" authors = [{name = "DKRZ, Clint", email = "freva@dkrz.de"}] readme = "README.md" -license = {file = "LICENSE"} classifiers = [ "Development Status :: 3 - Alpha", "Environment :: Console", From e79c65eb7129d9f494b3fc331d497526450d75a7 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:24:41 +0200 Subject: [PATCH 08/11] Fix linting problems. --- freva-client/src/freva_client/__main__.py | 3 ++- freva-client/src/freva_client/cli/__init__.py | 2 +- freva-client/src/freva_client/cli/cli_app.py | 3 +-- .../src/freva_client/cli/cli_utils.py | 6 ++--- .../src/freva_client/cli/databrowser_cli.py | 5 +++-- .../src/freva_client/utils/__init__.py | 7 ++++-- .../freva_client/utils/databrowser_utils.py | 22 +++++-------------- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/freva-client/src/freva_client/__main__.py b/freva-client/src/freva_client/__main__.py index 903e53a9..09cf6f49 100644 --- a/freva-client/src/freva_client/__main__.py +++ b/freva-client/src/freva_client/__main__.py @@ -1,9 +1,10 @@ """Freva command line interface.""" import sys + from freva_client import cli -__all__ = ["app"] +__all__ = ["cli"] if __name__ == "__main__": sys.exit(cli.app()) diff --git a/freva-client/src/freva_client/cli/__init__.py b/freva-client/src/freva_client/cli/__init__.py index f4083f97..f675823d 100644 --- a/freva-client/src/freva_client/cli/__init__.py +++ b/freva-client/src/freva_client/cli/__init__.py @@ -1,6 +1,6 @@ """Command line interface for the freva-client library.""" -from .databrowser_cli import * # noqa: F401 from .cli_app import app +from .databrowser_cli import * # noqa: F401 __all__ = ["app"] diff --git a/freva-client/src/freva_client/cli/cli_app.py b/freva-client/src/freva_client/cli/cli_app.py index b379029e..7db3a862 100644 --- a/freva-client/src/freva_client/cli/cli_app.py +++ b/freva-client/src/freva_client/cli/cli_app.py @@ -1,10 +1,9 @@ """Freva the Free Evaluation System command line interface.""" -from rich import print as pprint import typer - from freva_client import __version__ from freva_client.utils import logger +from rich import print as pprint APP_NAME: str = "freva-client" diff --git a/freva-client/src/freva_client/cli/cli_utils.py b/freva-client/src/freva_client/cli/cli_utils.py index 387261bc..090acc67 100644 --- a/freva-client/src/freva_client/cli/cli_utils.py +++ b/freva-client/src/freva_client/cli/cli_utils.py @@ -4,11 +4,9 @@ import inspect from typing import Any, Callable, Dict, List, Optional, Tuple, cast -import typer - -from freva_client.utils import logger -from freva_client.cli.cli_app import app from freva_client import databrowser +from freva_client.cli.cli_app import app +from freva_client.utils import logger def parse_cli_args(cli_args: List[str]) -> Dict[str, List[str]]: diff --git a/freva-client/src/freva_client/cli/databrowser_cli.py b/freva-client/src/freva_client/cli/databrowser_cli.py index 8d5621a8..18f43354 100644 --- a/freva-client/src/freva_client/cli/databrowser_cli.py +++ b/freva-client/src/freva_client/cli/databrowser_cli.py @@ -8,8 +8,9 @@ from typing import Dict, List, Literal, Optional, Union, cast import typer -from freva_client import __version__, databrowser -from freva_client.utils import logger, exception_handler +from freva_client import databrowser +from freva_client.utils import exception_handler, logger + from .cli_app import app, version_callback from .cli_utils import parse_cli_args diff --git a/freva-client/src/freva_client/utils/__init__.py b/freva-client/src/freva_client/utils/__init__.py index facd31e1..32e596ec 100644 --- a/freva-client/src/freva_client/utils/__init__.py +++ b/freva-client/src/freva_client/utils/__init__.py @@ -1,8 +1,11 @@ """Utilities for the general freva-client lib.""" -from functools import wraps import logging -from typing import Any, Callable, Dict, Literal, Optional, Tuple, cast +import sys +from functools import wraps +from typing import Any, Callable, cast + +from rich import print as pprint from .logger import Logger diff --git a/freva-client/src/freva_client/utils/databrowser_utils.py b/freva-client/src/freva_client/utils/databrowser_utils.py index b50b92fa..bca58028 100644 --- a/freva-client/src/freva_client/utils/databrowser_utils.py +++ b/freva-client/src/freva_client/utils/databrowser_utils.py @@ -12,8 +12,6 @@ import requests import tomli -from freva_client.utils import logger - class Config: """Client config class. @@ -59,9 +57,7 @@ def _read_toml(self, path: Path) -> str: host = f"{host}:{port}" return f"{scheme}://{host}" - def _read_config( - self, path: Path, file_type: Literal["toml", "ini"] - ) -> str: + def _read_config(self, path: Path, file_type: Literal["toml", "ini"]) -> str: """Read the configuration.""" data_types = {"toml": self._read_toml, "ini": self._read_ini} try: @@ -76,9 +72,7 @@ def overview(self) -> Dict[str, Any]: try: res = requests.get(f"{self.databrowser_url}/overview", timeout=3) except requests.exceptions.ConnectionError: - raise ValueError( - f"Could not connect to {self.databrowser_url}" - ) from None + raise ValueError(f"Could not connect to {self.databrowser_url}") from None return cast(Dict[str, Any], res.json()) def _get_databrowser_host_from_config(self) -> str: @@ -93,9 +87,7 @@ def _get_databrowser_host_from_config(self) -> str: Path(appdirs.user_config_dir("freva")) / "freva.toml": "toml", Path(self.get_dirs(user=True)) / "freva.toml": "toml", freva_config: "toml", - Path( - os.environ.get("EVALUATION_SYSTEM_CONFIG_FILE") or eval_conf - ): "ini", + Path(os.environ.get("EVALUATION_SYSTEM_CONFIG_FILE") or eval_conf): "ini", } for config_path, config_type in paths.items(): if config_path.is_file(): @@ -122,17 +114,13 @@ def flavour(self) -> str: @property def search_url(self) -> str: """Define the data search endpoint.""" - return ( - f"{self.databrowser_url}/data_search/" - f"{self.flavour}/{self.uniq_key}" - ) + return f"{self.databrowser_url}/data_search/" f"{self.flavour}/{self.uniq_key}" @property def metadata_url(self) -> str: """Define the endpoint for the metadata search.""" return ( - f"{self.databrowser_url}/metadata_search/" - f"{self.flavour}/{self.uniq_key}" + f"{self.databrowser_url}/metadata_search/" f"{self.flavour}/{self.uniq_key}" ) @staticmethod From b9dce028edc90307fe3e99c0782335b782062ba0 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:30:13 +0200 Subject: [PATCH 09/11] Adjust new github url. --- README.md | 10 +++++----- docs/source/index.rst | 10 +++++----- freva-client/README.md | 6 +++--- freva-client/pyproject.toml | 6 +++--- freva-rest/README.md | 10 +++++----- freva-rest/pyproject.toml | 6 +++--- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6425befb..31ac82c7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![License](https://img.shields.io/badge/License-BSD-purple.svg)](LICENSE) [![Python](https://img.shields.io/badge/python-3.12-red.svg)](https://www.python.org/downloads/release/python-312/) -[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/databrowserAPI) -[![Tests](https://github.com/FREVA-CLINT/databrowserAPI/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/databrowserAPI/actions) -[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/databrowserAPI/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/databrowserAPI) +[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/freva-nextgen) +[![Tests](https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/freva-nextgen/actions) +[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/freva-nextgen) This repository contains the *freva-rest services* defining rest endpoints that make up the freva server services as well as the client @@ -25,8 +25,8 @@ rest service counterparts. 2. Clone this repository: ```console -git clone git@github.com:FREVA-CLINT/databrowserAPI.git -cd databrowserAPI +git clone git@github.com:FREVA-CLINT/freva-nextgen.git +cd freva-nextgen ``` 3. Install flit: diff --git a/docs/source/index.rst b/docs/source/index.rst index c823767c..417f868b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -17,13 +17,13 @@ Freva: The free evaluation system :target: https://www.python.org/downloads/release/python-312/ .. image:: https://img.shields.io/badge/ViewOn-GitHub-purple - :target: https://github.com/FREVA-CLINT/databrowserAPI + :target: https://github.com/FREVA-CLINT/freva-nextgen -.. image:: https://github.com/FREVA-CLINT/databrowserAPI/actions/workflows/ci_job.yml/badge.svg - :target: https://github.com/FREVA-CLINT/databrowserAPI/actions +.. image:: https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg + :target: https://github.com/FREVA-CLINT/freva-nextgen/actions -.. image:: https://codecov.io/github/FREVA-CLINT/databrowserAPI/branch/init/graph/badge.svg?token=dGhXxh7uP3 - :target: https://codecov.io/github/FREVA-CLINT/databrowserAPI +.. image:: https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3 + :target: https://codecov.io/github/FREVA-CLINT/freva-nextgen Freva, the free evaluation system framework, is a data search and analysis diff --git a/freva-client/README.md b/freva-client/README.md index 95b4f550..32695475 100644 --- a/freva-client/README.md +++ b/freva-client/README.md @@ -2,9 +2,9 @@ [![License](https://img.shields.io/badge/License-BSD-purple.svg)](LICENSE) [![Python](https://img.shields.io/badge/python-3.12-red.svg)](https://www.python.org/downloads/release/python-312/) -[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/databrowserAPI) -[![Tests](https://github.com/FREVA-CLINT/databrowserAPI/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/databrowserAPI/actions) -[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/databrowserAPI/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/databrowserAPI) +[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/freva-nextgen) +[![Tests](https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/freva-nextgen/actions) +[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/freva-nextgen) The freva-client library is a small library that makes connections to the freva server. The client library currently supports the following services: diff --git a/freva-client/pyproject.toml b/freva-client/pyproject.toml index 6d773a8f..0e34e77c 100644 --- a/freva-client/pyproject.toml +++ b/freva-client/pyproject.toml @@ -28,9 +28,9 @@ dependencies = [ [project.scripts] freva-client = "freva_client:cli.app" [project.urls] -Documentation = "https://freva-clint.github.io/databrowserAPI" -Issues = "https://github.com/FREVA-CLINT/databrowserAPI/issues" -Source = "https://github.com/FREVA-CLINT/databrowserAPI/" +Documentation = "https://freva-clint.github.io/freva-nextgen" +Issues = "https://github.com/FREVA-CLINT/freva-nextgen/issues" +Source = "https://github.com/FREVA-CLINT/freva-nextgen/" [project.optional-dependencies] dev = ["tox"] diff --git a/freva-rest/README.md b/freva-rest/README.md index 24c11f3d..78776a1b 100644 --- a/freva-rest/README.md +++ b/freva-rest/README.md @@ -2,9 +2,9 @@ [![License](https://img.shields.io/badge/License-BSD-purple.svg)](LICENSE) [![Python](https://img.shields.io/badge/python-3.12-red.svg)](https://www.python.org/downloads/release/python-312/) -[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/databrowserAPI) -[![Tests](https://github.com/FREVA-CLINT/databrowserAPI/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/databrowserAPI/actions) -[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/databrowserAPI/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/databrowserAPI) +[![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/freva-nextgen) +[![Tests](https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/freva-nextgen/actions) +[![Test-Coverage](https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/freva-nextgen) This repository contains the *freva-rest services* defining rest endpoints that make up the freva server services as well as the client @@ -25,8 +25,8 @@ rest service counterparts. 2. Clone this repository: ```console -git clone git@github.com:FREVA-CLINT/databrowserAPI.git -cd databrowserAPI +git clone git@github.com:FREVA-CLINT/freva-nextgen.git +cd freva-nextgen ``` 3. Install flit: diff --git a/freva-rest/pyproject.toml b/freva-rest/pyproject.toml index fdb14bb7..0e2bff1a 100644 --- a/freva-rest/pyproject.toml +++ b/freva-rest/pyproject.toml @@ -33,9 +33,9 @@ dependencies = [ [project.scripts] freva-rest-server = "freva_rest.cli:cli" [project.urls] -Documentation = "https://freva-clint.github.io/databrowserAPI" -Issues = "https://github.com/FREVA-CLINT/databrowserAPI/issues" -Source = "https://github.com/FREVA-CLINT/databrowserAPI/" +Documentation = "https://freva-clint.github.io/freva-nextgen" +Issues = "https://github.com/FREVA-CLINT/freva-nextgen/issues" +Source = "https://github.com/FREVA-CLINT/freva-nextgen/" [project.optional-dependencies] dev = ["tox"] From 56f5c77c7537818e5d5072c35ef58cdbc099e424 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:34:10 +0200 Subject: [PATCH 10/11] Adjust python version classifiers. --- freva-client/pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/freva-client/pyproject.toml b/freva-client/pyproject.toml index 0e34e77c..0b0083e1 100644 --- a/freva-client/pyproject.toml +++ b/freva-client/pyproject.toml @@ -15,6 +15,11 @@ classifiers = [ "License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] requires-python = ">=3.8" dependencies = [ From a7923b7aa37a9cf5211a1e75e023401344716e40 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Tue, 14 May 2024 16:53:44 +0200 Subject: [PATCH 11/11] Update pyproject.toml --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7f405421..35dd2b7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,8 +108,8 @@ allowlist_externals = rm commands_pre = curl -H 'Cache-Control: no-cache' -Ls -o bump.py https://raw.githubusercontent.com/FREVA-CLINT/freva-deployment/main/release.py commands_post = rm bump.py [testenv:bump] -commands = python3 bump.py deploy databrowser -b versions -v -commands_pre = curl -H 'Cache-Control: no-cache' -Ls -o bump.py https://raw.githubusercontent.com/FREVA-CLINT/freva-deployment/versions/release.py +commands = python3 bump.py deploy -p freva-rest -v +commands_pre = curl -H 'Cache-Control: no-cache' -Ls -o bump.py https://raw.githubusercontent.com/FREVA-CLINT/freva-deployment/main/release.py allowlist_externals = rm curl commands_post = rm bump.py