Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI via Hub/proxy and/or UIS #5235

Open
4 of 6 tasks
dwsutherland opened this issue Nov 21, 2022 · 2 comments
Open
4 of 6 tasks

CLI via Hub/proxy and/or UIS #5235

dwsutherland opened this issue Nov 21, 2022 · 2 comments
Assignees
Milestone

Comments

@dwsutherland
Copy link
Member

dwsutherland commented Nov 21, 2022

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
                }
            }
        ]
    }
}
@dwsutherland
Copy link
Member Author

going via the UIS:

(uiserver) sutherlander@graphic-vbox:~$ cylc ping --debug linear
2022-12-07T21:18:59+13:00 DEBUG - Loading site/user config
    files
2022-12-07T21:18:59+13:00 DEBUG - Reading file
    /home/sutherlander/.cylc/flow/8.1.0.dev/global.cylc
2022-12-07T21:18:59+13:00 DEBUG - http:send {'command':
    'graphql', 'args': {'request_string': '\nquery ($wFlows: [ID]) {\n
    workflows(ids: $wFlows) {\n    id\n    name\n    port\n    pubPort\n
    }\n}\n', 'variables': {'wFlows': ['linear/run1']}}, 'meta': {'prog': 'ping',
    'host': 'graphic-vbox', 'comms_method': 'http'}}
2022-12-07T21:18:59+13:00 DEBUG - http:recv {'data':
    {'workflows': [{'id': '~sutherlander/linear/run1', 'name': 'linear/run1',
    'port': 43072, 'pubPort': 43070}]}}
linear/run1 running on graphic-vbox:43072 43070

We man need a general communication method global config setting, all I could find is the platform one, which as far as I can tell is only for jobs:
https://cylc.github.io/cylc-doc/nightly/html/reference/config/global.html#global.cylc\[platforms\]\[%3Cplatform%20name%3E\]communication%20method

Had to $ export CYLC_TASK_COMMS_METHOD='http' to get it using HTTP UI Server client.

@oliver-sanders
Copy link
Member

Yep, but of an oversight there, we could do with the ability to configure the comms method for non-job comms anyway (e.g. if the scheduler host's Cylc ports are not open)

#5265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants