|
12 | 12 | from one.alf.spec import is_uuid_string |
13 | 13 | from one import params |
14 | 14 | from one.converters import path_from_dataset |
| 15 | +from one.remote import globus |
15 | 16 |
|
16 | | -from ibllib.io import globus |
17 | 17 | from ibllib.oneibl.registration import register_dataset |
18 | 18 |
|
19 | 19 | _logger = logging.getLogger('ibllib') |
@@ -97,7 +97,7 @@ def _patch_dataset(self, path, dset_id=None, dry=False, ftp=False): |
97 | 97 | full_remote_path = PurePosixPath(FLATIRON_MOUNT, remote_path) |
98 | 98 | if isinstance(path, WindowsPath) and not ftp: |
99 | 99 | # On Windows replace drive map with Globus uri, e.g. C:/ -> /~/C/ |
100 | | - path = '/~/' + path.as_posix().replace(':', '') |
| 100 | + path = globus.as_globus_path(path) |
101 | 101 | status = self._scp(path, full_remote_path, dry=dry)[0] |
102 | 102 | return status |
103 | 103 |
|
@@ -140,8 +140,8 @@ def patch_dataset(self, file_list, dry=False, ftp=False, **kwargs): |
140 | 140 | Rules for creation/patching are the same that apply for registration via Alyx |
141 | 141 | as this uses the registration endpoint to get the dataset. |
142 | 142 | An existing file (same session and path relative to session) will be patched. |
143 | | - :param path: full file path. Must be whithin an ALF session folder (subject/date/number) |
144 | | - can also be a list of full file pathes belonging to the same session. |
| 143 | + :param path: full file path. Must be within an ALF session folder (subject/date/number) |
| 144 | + can also be a list of full file paths belonging to the same session. |
145 | 145 | :param server_repository: Alyx server repository name |
146 | 146 | :param created_by: alyx username for the dataset (optional, defaults to root) |
147 | 147 | :param ftp: flag for case when using ftppatcher. Don't adjust windows path in |
@@ -197,13 +197,12 @@ class GlobusPatcher(Patcher): |
197 | 197 |
|
198 | 198 | """ |
199 | 199 |
|
200 | | - def __init__(self, one=None, globus_client_id=None, local_endpoint=None, label='ibllib patch'): |
201 | | - assert globus_client_id |
| 200 | + def __init__(self, client_name='default', one=None, label='ibllib patch'): |
202 | 201 | assert one |
203 | | - self.local_endpoint = local_endpoint or globus.get_local_endpoint() |
| 202 | + self.local_endpoint = getattr(globus.load_client_params(f'globus.{client_name}'), |
| 203 | + 'local_endpoint', globus.get_local_endpoint_id()) |
| 204 | + self.transfer_client = globus.create_globus_client(client_name) |
204 | 205 | self.label = label |
205 | | - self.transfer_client = globus.login_auto( |
206 | | - globus_client_id=globus_client_id, str_app='globus/admin') |
207 | 206 | # transfers/delete from the current computer to the flatiron: mandatory and executed first |
208 | 207 | self.globus_transfer = globus_sdk.TransferData( |
209 | 208 | self.transfer_client, self.local_endpoint, FLAT_IRON_GLOBUS_ID, verify_checksum=True, |
@@ -296,11 +295,11 @@ def _wait_for_task(resp): |
296 | 295 | # on an errored task |
297 | 296 | # Out[10]: TransferResponse({'bytes_checksummed': 0, 'bytes_transferred': 0, 'canceled_by_admin': None, 'canceled_by_admin_message': None, 'command': 'API 0.10', 'completion_time': '2021-01-03T17:39:00+00:00', 'deadline': '2021-01-04T17:37:34+00:00', 'delete_destination_extra': False, 'destination_endpoint': 'simonsfoundation#ibl', 'destination_endpoint_display_name': 'IBL Flatiron SDSC Data', 'destination_endpoint_id': 'ab2d064c-413d-11eb-b188-0ee0d5d9299f', 'directories': 0, 'effective_bytes_per_second': 0, 'encrypt_data': False, 'fatal_error': {'code': 'CANCELED', 'description': 'canceled'}, 'faults': 2, 'files': 6, 'files_skipped': 0, 'files_transferred': 0, 'history_deleted': False, 'is_ok': None, 'is_paused': False, 'key': 'complete,2021-01-03T17:38:59.697413', 'label': 'test 3B analog sync patch', 'nice_status': None, 'nice_status_details': None, 'nice_status_expires_in': None, 'nice_status_short_description': None, 'owner_id': 'e633663a-8561-4a5d-ac92-f198d43b14dc', 'preserve_timestamp': False, 'recursive_symlinks': 'ignore', 'request_time': '2021-01-03T17:37:34+00:00', 'source_endpoint': 'internationalbrainlab#916c2766-bd2a-11ea-8f22-0a21f750d19b', 'source_endpoint_display_name': 'olivier_laptop', 'source_endpoint_id': '916c2766-bd2a-11ea-8f22-0a21f750d19b', 'status': 'FAILED', 'subtasks_canceled': 6, 'subtasks_expired': 0, 'subtasks_failed': 0, 'subtasks_pending': 0, 'subtasks_retrying': 0, 'subtasks_succeeded': 6, 'subtasks_total': 12, 'symlinks': 0, 'sync_level': 3, 'task_id': '5706dd2c-4dea-11eb-8ffb-0a34088e79f9', 'type': 'TRANSFER', 'username': 'internationalbrainlab', 'verify_checksum': True}) # noqa |
298 | 297 | while True: |
299 | | - tinfo = gtc.get_task(task_id=resp['task_id'])['completion_time'] |
300 | | - if tinfo['completion_time'] is not None: |
| 298 | + tinfo = gtc.get_task(task_id=resp['task_id']) |
| 299 | + if tinfo and tinfo['completion_time'] is not None: |
301 | 300 | break |
302 | 301 | _ = gtc.task_wait(task_id=resp['task_id'], timeout=30) |
303 | | - if tinfo['fatal_error'] is not None: |
| 302 | + if tinfo and tinfo['fatal_error'] is not None: |
304 | 303 | raise ConnectionError(f"Globus transfer failed \n {tinfo}") |
305 | 304 |
|
306 | 305 | # handles the transfers first |
|
0 commit comments