-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Milestone
Description
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:
- -
cylc-uiserver(Make API info available - CLI via Hub/proxy and/or UIS cylc-uiserver#396)- Make the API info (token, URL ...etc) available to the user (read-only).
- Create new client to send commands via the Hub/UIS using this API info.
- -
cylc-flow(Add CLI http comms method #5267)- Add http comms method and global configuration.
- Import UI Server client (require UIS to be installed).
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