Skip to content

Commit 5df29a8

Browse files
authored
MRG: Merge pull request #734 from octue/switch-to-octue-twined-cli
Switch to octue twined CLI
2 parents 51c6d8f + 647eae0 commit 5df29a8

10 files changed

+448
-242
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
exclude: "build|.git/|.tox|dist|octue.egg-info"
22
default_stages: [commit]
3-
fail_fast: true
3+
fail_fast: false
44
default_language_version:
55
python: python3 # force all unspecified python hooks to run python3
66
repos:

docs/source/creating_services.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ See :ref:`here <service_naming>` for service naming requirements.
126126
- Set in:
127127

128128
- ``OCTUE_SERVICE_REVISION_TAG`` environment variable
129-
- If using ``octue start`` command, the ``--revision-tag`` option (takes priority)
129+
- If using ``octue twined start`` command, the ``--revision-tag`` option (takes priority)
130130

131131

132132
Template apps

docs/source/inter_service_compatibility.rst

Lines changed: 115 additions & 111 deletions
Large diffs are not rendered by default.

docs/source/running_services_locally.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Via the CLI
2424

2525
.. code-block:: shell
2626
27-
octue question ask local --input-values='{"some": "input"}'
27+
octue twined question ask local --input-values='{"some": "input"}'
2828
2929
The output values and/or manifest will be printed to ``stdout`` but are also stored in the event store.
3030

@@ -61,7 +61,7 @@ Via the CLI
6161

6262
.. code-block:: shell
6363
64-
octue start
64+
octue twined start
6565
6666
This will run the service as a child waiting for questions until you press ``Ctrl + C`` or an error is encountered. The
6767
service will be available to be questioned by other services at the service ID ``organisation/name`` as specified in

docs/source/troubleshooting_services.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ message. A user with credentials to access this path can use the ``octue`` CLI t
2727

2828
.. code-block:: shell
2929
30-
octue question diagnostics <cloud-path>
30+
octue twined question diagnostics <cloud-path>
3131
3232
More information on the command:
3333

3434
.. code-block::
3535
36-
>>> octue question diagnostics -h
36+
>>> octue twined question diagnostics -h
3737
38-
Usage: octue question diagnostics [OPTIONS] CLOUD_PATH
38+
Usage: octue twined question diagnostics [OPTIONS] CLOUD_PATH
3939
4040
Download diagnostics for an analysis from the given directory in
4141
Google Cloud Storage. The cloud path should end in the analysis ID.

octue/cli.py

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
from octue.cloud import storage
1212
from octue.cloud.events.answer_question import answer_question
13-
from octue.cloud.events.replayer import EventReplayer
1413
from octue.cloud.events.question import make_question_event
14+
from octue.cloud.events.replayer import EventReplayer
1515
from octue.cloud.events.validation import VALID_EVENT_KINDS
16-
from octue.cloud.pub_sub.bigquery import get_events, DEFAULT_EVENT_STORE_TABLE_ID
16+
from octue.cloud.pub_sub.bigquery import DEFAULT_EVENT_STORE_TABLE_ID, get_events
1717
from octue.cloud.pub_sub.service import Service
1818
from octue.cloud.service_id import create_sruid, get_sruid_parts
1919
from octue.cloud.storage import GoogleCloudStorageClient
@@ -32,13 +32,6 @@
3232

3333

3434
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
35-
@click.option(
36-
"--id",
37-
default=None,
38-
type=click.UUID,
39-
show_default=True,
40-
help="UUID of the analysis being undertaken. None (for local use) will cause a unique ID to be generated.",
41-
)
4235
@click.option("--logger-uri", default=None, show_default=True, help="Stream logs to a websocket at the given URI.")
4336
@click.option(
4437
"--log-level",
@@ -47,25 +40,15 @@
4740
show_default=True,
4841
help="Log level used for the analysis.",
4942
)
50-
@click.option(
51-
"--force-reset/--no-force-reset",
52-
default=True,
53-
is_flag=True,
54-
show_default=True,
55-
help="Forces a reset of analysis cache and outputs [For future use, currently not implemented]",
56-
)
5743
@click.version_option(version=LOCAL_SDK_VERSION)
58-
def octue_cli(id, logger_uri, log_level, force_reset):
59-
"""The CLI for the Octue SDK. Use it to start an Octue data service or digital twin locally or run an analysis on
60-
one locally.
44+
def octue_cli(logger_uri, log_level):
45+
"""The CLI for Octue SDKs and APIs, most notably Twined.
6146
6247
Read more in the docs: https://octue-python-sdk.readthedocs.io/en/latest/
6348
"""
64-
global_cli_context["analysis_id"] = id
6549
global_cli_context["logger_uri"] = logger_uri
6650
global_cli_context["log_handler"] = None
6751
global_cli_context["log_level"] = log_level.upper()
68-
global_cli_context["force_reset"] = force_reset
6952

7053
apply_log_handler(log_level=log_level.upper())
7154

@@ -74,6 +57,12 @@ def octue_cli(id, logger_uri, log_level, force_reset):
7457

7558

7659
@octue_cli.group()
60+
def twined():
61+
"""The Twined CLI. Use it to ask questions to or start a Twined data service in the cloud or locally."""
62+
pass
63+
64+
65+
@twined.group()
7766
def question():
7867
"""Ask a new question to an Octue Twined data service or interact with a previous question."""
7968

@@ -322,7 +311,7 @@ def get(
322311
limit,
323312
service_config,
324313
):
325-
"""Get the events emitted during a question as JSON. One of the following must be set:
314+
r"""Get the events emitted during a question as JSON. One of the following must be set:
326315
327316
--question-uuid\n
328317
--parent-question-uuid\n
@@ -434,7 +423,7 @@ def replay(
434423
exclude_logs_containing,
435424
validate_events,
436425
):
437-
"""Replay a question's events, returning the result as JSON at the end if there is one. One of the following must be
426+
r"""Replay a question's events, returning the result as JSON at the end if there is one. One of the following must be
438427
set:
439428
440429
--question-uuid\n
@@ -584,29 +573,7 @@ def diagnostics(cloud_path, local_path, download_datasets):
584573
# child.cancel(question_uuid=question_uuid, event_store_table_id=service_configuration.event_store_table_id)
585574

586575

587-
@octue_cli.command(deprecated=True)
588-
@click.argument(
589-
"cloud_path",
590-
type=str,
591-
)
592-
@click.option(
593-
"--local-path",
594-
type=click.Path(file_okay=False),
595-
default=".",
596-
help="The path to a directory to store the directory of diagnostics data in. Defaults to the current working "
597-
"directory.",
598-
)
599-
@click.option(
600-
"--download-datasets",
601-
is_flag=True,
602-
help="If provided, download any datasets from the diagnostics and update their paths in the configuration and "
603-
"input manifests to the new local paths.",
604-
)
605-
def get_diagnostics(cloud_path, local_path, download_datasets):
606-
diagnostics(cloud_path, local_path, download_datasets)
607-
608-
609-
@octue_cli.command()
576+
@twined.command()
610577
@click.option(
611578
"-c",
612579
"--service-config",

0 commit comments

Comments
 (0)