diff --git a/setup.cfg b/setup.cfg index 8955837..efeb0bb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ [metadata] name = gypsum-client -description = Python cline to gypsum +description = Python client to gypsum REST API author = Jayaram Kancherla author_email = jayaram.kancherla@gmail.com license = MIT diff --git a/src/gypsum_client/__init__.py b/src/gypsum_client/__init__.py index 0e086f2..844d099 100644 --- a/src/gypsum_client/__init__.py +++ b/src/gypsum_client/__init__.py @@ -17,6 +17,7 @@ from .auth import access_token, set_access_token +from .cache_directory import cache_directory from .clone_operations import clone_version from .config import REQUESTS_MOD from .create_operations import create_project @@ -36,6 +37,7 @@ from .refresh_operations import refresh_latest, refresh_usage from .remove_operations import remove_asset, remove_project, remove_version from .resolve_links import resolve_links +from .rest_url import rest_url from .s3_config import public_s3_config from .save_operations import save_file, save_version from .search_metadata import define_text_query, search_metadata_text diff --git a/src/gypsum_client/_utils.py b/src/gypsum_client/_utils.py index 1ebf6ef..683ef88 100644 --- a/src/gypsum_client/_utils.py +++ b/src/gypsum_client/_utils.py @@ -3,8 +3,7 @@ import re import shutil import tempfile -from datetime import datetime, timezone -from pathlib import Path +from datetime import datetime from typing import Optional from urllib.parse import quote_plus @@ -18,40 +17,6 @@ __license__ = "MIT" -def _rest_url(url: Optional[str] = None): - current = "https://gypsum.artifactdb.com" - - if url is None: - return current - else: - return url - - -def _cache_directory(dir: Optional[str] = None): - current = None - if current is None: - _from_env = os.environ.get("GYPSUM_CACHE_DIR", None) - if _from_env is not None: - if not os.path.exists(_from_env): - raise FileNotFoundError( - f"Path {_from_env} does not exist or is not accessible." - ) - - current = _from_env - else: - current = os.path.join(str(Path.home()), "gypsum", "cache") - - os.makedirs(current, exist_ok=True) - - if dir is None: - return current - else: - if not os.path.exists(dir): - raise FileNotFoundError(f"Path {dir} does not exist or is not accessible.") - - return dir - - def _remove_slash_url(url: str): if url.endswith("/"): url = url.rstrip("/") diff --git a/src/gypsum_client/auth.py b/src/gypsum_client/auth.py index 51481b7..3499f0f 100644 --- a/src/gypsum_client/auth.py +++ b/src/gypsum_client/auth.py @@ -6,8 +6,10 @@ from filelock import FileLock from ._github import github_access_token -from ._utils import _cache_directory, _is_interactive, _remove_slash_url, _rest_url +from ._utils import _is_interactive, _remove_slash_url +from .cache_directory import cache_directory from .config import REQUESTS_MOD +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -23,7 +25,7 @@ def _token_cache_path(cache_dir): def access_token( full: bool = False, request: bool = True, - cache_dir: Optional[str] = _cache_directory(), + cache_dir: Optional[str] = cache_directory(), token_expiration_limit: int = 10, ) -> Optional[Union[str, dict]]: """Get GitHub access token for authentication to the gypsum API's. @@ -69,7 +71,6 @@ def _token_func(x): TOKEN_CACHE["auth_info"] = None if cache_dir is not None: - cache_dir = _cache_directory(cache_dir) cache_path = _token_cache_path(cache_dir) if os.path.exists(cache_path): @@ -99,12 +100,12 @@ def _token_func(x): def set_access_token( token: str = TOKEN_AUTO, - app_url: str = _rest_url(), + app_url: str = rest_url(), app_key: Optional[str] = None, app_secret: Optional[str] = None, github_url: str = "https://api.github.com", user_agent: Optional[str] = None, - cache_dir: Optional[str] = _cache_directory(), + cache_dir: Optional[str] = cache_directory(), ) -> dict: """Set GitHub access token for authentication to the gypsum API's. @@ -141,7 +142,6 @@ def set_access_token( cache_path = None if cache_dir is not None: - cache_dir = _cache_directory(cache_dir) cache_path = _token_cache_path(cache_dir) if token is None: @@ -211,7 +211,6 @@ def set_access_token( if expires_header is not None: expiry = float(expires_header.split(" ")[0]) - cache_dir = _cache_directory(cache_dir) if cache_dir is not None: cache_path = _token_cache_path(cache_dir) os.makedirs(os.path.dirname(cache_path), exist_ok=True) diff --git a/src/gypsum_client/cache_directory.py b/src/gypsum_client/cache_directory.py new file mode 100644 index 0000000..6d44753 --- /dev/null +++ b/src/gypsum_client/cache_directory.py @@ -0,0 +1,52 @@ +import os +from pathlib import Path +from typing import Optional + +__author__ = "Jayaram Kancherla" +__copyright__ = "Jayaram Kancherla" +__license__ = "MIT" + +CURRENT_CACHE_DIRECTORY = None + + +def cache_directory(dir: Optional[str] = None): + """Cache directory. + + Specify the cache directory in the local filesystem + for gypsum-related data. + + If the ``GYPSUM_CACHE_DIR`` environment variable is set + before the first call to ``cache_directory()``, it is used + as the initial location of the cache directory. + Otherwise, the initial location is set to user's home + directory defined by ``Path.home()``. + + Args: + dir: + Path to the cache directory. + If `None`, a default cache location is used. + + Returns: + Path to the cache directory. + """ + global CURRENT_CACHE_DIRECTORY + + if CURRENT_CACHE_DIRECTORY is None: + _from_env = os.environ.get("GYPSUM_CACHE_DIR", None) + if _from_env is not None: + if not os.path.exists(_from_env): + raise FileNotFoundError( + f"Path {_from_env} does not exist or is not accessible." + ) + + CURRENT_CACHE_DIRECTORY = _from_env + else: + CURRENT_CACHE_DIRECTORY = os.path.join(str(Path.home()), "gypsum", "cache") + os.makedirs(CURRENT_CACHE_DIRECTORY, exist_ok=True) + + if dir is not None: + if not os.path.exists(dir): + raise FileNotFoundError(f"Path {dir} does not exist or is not accessible.") + CURRENT_CACHE_DIRECTORY = dir + + return CURRENT_CACHE_DIRECTORY diff --git a/src/gypsum_client/clone_operations.py b/src/gypsum_client/clone_operations.py index 9b36afc..0dff5e7 100644 --- a/src/gypsum_client/clone_operations.py +++ b/src/gypsum_client/clone_operations.py @@ -42,8 +42,10 @@ import os import shutil -from ._utils import BUCKET_CACHE_NAME, _cache_directory, _rest_url +from ._utils import BUCKET_CACHE_NAME +from .cache_directory import cache_directory from .fetch_operations import fetch_manifest +from .rest_url import rest_url from .save_operations import save_version __author__ = "Jayaram Kancherla" @@ -57,8 +59,8 @@ def clone_version( version: str, destination: str, download: bool = True, - cache_dir: str = _cache_directory(), - url: str = _rest_url(), + cache_dir: str = cache_directory(), + url: str = rest_url(), **kwargs, ): """Clone a version's directory structure. @@ -112,8 +114,6 @@ def clone_version( Only used if ``download`` is `True`. """ - cache_dir = _cache_directory(cache_dir) - if download: save_version(project, asset, version, cache_dir=cache_dir, url=url, **kwargs) diff --git a/src/gypsum_client/create_operations.py b/src/gypsum_client/create_operations.py index 5964896..ca2947b 100644 --- a/src/gypsum_client/create_operations.py +++ b/src/gypsum_client/create_operations.py @@ -3,9 +3,10 @@ import requests -from ._utils import _remove_slash_url, _rest_url, _sanitize_uploaders +from ._utils import _remove_slash_url, _sanitize_uploaders from .auth import access_token from .config import REQUESTS_MOD +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -19,7 +20,7 @@ def create_project( baseline: int = None, growth_rate: int = None, year: int = None, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, ): """Create a new project with the associated permissions. diff --git a/src/gypsum_client/fetch_metadata_database.py b/src/gypsum_client/fetch_metadata_database.py index 8b92946..0f3c742 100644 --- a/src/gypsum_client/fetch_metadata_database.py +++ b/src/gypsum_client/fetch_metadata_database.py @@ -14,7 +14,8 @@ import requests from filelock import FileLock -from ._utils import _cache_directory, _download_and_rename_file +from ._utils import _download_and_rename_file +from .cache_directory import cache_directory from .config import REQUESTS_MOD __author__ = "Jayaram Kancherla" @@ -71,7 +72,7 @@ def fetch_metadata_database( if cache_dir is None: cache_path = tempfile.NamedTemporaryFile(suffix=".sqlite3").name else: - cache_dir = os.path.join(_cache_directory(cache_dir), "databases") + cache_dir = os.path.join(cache_directory(cache_dir), "databases") cache_path = os.path.join(cache_dir, name) if not os.path.exists(cache_path): diff --git a/src/gypsum_client/fetch_metadata_schema.py b/src/gypsum_client/fetch_metadata_schema.py index d3db0d4..9c07c60 100644 --- a/src/gypsum_client/fetch_metadata_schema.py +++ b/src/gypsum_client/fetch_metadata_schema.py @@ -4,7 +4,7 @@ import requests from filelock import FileLock -from ._utils import _cache_directory +from .cache_directory import cache_directory from .config import REQUESTS_MOD __author__ = "Jayaram Kancherla" @@ -58,7 +58,7 @@ def fetch_metadata_schema( if cache_dir is None: cache_path = tempfile.mktemp(suffix=".json") else: - cache_dir = os.path.join(_cache_directory(cache_dir), "schemas") + cache_dir = os.path.join(cache_directory(cache_dir), "schemas") cache_path = os.path.join(cache_dir, name) if not os.path.exists(cache_path): diff --git a/src/gypsum_client/fetch_operations.py b/src/gypsum_client/fetch_operations.py index fa2f0b4..89873ca 100644 --- a/src/gypsum_client/fetch_operations.py +++ b/src/gypsum_client/fetch_operations.py @@ -2,19 +2,19 @@ from ._utils import ( BUCKET_CACHE_NAME, - _cache_directory, _cast_datetime, _fetch_cacheable_json, _fetch_json, - _rest_url, ) +from .cache_directory import cache_directory +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" __license__ = "MIT" -def fetch_latest(project: str, asset: str, url: str = _rest_url()) -> str: +def fetch_latest(project: str, asset: str, url: str = rest_url()) -> str: """Fetch the latest version of a project's asset. See Also: @@ -48,9 +48,9 @@ def fetch_manifest( project: str, asset: str, version: str, - cache_dir: str = _cache_directory(), + cache_dir: str = cache_directory(), overwrite: bool = False, - url: str = _rest_url(), + url: str = rest_url(), ) -> dict: """Fetch the manifest for a version of an asset of a project. @@ -102,7 +102,7 @@ def fetch_manifest( ) -def fetch_permissions(project: str, url: str = _rest_url()) -> dict: +def fetch_permissions(project: str, url: str = rest_url()) -> dict: """Fetch the permissions for a project. See Also: @@ -153,7 +153,7 @@ def fetch_permissions(project: str, url: str = _rest_url()) -> dict: return perms -def fetch_quota(project: str, url: str = _rest_url()) -> dict: +def fetch_quota(project: str, url: str = rest_url()) -> dict: """Fetch the quota details for a project. See Also: @@ -185,9 +185,9 @@ def fetch_summary( project: str, asset: str, version: str, - cache_dir: str = _cache_directory(), + cache_dir: str = cache_directory(), overwrite: bool = False, - url: str = _rest_url(), + url: str = rest_url(), ) -> dict: """Fetch the summary for a version of an asset of a project. @@ -247,7 +247,7 @@ def fetch_summary( return _out -def fetch_usage(project: str, url: str = _rest_url()) -> int: +def fetch_usage(project: str, url: str = rest_url()) -> int: """Fetch the quota usage for a project. See Also: diff --git a/src/gypsum_client/list_operations.py b/src/gypsum_client/list_operations.py index 39bf325..0dc0f57 100644 --- a/src/gypsum_client/list_operations.py +++ b/src/gypsum_client/list_operations.py @@ -1,14 +1,15 @@ import requests -from ._utils import _list_for_prefix, _rest_url +from ._utils import _list_for_prefix from .config import REQUESTS_MOD +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" __license__ = "MIT" -def list_projects(url: str = _rest_url()) -> list: +def list_projects(url: str = rest_url()) -> list: """List all projects in the gypsum backend. Example: @@ -27,7 +28,7 @@ def list_projects(url: str = _rest_url()) -> list: return _list_for_prefix(prefix=None, url=url) -def list_assets(project: str, url: str = _rest_url()) -> list: +def list_assets(project: str, url: str = rest_url()) -> list: """List all assets in a project. Example: @@ -49,7 +50,7 @@ def list_assets(project: str, url: str = _rest_url()) -> list: return _list_for_prefix(f"{project}/", url=url) -def list_versions(project: str, asset: str, url=_rest_url()) -> list: +def list_versions(project: str, asset: str, url: str = rest_url()) -> list: """List all versions for a project asset. Example: @@ -80,7 +81,7 @@ def list_files( version: str, prefix: str = None, include_dot: bool = True, - url: str = _rest_url(), + url: str = rest_url(), ) -> list: """List all files for a specified version of a project and asset. diff --git a/src/gypsum_client/prepare_directory_for_upload.py b/src/gypsum_client/prepare_directory_for_upload.py index fa98486..fd2f8b6 100644 --- a/src/gypsum_client/prepare_directory_for_upload.py +++ b/src/gypsum_client/prepare_directory_for_upload.py @@ -59,9 +59,9 @@ from ._utils import ( BUCKET_CACHE_NAME, - _cache_directory, _sanitize_path, ) +from .cache_directory import cache_directory __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -71,7 +71,7 @@ def prepare_directory_upload( directory: str, links: Literal["auto", "always", "never"] = "auto", - cache_dir: str = _cache_directory(), + cache_dir: str = cache_directory(), ) -> dict: """Prepare to upload a directory's contents. @@ -111,8 +111,6 @@ def prepare_directory_upload( f"Invalid value for 'links': {links}. Must be one of {_links_options}." ) - cache_dir = _cache_directory(cache_dir) - out_files = [] out_links = [] diff --git a/src/gypsum_client/probation_operations.py b/src/gypsum_client/probation_operations.py index b1077f5..057152c 100644 --- a/src/gypsum_client/probation_operations.py +++ b/src/gypsum_client/probation_operations.py @@ -4,9 +4,9 @@ from ._utils import ( _remove_slash_url, - _rest_url, ) from .auth import access_token +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -14,7 +14,7 @@ def approve_probation( - project: str, asset: str, version: str, url: str = _rest_url(), token: str = None + project: str, asset: str, version: str, url: str = rest_url(), token: str = None ): """Approve a probational upload. @@ -81,7 +81,7 @@ def approve_probation( def reject_probation( - project: str, asset: str, version: str, url: str = _rest_url(), token: str = None + project: str, asset: str, version: str, url: str = rest_url(), token: str = None ): """Reject a probational upload. diff --git a/src/gypsum_client/refresh_operations.py b/src/gypsum_client/refresh_operations.py index 6d82e8c..36b5215 100644 --- a/src/gypsum_client/refresh_operations.py +++ b/src/gypsum_client/refresh_operations.py @@ -4,9 +4,9 @@ from ._utils import ( _remove_slash_url, - _rest_url, ) from .auth import access_token +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -14,7 +14,7 @@ def refresh_latest( - project: str, asset: str, url: str = _rest_url(), token: str = None + project: str, asset: str, url: str = rest_url(), token: str = None ) -> str: """Refresh the latest version. @@ -69,7 +69,7 @@ def refresh_latest( return req.json()["version"] -def refresh_usage(project: str, url: str = _rest_url(), token: str = None) -> int: +def refresh_usage(project: str, url: str = rest_url(), token: str = None) -> int: """Refresh the usage quota of a project. Recompute the usage of a project. diff --git a/src/gypsum_client/remove_operations.py b/src/gypsum_client/remove_operations.py index 4b1c052..62a1096 100644 --- a/src/gypsum_client/remove_operations.py +++ b/src/gypsum_client/remove_operations.py @@ -2,15 +2,16 @@ import requests -from ._utils import _remove_slash_url, _rest_url +from ._utils import _remove_slash_url from .auth import access_token +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" __license__ = "MIT" -def remove_asset(project: str, asset: str, url: str = _rest_url(), token: str = None): +def remove_asset(project: str, asset: str, url: str = rest_url(), token: str = None): """Remove an asset of a project from the gypsum backend. See Also: @@ -62,7 +63,7 @@ def remove_asset(project: str, asset: str, url: str = _rest_url(), token: str = return True -def remove_project(project: str, url: str = _rest_url(), token: str = None): +def remove_project(project: str, url: str = rest_url(), token: str = None): """Remove a project from the gypsum backend. See Also: @@ -109,11 +110,11 @@ def remove_version( project: str, asset: str, version: str, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, ): """Remove a project from the gypsum backend. - + See Also: :py:func:`~.remove_asset`, to remove a specific asset. diff --git a/src/gypsum_client/resolve_links.py b/src/gypsum_client/resolve_links.py index e044746..dea1525 100644 --- a/src/gypsum_client/resolve_links.py +++ b/src/gypsum_client/resolve_links.py @@ -6,11 +6,11 @@ from ._utils import ( BUCKET_CACHE_NAME, _acquire_lock, - _cache_directory, _release_lock, - _rest_url, ) +from .cache_directory import cache_directory from .fetch_operations import fetch_manifest +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -23,7 +23,7 @@ def resolve_links( version: str, cache_dir: Optional[str] = None, overwrite: str = False, - url: str = _rest_url(), + url: str = rest_url(), ): """Resolve links in the cache directory. @@ -66,7 +66,6 @@ def resolve_links( """ from .save_operations import save_file - cache_dir = _cache_directory(cache_dir) _acquire_lock(cache_dir, project, asset, version) def release_lock_wrapper(): diff --git a/src/gypsum_client/rest_url.py b/src/gypsum_client/rest_url.py new file mode 100644 index 0000000..787dc8b --- /dev/null +++ b/src/gypsum_client/rest_url.py @@ -0,0 +1,27 @@ +from typing import Optional + +__author__ = "Jayaram Kancherla" +__copyright__ = "Jayaram Kancherla" +__license__ = "MIT" + +CURRENT_REST_URL = "https://gypsum.artifactdb.com" + + +def rest_url(url: Optional[str] = None): + """URL for the gypsum REST API. + + Get or set the URL for the gypsum REST API. + + Args: + url: + URL to the gypsum REST API. + Defaults to None. + + Returns: + String containing the URL to the gypsum REST API. + """ + global CURRENT_REST_URL + if url is not None: + CURRENT_REST_URL = url + + return CURRENT_REST_URL diff --git a/src/gypsum_client/s3_config.py b/src/gypsum_client/s3_config.py index e030ad7..4bece0a 100644 --- a/src/gypsum_client/s3_config.py +++ b/src/gypsum_client/s3_config.py @@ -6,8 +6,9 @@ import requests from filelock import FileLock -from ._utils import _cache_directory, _rest_url +from .cache_directory import cache_directory from .config import REQUESTS_MOD +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -22,7 +23,7 @@ def _config_cache_path(cache_dir): def public_s3_config( - refresh: bool = False, url: str = _rest_url(), cache_dir: Optional[str] = None + refresh: bool = False, url: str = rest_url(), cache_dir: Optional[str] = None ) -> dict: """Get S3 configuration to the bucket storing the data. @@ -44,7 +45,6 @@ def public_s3_config( A dictionary containing the S3 credentials. """ creds = None - cache_dir = _cache_directory(cache_dir) if not refresh: if cache_dir is None: diff --git a/src/gypsum_client/save_operations.py b/src/gypsum_client/save_operations.py index 6dd22d9..129f30e 100644 --- a/src/gypsum_client/save_operations.py +++ b/src/gypsum_client/save_operations.py @@ -9,15 +9,15 @@ from ._utils import ( BUCKET_CACHE_NAME, _acquire_lock, - _cache_directory, _release_lock, - _rest_url, _sanitize_path, _save_file, ) +from .cache_directory import cache_directory from .config import REQUESTS_MOD from .list_operations import list_files from .resolve_links import resolve_links +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -39,7 +39,7 @@ def save_version( overwrite: bool = False, relink: bool = True, concurrent: int = 1, - url: str = _rest_url(), + url: str = rest_url(), ) -> str: """Download all files associated with a version of an asset of a project from the gypsum bucket. @@ -82,7 +82,6 @@ def save_version( Path to the local directory where the files are downloaded to. """ - cache_dir = _cache_directory(cache_dir) _acquire_lock(cache_dir, project, asset, version) def release_lock_wrapper(): @@ -206,7 +205,7 @@ def save_file( path: str, cache_dir: Optional[str] = None, overwrite: bool = False, - url: str = _rest_url(), + url: str = rest_url(), ): """Save a file from a version of a project asset. @@ -256,7 +255,6 @@ def save_file( The destintion file path where the file is downloaded to in the local file system. """ - cache_dir = _cache_directory(cache_dir) _acquire_lock(cache_dir, project, asset, version) diff --git a/src/gypsum_client/set_operations.py b/src/gypsum_client/set_operations.py index ba7974a..6008049 100644 --- a/src/gypsum_client/set_operations.py +++ b/src/gypsum_client/set_operations.py @@ -2,9 +2,10 @@ import requests -from ._utils import _remove_slash_url, _rest_url, _sanitize_uploaders +from ._utils import _remove_slash_url, _sanitize_uploaders from .auth import access_token from .fetch_operations import fetch_permissions +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -16,7 +17,7 @@ def set_quota( baseline: int = None, growth_rate: int = None, year: int = None, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, ): """ @@ -96,7 +97,7 @@ def set_permissions( owners: str = None, uploaders: str = None, append: bool = True, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, ): """ diff --git a/src/gypsum_client/upload_api_operations.py b/src/gypsum_client/upload_api_operations.py index fb2e641..9a36011 100644 --- a/src/gypsum_client/upload_api_operations.py +++ b/src/gypsum_client/upload_api_operations.py @@ -5,9 +5,10 @@ import requests -from ._utils import _remove_slash_url, _rest_url, _sanitize_path +from ._utils import _remove_slash_url, _sanitize_path from .auth import access_token from .config import REQUESTS_MOD +from .rest_url import rest_url __author__ = "Jayaram Kancherla" __copyright__ = "Jayaram Kancherla" @@ -22,7 +23,7 @@ def start_upload( links: List[dict] = None, deduplicate: bool = True, probation: bool = False, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, directory: str = None, ) -> dict: @@ -240,7 +241,7 @@ def start_upload( return resp -def complete_upload(init: dict, url=_rest_url()): +def complete_upload(init: dict, url=rest_url()): """Complete an upload session after all files have been uploaded. See Also: @@ -300,7 +301,7 @@ def complete_upload(init: dict, url=_rest_url()): ) from e -def abort_upload(init: dict, url=_rest_url()): +def abort_upload(init: dict, url=rest_url()): """Abort an upload session, usually after an irrecoverable error. See Also: diff --git a/src/gypsum_client/upload_file_actions.py b/src/gypsum_client/upload_file_actions.py index bcd50fa..4010df4 100644 --- a/src/gypsum_client/upload_file_actions.py +++ b/src/gypsum_client/upload_file_actions.py @@ -3,10 +3,12 @@ import requests -from ._utils import _cache_directory, _remove_slash_url, _rest_url +from ._utils import _remove_slash_url from .auth import access_token +from .cache_directory import cache_directory from .config import REQUESTS_MOD from .prepare_directory_for_upload import prepare_directory_upload +from .rest_url import rest_url from .upload_api_operations import abort_upload, complete_upload, start_upload __author__ = "Jayaram Kancherla" @@ -19,10 +21,10 @@ def upload_directory( project: str, asset: str, version: str, - cache_dir: str = _cache_directory(), + cache_dir: str = cache_directory(), deduplicate: bool = True, probation: bool = False, - url: str = _rest_url(), + url: str = rest_url(), token: str = None, concurrent: int = 1, abort_failed: bool = True, @@ -106,7 +108,6 @@ def upload_directory( Returns: `True` if successfull, otherwise `False`. """ - cache_dir = _cache_directory(cache_dir) if token is None: token = access_token() @@ -143,7 +144,7 @@ def _upload_file_wrapper(args): def upload_files( - init: dict, directory: str = None, url: str = _rest_url(), concurrent: int = 1 + init: dict, directory: str = None, url: str = rest_url(), concurrent: int = 1 ): """Upload files in an initialized upload session for a version of an asset.