def __init__( self, local_sandbox_dir: Union[str, os.PathLike], remote_proxy: Union[_s3proxy.AwsS3Proxy, _gcs_proxy.GCSProxy, None] = None, ): # Local access if local_sandbox_dir is None or local_sandbox_dir == "": raise Exception("Can't use empty path") local_sandbox_dir_appended = os.path.join(local_sandbox_dir, "local_flytekit") pathlib.Path(local_sandbox_dir_appended).mkdir(parents=True, exist_ok=True) self._local_sandbox_dir = local_sandbox_dir_appended self._local = _local_file_proxy.LocalFileProxy( local_sandbox_dir_appended) # Remote/cloud stuff if isinstance(remote_proxy, _s3proxy.AwsS3Proxy): self._aws = remote_proxy if isinstance(remote_proxy, _gcs_proxy.GCSProxy): self._gcs = remote_proxy if remote_proxy is not None: self._remote = remote_proxy else: mock_remote = os.path.join(local_sandbox_dir, "mock_remote") pathlib.Path(mock_remote).mkdir(parents=True, exist_ok=True) self._remote = _local_file_proxy.LocalFileProxy(mock_remote) # HTTP access self._http_proxy = _http_data_proxy.HttpFileProxy()
class _OutputDataContext(object): _CONTEXTS = [_local_file_proxy.LocalFileProxy(_sdk_config.LOCAL_SANDBOX.get())] def __init__(self, context): self._context = context def __enter__(self): self._CONTEXTS.append(self._context) def __exit__(self, exc_type, exc_val, exc_tb): self._CONTEXTS.pop() @classmethod def get_active_proxy(cls): return cls._CONTEXTS[-1] @classmethod def get_default_proxy(cls): return cls._CONTEXTS[0]
def __init__(self, sandbox): """ :param Text sandbox: """ super(LocalDataContext, self).__init__(_local_file_proxy.LocalFileProxy(sandbox))