Exemple #1
0
 def add_file(self, file):
     if file.scheme == 'globus':
         if not self.globus:
             self.globus = get_globus()
         # keep a list of all remote files for optimization purposes (TODO)
         self.files.append(file)
         self._set_local_path(file)
Exemple #2
0
 def initialize_globus(self):
     if self.globus is None:
         self.globus = get_globus()
Exemple #3
0
    def __init__(
        self,
        name: str,
        *,
        endpoints: GlobusEndpoints
        | list[GlobusEndpoint]
        | dict[str, dict[str, str]],
        polling_interval: int = 1,
        sync_level: int | str = "mtime",
        timeout: int = 60,
        cache_size: int = 16,
    ) -> None:
        """Init GlobusStore.

        Args:
            name (str): name of the store instance.
            endpoints (GlobusEndpoints): Globus endpoints to keep
                in sync. If passed as a `dict`, the dictionary must match the
                format expected by :func:`GlobusEndpoints.from_dict()`.
            polling_interval (int): interval in seconds to check if Globus
                tasks have finished.
            sync_level (str, int): Globus transfer sync level.
            timeout (int): timeout in seconds for waiting on Globus tasks.
            cache_size (int): size of local cache (in # of objects). If 0,
                the cache is disabled (default: 16).

        Raise:
            ImportError:
                if `globus_sdk <https://globus-sdk-python.readthedocs.io/en/stable/>`_
                or `parsl <https://parsl.readthedocs.io/en/stable/>`_
                is not installed.
            ValueError:
                if `endpoints` is not a list of
                :class:`GlobusEndpoint <.GlobusEndpoint>`, instance of
                :class:`GlobusEndpoints <.GlobusEndpoints>`, or dict.
            ValueError:
                if the :code:`len(endpoints) != 2` because
                :class:`GlobusStore <.GlobusStore>` can currently only keep
                two endpoints in sync.
        """  # noqa: E501
        if import_error is not None:  # pragma: no cover
            raise import_error
        if isinstance(endpoints, GlobusEndpoints):
            self.endpoints = endpoints
        elif isinstance(endpoints, list):
            self.endpoints = GlobusEndpoints(endpoints)
        elif isinstance(endpoints, dict):
            self.endpoints = GlobusEndpoints.from_dict(endpoints)
        else:
            raise ValueError(
                "endpoints must be of type GlobusEndpoints or a list of "
                f"GlobusEndpoint. Got {type(endpoints)}.", )
        if len(endpoints) != 2:
            raise ValueError(
                "ProxyStore only supports two endpoints at a time", )
        self.polling_interval = polling_interval
        self.sync_level = sync_level
        self.timeout = timeout

        parsl_globus_auth = globus.get_globus()

        self._transfer_client = globus_sdk.TransferClient(
            authorizer=parsl_globus_auth.authorizer, )

        super().__init__(name, cache_size=cache_size)