1010
1111from octue .cloud import storage
1212from octue .cloud .events .answer_question import answer_question
13- from octue .cloud .events .replayer import EventReplayer
1413from octue .cloud .events .question import make_question_event
14+ from octue .cloud .events .replayer import EventReplayer
1515from 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
1717from octue .cloud .pub_sub .service import Service
1818from octue .cloud .service_id import create_sruid , get_sruid_parts
1919from octue .cloud .storage import GoogleCloudStorageClient
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" ,
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 ()
7766def 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