Python API

The educelab.globus package exposes a small Python API for use from scripts and pipelines.

from educelab.globus import login, endpoints, get_endpoint

# Inspect the configuration
for name, ep in endpoints().items():
    print(name, ep['uuid'])

# Log in and get an authorized TransferClient
ep = get_endpoint('lab-server')
tc = login([ep['uuid']])
for item in tc.operation_ls(ep['uuid']):
    print(item['name'])

educelab.globus

EduceLab Globus: configuration and helpers for Globus endpoint transfers.

educelab.globus.endpoint_names()[source]

Return the list of configured endpoint names.

Return type:

List[str]

educelab.globus.endpoint_uuids()[source]

Return the list of UUIDs for all configured endpoints.

Return type:

List[str]

educelab.globus.endpoints()[source]

Return all configured endpoints keyed by name.

Each value is a dict containing at least uuid and optionally basedir. An empty dict is returned if no config file exists.

Return type:

Dict

educelab.globus.get_endpoint(key)[source]

Return the config entry for the named endpoint, or None if missing.

Parameters:

key (str) – The endpoint name as it appears in the config file.

Returns:

A dict with at least a uuid key (and optionally basedir), or None if no endpoint with that name is configured.

Return type:

dict or None

educelab.globus.login(endpoint_uuids, force=False, ignore_offline=False, browser=True)[source]

Log into Globus and return a TransferClient authorized for the given endpoints.

Acquires (or refreshes) tokens, prompts for any required consents or session credentials (re-running the auth flow up to five times), and verifies that each endpoint is reachable via operation_ls.

Parameters:
  • endpoint_uuids (iterable of str) – UUIDs of the Globus endpoints to authorize.

  • force (bool, optional) – Force a new login even if cached tokens are valid. Default False.

  • ignore_offline (bool, optional) – Treat offline (GCDisconnected) endpoints as non-fatal. Default False.

  • browser (bool, optional) – Use the local-server (browser) login flow. Automatically disabled on remote/SSH sessions. Default True.

Returns:

An authorized transfer client.

Return type:

globus_sdk.TransferClient

Raises:

RuntimeError – If any endpoint could not be authorized after the retry budget is exhausted (e.g. user did not satisfy a session requirement).

educelab.globus.config

educelab.globus.config.edit_mode()[source]

Interactive CLI menu for editing the Globus endpoint config.

Return type:

None

educelab.globus.config.endpoint_names()[source]

Return the list of configured endpoint names.

Return type:

List[str]

educelab.globus.config.endpoint_uuids()[source]

Return the list of UUIDs for all configured endpoints.

Return type:

List[str]

educelab.globus.config.endpoints()[source]

Return all configured endpoints keyed by name.

Each value is a dict containing at least uuid and optionally basedir. An empty dict is returned if no config file exists.

Return type:

Dict

educelab.globus.config.get_endpoint(key)[source]

Return the config entry for the named endpoint, or None if missing.

Parameters:

key (str) – The endpoint name as it appears in the config file.

Returns:

A dict with at least a uuid key (and optionally basedir), or None if no endpoint with that name is configured.

Return type:

dict or None

educelab.globus.config.has_config()[source]

Return True if the user has a config file at ~/.globuscp/config.toml.

Return type:

bool

educelab.globus.config.main()[source]

educelab.globus.login

educelab.globus.login.login(endpoint_uuids, force=False, ignore_offline=False, browser=True)[source]

Log into Globus and return a TransferClient authorized for the given endpoints.

Acquires (or refreshes) tokens, prompts for any required consents or session credentials (re-running the auth flow up to five times), and verifies that each endpoint is reachable via operation_ls.

Parameters:
  • endpoint_uuids (iterable of str) – UUIDs of the Globus endpoints to authorize.

  • force (bool, optional) – Force a new login even if cached tokens are valid. Default False.

  • ignore_offline (bool, optional) – Treat offline (GCDisconnected) endpoints as non-fatal. Default False.

  • browser (bool, optional) – Use the local-server (browser) login flow. Automatically disabled on remote/SSH sessions. Default True.

Returns:

An authorized transfer client.

Return type:

globus_sdk.TransferClient

Raises:

RuntimeError – If any endpoint could not be authorized after the retry budget is exhausted (e.g. user did not satisfy a session requirement).

educelab.globus.login.main()[source]
educelab.globus.login.test_endpoints(tc, endpoint_uuids, ignore_offline=False)[source]

Test that the provided endpoints are accessible for transfers.

educelab.globus.cp.main

educelab.globus.cp.main.main()[source]
educelab.globus.cp.main.resolve_path(endpoint, path_str)[source]

Resolve a user-supplied path string against the endpoint’s basedir.

educelab.globus.cp.main.to_posix_path(path)[source]