ODA Command Line Interface (CLI)

The ODA Command Line Interface package provides the user with a simple interface for accessing and querying different entities stored in the ODA.

Currently supported entity types (followed by the CLI abbreviation) are:

  • Scheduling Block Definitions (sbds)

  • Scheduling Block Instances (sbis)

  • Execution Blocks (ebs)

  • Projects (prjs)

Configuration

ODA CLI is installed as part of the ska-db-oda package:

$ pip install ska-db-oda --extra-index-url=https://artefact.skao.int/repository/pypi-internal/simple

The CLI assumes ODA server is running at the address specified by ODA_URI environment variable. Set the variable, for example when deployed locally with k8s:

$ export ODA_URI=http://<minikube_ip>/<kube_namespace>/api/v1

To ensure the CLI is available, and for more help, run oda --help.

The typical use pattern is then as below, and specific examples can be seen in the following sections.

$ oda <entity abbreviation> <command> <parameters>

Commands

ODA CLI command

Parameters

Description

get

entity_id

Get entity by ID, first specifying entity type. Example: oda sbis get sbi-mvp01-20200325-00001

query

Query ODA for entity IDs. The query can be one of the following:

user

User query: Specify a name of the creator of the entity, set starts_with to True if only wanting to match the beginning of the user (False by default).

starts_with

created_before

Date created query: Specify a start and/or end date for when the entity was first created

created_after

last_modified_before

Date modified query: Specify a start and/or end date for when the entity was last modified.

last_modified_after

Examples

A typical use case would be to query for entities created in a certain time window or by a certain user, then to retrieve the full entity.

For example, to query all ExecutionBlocks created on a certain day

$ oda ebs query --created_after='2023-10-18 00:00' --created_before='2023-10-18 23:59'

   Query Parameters
   ---------------
   query_type = QueryType.CREATED_BETWEEN
   start = 2023-10-18 00:00:00
   end = 2023-10-18 23:59:00

   Result
   -------
   eb-t0001-20231018-00003
   eb-t0001-20231018-00004
   eb-t0001-20231018-00005
   eb-t0001-20231018-00002

Then fetch the full ExecutionBlock for one of the IDs.

$ oda ebs get eb-t0001-20231018-00004

   {
       "interface": "https://schema.skao.int/ska-oso-pdm-eb/0.1",
       "eb_id": "eb-t0001-20231018-00004",
       "metadata": {
           "version": 1,
           "created_by": "DefaultUser",
           "created_on": "2023-10-18T08:36:46.710630+00:00",
           "last_modified_by": "DefaultUser",
           "last_modified_on": "2023-10-18T08:36:46.710630+00:00"
       },
       "telescope": "ska_mid",
       "sbd_ref": "sbd-mvp01-20220923-00001",
       "sbd_version": 1,
       "sbi_ref": "sbi-mvp01-20220923-00001",
       "request_responses": [
           {
             "request": "ska_oso_scripting.functions.devicecontrol.release_all_resources",
             "request_args": "{'args': None, 'kwargs': {'subarray_id': '1'}}",
             "status": "OK",
             "response": {
               "result": "this is a result"
             },
             "request_sent_at": "2022-09-23T15:43:53.971548+00:00",
             "response_received_at": "2022-09-23T15:43:53.971548+00:00"
           },
           {
             "request": "ska_oso_scripting.functions.devicecontrol.scan",
             "status": "ERROR",
             "error": {
               "detail": "this is an error"
             },
             "request_sent_at": "2022-09-23T15:43:53.971548+00:00"
           }
         ]
   }

Another example, to query SBInstances by user

$ oda sbis query --user='Default' --starts-with

    Query Parameters
    ---------------
    user = DefaultUser
    match_type = MatchType.STARTS_WITH

    Result
    -------
    sbi-t0001-20231018-00006
    sbi-t0001-20231018-00001