From 3569738c86bc763f2cb00d6f38a9f28349b7959d Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Fri, 27 Sep 2024 18:07:24 +0200 Subject: [PATCH] cli --- diracx-cli/src/diracx/cli/__init__.py | 1 - extensions/README.md | 9 ++++ extensions/gubbins/gubbins-cli/pyproject.toml | 52 +++++++++++++++++++ .../gubbins/gubbins-cli/src/cli/__init__.py | 0 .../gubbins/gubbins-cli/src/cli/lollygag.py | 8 +++ extensions/gubbins/requirements-dev.txt | 1 + 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 extensions/gubbins/gubbins-cli/pyproject.toml create mode 100644 extensions/gubbins/gubbins-cli/src/cli/__init__.py create mode 100644 extensions/gubbins/gubbins-cli/src/cli/lollygag.py diff --git a/diracx-cli/src/diracx/cli/__init__.py b/diracx-cli/src/diracx/cli/__init__.py index 1251576e..ee0f146c 100644 --- a/diracx-cli/src/diracx/cli/__init__.py +++ b/diracx-cli/src/diracx/cli/__init__.py @@ -116,7 +116,6 @@ def callback(output_format: Optional[str] = None): # Load all the sub commands - for entry_point in select_from_extension(group="diracx.cli"): app.add_typer(entry_point.load(), name=entry_point.name) diff --git a/extensions/README.md b/extensions/README.md index 358d2c1b..04bb5129 100644 --- a/extensions/README.md +++ b/extensions/README.md @@ -20,6 +20,8 @@ What to do with the `environment.yaml` ? should we replicate wht's in diracx ? When working with the extension, you MUST always (server, client, testing) have exported the environment variable ``DIRACX_EXTENSIONS=gubbins,diracx`` +In the pyproject, the ``root`` of ``setuptools_scm`` will only be ``..`` for your extension + ## CI What is under ``.github/workflows/extensions.yaml`` should in fact be split in multiple jobs under ``.github/workflows/`` of your repo @@ -87,6 +89,13 @@ aio_client_class = "gubbins.client.generated.aio._client:Dirac" * Generate the autorest client (see ci ``regenerate_client``) +## CLI + +* add a new subcommand +* extend an existing subcommand +* modify an existing subcommand +* no ``gubbins`` CI, everythign through ``dirac`` cli + ## Writing tests diff --git a/extensions/gubbins/gubbins-cli/pyproject.toml b/extensions/gubbins/gubbins-cli/pyproject.toml new file mode 100644 index 00000000..4b011df3 --- /dev/null +++ b/extensions/gubbins/gubbins-cli/pyproject.toml @@ -0,0 +1,52 @@ +[project] +name = "gubbins-cli" +description = "TODO" +readme = "README.md" +requires-python = ">=3.11" +keywords = [] +license = {text = "GPL-3.0-only"} +classifiers = [ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", + "Topic :: System :: Distributed Computing", +] +dependencies = ["diracx-cli"] +dynamic = ["version"] + +[project.optional-dependencies] +testing = ["diracx-cli[testing]", "diracx-testing"] +types = [ + "types-PyYAML", +] + +# [project.scripts] +# dirac = "gubbins.cli:app" + +[project.entry-points."diracx.cli"] +lollygag = "gubbins.cli.lollygag:app" + + +[tool.setuptools.packages.find] +where = ["src"] + +[build-system] +requires = ["setuptools>=61", "wheel", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +root = "../../.." + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = [ + "-v", + "--cov=diracx.cli", "--cov-report=term-missing", + "-pdiracx.testing", + "--import-mode=importlib", +] +asyncio_mode = "auto" +markers = [ + "enabled_dependencies: List of dependencies which should be available to the FastAPI test client", +] diff --git a/extensions/gubbins/gubbins-cli/src/cli/__init__.py b/extensions/gubbins/gubbins-cli/src/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/extensions/gubbins/gubbins-cli/src/cli/lollygag.py b/extensions/gubbins/gubbins-cli/src/cli/lollygag.py new file mode 100644 index 00000000..b4779ed2 --- /dev/null +++ b/extensions/gubbins/gubbins-cli/src/cli/lollygag.py @@ -0,0 +1,8 @@ +from diracx.cli.utils import AsyncTyper + +app = AsyncTyper() + + +@app.command() +def boom(): + print("yes baby") diff --git a/extensions/gubbins/requirements-dev.txt b/extensions/gubbins/requirements-dev.txt index 10d1f54c..f0535999 100644 --- a/extensions/gubbins/requirements-dev.txt +++ b/extensions/gubbins/requirements-dev.txt @@ -2,3 +2,4 @@ -e ./gubbins-db/[testing] -e ./gubbins-testing/[testing] -e ./gubbins-client/[testing] +-e ./gubbins-cli/[testing]