Exemplo n.º 1
0
 def __init__(self,
              one=None,
              globus_client_id=None,
              local_endpoint=None,
              label='ibllib patch'):
     assert globus_client_id
     assert one
     self.local_endpoint = local_endpoint or globus.get_local_endpoint()
     self.label = label
     self.transfer_client = globus.login_auto(
         globus_client_id=globus_client_id, str_app='globus/admin')
     # transfers/delete from the current computer to the flatiron: mandatory and executed first
     self.globus_transfer = globus_sdk.TransferData(self.transfer_client,
                                                    self.local_endpoint,
                                                    FLAT_IRON_GLOBUS_ID,
                                                    verify_checksum=True,
                                                    sync_level='checksum',
                                                    label=label)
     self.globus_delete = globus_sdk.DeleteData(self.transfer_client,
                                                FLAT_IRON_GLOBUS_ID,
                                                verify_checksum=True,
                                                sync_level='checksum',
                                                label=label)
     # get a dictionary of data repositories from Alyx (with globus ids)
     self.repos = {
         r['name']: r
         for r in one.alyx.rest('data-repository', 'list')
     }
     # transfers/delete from flatiron to optional third parties to synchronize / delete
     self.globus_transfers_locals = {}
     self.globus_deletes_locals = {}
     super().__init__(one=one)
Exemplo n.º 2
0
    def test_login_auto(self, mock_params):
        client_id = 'h3u2i'
        # Test ValueError thrown with incorrect parameters
        mock_params.return_value = None  # No parameters saved
        with self.assertRaises(ValueError):
            globus.login_auto(client_id)
        mock_params.assert_called_with('globus/default')

        pars = params.from_dict({'access_token': '7r3hj89', 'expires_at_seconds': '2020-09-10'})
        mock_params.return_value = pars  # Incomplete parameter object
        with self.assertRaises(ValueError):
            globus.login_auto(client_id)

        # Complete parameter object
        mock_params.return_value = pars.set('refresh_token', '37yh4')
        gtc = globus.login_auto(client_id)
        self.assertIsInstance(gtc, unittest.mock.Mock)
        mock, _ = self.patcher.get_original()
        mock.assert_called_once_with(client_id)
Exemplo n.º 3
0
LOCAL_REPO = p.local_endpoint  # Endpoint UUID from Website
SERVER_ID = p.remote_endpoint  # FlatIron
DST_DIR = params.read('ibl_ci', {'data_root': '.'}).data_root
GLOBUS_CLIENT_ID = oneibl.params.get().GLOBUS_CLIENT_ID
# Constants
SRC_DIR = '/integration'
POLL = (5, 60*60)  # min max seconds between pinging server
TIMEOUT = 24*60*60  # seconds before timeout
status_map = {
    'ACTIVE': ('QUEUED', 'ACTIVE'),
    'FAILED': ('ENDPOINT_ERROR', 'PERMISSION_DENIED', 'CONNECT_FAILED'),
    'INACTIVE': 'PAUSED_BY_ADMIN'
}

try:
    gtc = globus.login_auto(GLOBUS_CLIENT_ID, str_app='globus/admin')
except ValueError:
    logger.info('User authentication required...')
    globus.setup(GLOBUS_CLIENT_ID)
    gtc = globus.login_auto(GLOBUS_CLIENT_ID)

# Check path exists
try:
    gtc.operation_ls(SERVER_ID, path=SRC_DIR)
except TransferAPIError as ex:
    logger.error(f'Failed to query source endpoint path {SRC_DIR}')
    raise ex

# Create the destination path if it does not exist
dst_directory = as_globus_path(DST_DIR)
Exemplo n.º 4
0
LOCAL_REPO = p.local_endpoint  # Endpoint UUID from Website
SERVER_ID = p.remote_endpoint  # FlatIron
GLOBUS_CLIENT_ID = p.GLOBUS_CLIENT_ID
DST_DIR = params.read('ibl_ci', {'data_root': '.'}).data_root
# Constants
SRC_DIR = '/integration'
POLL = (5, 60 * 60)  # min max seconds between pinging server
TIMEOUT = 24 * 60 * 60  # seconds before timeout
status_map = {
    'ACTIVE': ('QUEUED', 'ACTIVE'),
    'FAILED': ('ENDPOINT_ERROR', 'PERMISSION_DENIED', 'CONNECT_FAILED'),
    'INACTIVE': 'PAUSED_BY_ADMIN'
}

try:
    gtc = globus.login_auto(GLOBUS_CLIENT_ID)
except ValueError:
    logger.info('User authentication required...')
    globus.setup(GLOBUS_CLIENT_ID)
    gtc = globus.login_auto(GLOBUS_CLIENT_ID)

# Check path exists
try:
    gtc.operation_ls(SERVER_ID, path=SRC_DIR)
except TransferAPIError as ex:
    logger.error(f'Failed to query source endpoint path {SRC_DIR}')
    raise ex

# Create the destination path if it does not exist
dst_directory = as_globus_path(DST_DIR)
Exemplo n.º 5
0
 def __init__(self, **kwargs):
     # Init connection to the database
     super(OneGlobus, self).__init__(**kwargs)
     # Init connection to Globus if needed
     self._tc = globus.login_auto(par.GLOBUS['CLIENT_ID'], str_app='globus_one')
Exemplo n.º 6
0
 def setup(self):
     super(OneGlobus, self).setup()
     globus.login_auto(par.GLOBUS['CLIENT_ID'], str_app='globus_one')