Skip to content

CLI via Hub/proxy and/or UIS #5235

@dwsutherland

Description

@dwsutherland

Long awaited, and relates to:
#2123
#3005
#3528
#4742

The hub started UIS negotiates an API authentication token that can be used via the hub proxy or directly with the UIS, and in the absence of the hub (cylc gui) the UIS generates it's own token.

The scheduler currently has two comms methods tcp and ssh, and now that the client has been abstracted somewhat (#4742), we could add an http option/client that picks up the API token. All the CLI GraphQL queries/mutations should work as is.

Tasks:

Sample
(from the UIS task)

#!/usr/bin/env python3

import json
import requests

from cylc.uiserver.app import API_INFO_FILE

f = open(API_INFO_FILE, "r")
api_info = json.loads(f.read())
f.close()

query = '''
query {
  workflows {
    id
    stateTotals
  }
}
'''

r = requests.post(api_info["url"] + 'cylc/graphql',
    headers={
        'Authorization': f'token {api_info["token"]}',
    },
    json={'query': query}
)


r.raise_for_status()
data = r.json()

print(json.dumps(data, indent=4))

$ ./uis_api.py
{
    "data": {
        "workflows": [
            {
                "id": "~sutherlander/linear/run1",
                "stateTotals": {
                    "waiting": 2,
                    "expired": 0,
                    "preparing": 0,
                    "submit-failed": 1,
                    "submitted": 0,
                    "running": 0,
                    "failed": 0,
                    "succeeded": 0
                }
            }
        ]
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions