2020ZSTASH_CLIENT_ID : str = "6c1629cf-446c-49e7-af95-323c6412397f"
2121
2222HPSS_ENDPOINT_MAP : Dict [str , str ] = {
23- # "ALCF": "de463ec4-6d04-11e5-ba46-22000b92c6ec",
23+ "ALCF" : "de463ec4-6d04-11e5-ba46-22000b92c6ec" ,
2424 "NERSC" : "9cd89cfd-6d04-11e5-ba46-22000b92c6ec" ,
2525}
2626
2727# This is used if the `globus_endpoint_uuid` is not set in `~/.zstash.ini`
2828REGEX_ENDPOINT_MAP : Dict [str , str ] = {
29- # r"theta.*\.alcf\.anl\.gov": "08925f04-569f-11e7-bef8-22000b9a448b",
29+ r"theta.*\.alcf\.anl\.gov" : "08925f04-569f-11e7-bef8-22000b9a448b" ,
3030 r"blueslogin.*\.lcrc\.anl\.gov" : "15288284-7006-4041-ba1a-6b52501e49f1" ,
3131 r"chrlogin.*\.lcrc\.anl\.gov" : "15288284-7006-4041-ba1a-6b52501e49f1" ,
3232 r"b\d+\.lcrc\.anl\.gov" : "15288284-7006-4041-ba1a-6b52501e49f1" ,
@@ -57,6 +57,8 @@ def ep_to_name(endpoint_id: str) -> str:
5757
5858
5959def log_current_endpoints (globus_info : GlobusInfo ):
60+ local : str
61+ remote : str
6062 if globus_info .local_endpoint :
6163 local = ep_to_name (globus_info .local_endpoint )
6264 else :
@@ -86,17 +88,21 @@ def set_clients(globus_info: GlobusInfo):
8688 logger .debug (
8789 "set_clients. Calling login, which may print 'Please Paste your Auth Code Below:'"
8890 )
89- all_scopes : str = get_all_endpoint_scopes (
90- list (HPSS_ENDPOINT_MAP .values ()) + list (REGEX_ENDPOINT_MAP .values ())
91- )
92- native_client .login (
93- requested_scopes = all_scopes , no_local_server = True , refresh_tokens = True
94- )
91+ if globus_info .local_endpoint and globus_info .remote_endpoint :
92+ all_scopes : str = get_all_endpoint_scopes (
93+ [globus_info .local_endpoint , globus_info .remote_endpoint ]
94+ )
95+ native_client .login (
96+ requested_scopes = all_scopes , no_local_server = True , refresh_tokens = True
97+ )
98+ else :
99+ native_client .login (no_local_server = True , refresh_tokens = True )
95100 transfer_authorizer = native_client .get_authorizers ().get ("transfer.api.globus.org" )
96101 globus_info .transfer_client = TransferClient (authorizer = transfer_authorizer )
97102
98103
99- def check_endpoint_version_5 (globus_info : GlobusInfo , ep_id ):
104+ # Used exclusively by check_consents
105+ def check_endpoint_version_5 (globus_info : GlobusInfo , ep_id : str ) -> bool :
100106 if not globus_info .transfer_client :
101107 raise ValueError ("transfer_client is undefined" )
102108 log_current_endpoints (globus_info )
@@ -110,10 +116,13 @@ def check_endpoint_version_5(globus_info: GlobusInfo, ep_id):
110116 return False
111117
112118
119+ # Used exclusively by submit_transfer_with_checks, exclusively when there is a TransferAPIError
120+ # This function is really to diagnose an error: are the consents ok?
121+ # That is, we don't *need* to check consents or endpoint versions if everything worked out fine.
113122def check_consents (globus_info : GlobusInfo ):
114123 scopes = "urn:globus:auth:scope:transfer.api.globus.org:all["
115124 for ep_id in [globus_info .remote_endpoint , globus_info .local_endpoint ]:
116- if check_endpoint_version_5 (globus_info , ep_id ):
125+ if ep_id and check_endpoint_version_5 (globus_info , ep_id ):
117126 scopes += f" *https://auth.globus.org/scopes/{ ep_id } /data_access"
118127 scopes += " ]"
119128 native_client = NativeClient (client_id = ZSTASH_CLIENT_ID , app_name = "Zstash" )
0 commit comments