TNO Intern

Packaging v2

This version can run a tutorial. The CLI exists, but implementing the run command is outside of the scope of this PR.

Merge request reports

Loading
+0 −0

Empty file added.

src/cso/scripts/cli.py

0 → 100644
+96 −0
Changes for src/cso/scripts/cli.py: 96 added lines, 0 removed lines.
Original line number Diff line number Diff line
import subprocess
from typing import Optional

import typer
import sys
import os
import webbrowser

from cso import __package__, __version__

# import utopya

# prefix of CSO installation:
prefix = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
# extend path:
sys.path.insert(0, os.path.join(prefix, "src/cso"))
sys.path.insert(0, os.path.join(prefix, "src/utopya"))

main = typer.Typer()


def version_callback(value: bool):
    if not value:
        return
    typer.echo(f"🛰️  {__package__} {__version__}")
    raise typer.Exit()


@main.callback()
def callback(
    version: Optional[bool] = typer.Option(None, "--version", "-V", callback=version_callback),
):
    """🛰️  CAMS Satellite Operator (CSO) Command Line Interface"""

@main.command()
def run(rc_file: str = typer.Argument(..., help="Provide .rc file")):
    """Run cso based on settings provided in .rc file (e.g., cso run config/tutorial/tutorial.rc)"""
    raise NotImplementedError
    # # set environment:
    # os.environ["CSO_PREFIX"] = prefix
    # # dummy values to ensure that settings could be read first to setup logging:
    # os.environ["CSO_RCFILE"] = "None"
    # os.environ["CSO_RCDIR"] = "None"

    # # init script:
    # utos = utopya.UtopyaRunScriptRc()

    # # setup standard command line arguments, and also enable rcfile arguments:
    # utos.ArgumentsSetup(description="CAMS Satellite Operator", rcbase="cso")

    # # evaluate known arguments, store the other ;
    # # might show help text and exit:
    # args, xargs = utos.ArgumentsParse()

    # # store full path to settings:
    # os.environ["CSO_RCFILE"] = os.path.abspath(args.rcfile)
    # # location of settings file:
    # os.environ["CSO_RCDIR"] = os.path.dirname(os.path.abspath(args.rcfile))

    # # start, shout info:
    # logging.info(f"")
    # logging.info(f"** CSO - CAMS Satellite Operator **")
    # logging.info(f"")
    # logging.info(f"installation prefix  : {prefix}")
    # logging.info(f"input rcfile         : {args.rcfile}")
    # logging.info(f"settings base        : {args.rcbase}")
    # logging.info(f"")
    # logging.info(f"environment:")
    # for key in ["CSO_PREFIX", "CSO_RCFILE", "CSO_RCDIR"]:
    #     logging.info(f"  {key} = {os.environ[key]}")
    # # endfor
    # logging.info(f"")

    # # info ...
    # logging.info(f"start job tree ...")
    # # import class as defined in settings by 'cso.class' key;
    # # should be (derived from) 'utopya.JobStep' :
    # jbs_cls = utos.ImportClass("class")
    # # init job step object, use the 'rcbase' as name:
    # jbs = jbs_cls(args.rcbase, args.rcfile)
    # # start first:
    # jbs.Start(single=args.single)

    # # info:
    # logging.info(f"")
    # logging.info(f"** end **")
    # logging.info(f"")


# -------------------------------------------------
# end
# -------------------------------------------------


if __name__ == "__main__":
    main()

src/cso/__init__.py

0 → 100644
+20 −0
Changes for src/cso/__init__.py: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
from importlib import metadata

__version__ = metadata.version(__package__)

from .cso_file import *
from .cso_catalogue import *
from .cso_inquire import *

# from .cso_scihub import *
from .cso_pal import *
from .cso_s5p import *
from .cso_superobs import *
from .cso_gridded import *
from .cso_colocate import *
from .cso_superobs import *
from .cso_regions import *
from .cso_constants import *
from .cso_mapping import *
from .cso_plot import *
from .cso_dataspace import *
 No newline at end of file
+0 −0

File moved.

+7 −7
Changes for src/cso/cso_catalogue.py: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ class CSO_CatalogueBase(utopya.UtopyaRc):
        import numpy

        # tools:
        import cso_constants
        from . import cso_constants

        # no target units defined?
        if (vunits is None) or (vunits == "None"):
@@ -278,8 +278,8 @@ class CSO_Catalogue(CSO_CatalogueBase):
        import matplotlib.pyplot as plt

        # tools:
        import cso_file
        import cso_plot
        from . import cso_file
        from . import cso_plot

        # setup graphics back-end:
        matplotlib.use("Agg")
@@ -660,8 +660,8 @@ class CSO_SimCatalogue(CSO_CatalogueBase):
        import matplotlib.pyplot as plt

        # tools:
        import cso_file
        import cso_plot
        from . import cso_file
        from . import cso_plot

        # setup graphics back-end:
        matplotlib.use("Agg")
@@ -1008,8 +1008,8 @@ class CSO_GriddedCatalogue(CSO_CatalogueBase):
        import matplotlib.pyplot as plt

        # tools:
        import cso_file
        import cso_plot
        from . import cso_file
        from . import cso_plot

        # setup graphics back-end:
        matplotlib.use("Agg")
Loading
Loading