Skip to content

Commit

Permalink
implement metadata search functions (#8)
Browse files Browse the repository at this point in the history
Refactor, renaming, tests, documentation.
  • Loading branch information
jkanche authored May 19, 2024
1 parent 005a7c3 commit dbdfdd1
Show file tree
Hide file tree
Showing 29 changed files with 806 additions and 252 deletions.
30 changes: 15 additions & 15 deletions src/gypsum_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
finally:
del version, PackageNotFoundError

from .abort_upload import abort_upload

from .auth import access_token, set_access_token
from .clone_version import clone_version
from .complete_upload import complete_upload
from .create_assets import create_project
from .fetch_assets import (
from .clone_operations import clone_version
from .create_operations import create_project
from .fetch_metadata_database import fetch_metadata_database
from .fetch_metadata_schema import fetch_metadata_schema
from .fetch_operations import (
fetch_latest,
fetch_manifest,
fetch_permissions,
fetch_quota,
fetch_summary,
fetch_usage,
)
from .fetch_metadata_database import fetch_metadata_database
from .fetch_metadata_schema import fetch_metadata_schema
from .list_assets import list_assets, list_files, list_projects, list_versions
from .list_operations import list_assets, list_files, list_projects, list_versions
from .prepare_directory_for_upload import prepare_directory_upload
from .probation import approve_probation, reject_probation
from .refresh_ops import refresh_latest, refresh_usage
from .remove_assets import remove_asset, remove_project, remove_version
from .probation_operations import approve_probation, reject_probation
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 .s3_config import public_s3_config
from .save_assets import save_version
from .save_file import save_file
from .set_ops import set_permissions, set_quota
from .upload_assets import upload_directory, upload_files
from .save_operations import save_file, save_version
from .search_metadata import define_text_query, search_metadata_text
from .set_operations import set_permissions, set_quota
from .upload_api_operations import abort_upload, complete_upload, start_upload
from .upload_file_actions import upload_directory, upload_files
4 changes: 2 additions & 2 deletions src/gypsum_client/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _save_file(
if overwrite is True or not os.path.exists(destination):
os.makedirs(os.path.dirname(destination), exist_ok=True)

_lock = FileLock(destination + ".lock")
_lock = FileLock(destination + ".LOCK")
with _lock:
with tempfile.NamedTemporaryFile(
dir=os.path.dirname(destination), delete=False
Expand Down Expand Up @@ -224,7 +224,7 @@ def _acquire_lock(cache: str, project: str, asset: str, version: str):
_path = os.path.join(cache, "status", project, asset, version)
os.makedirs(os.path.dirname(_path), exist_ok=True)

_lock = FileLock(_path + ".lock")
_lock = FileLock(_path + ".LOCK")
_lock.acquire()
IS_LOCKED["locks"][_key] = _lock

Expand Down
36 changes: 0 additions & 36 deletions src/gypsum_client/abort_upload.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/gypsum_client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _token_func(x):
cache_path = _token_cache_path(cache_dir)

if os.path.exists(cache_path):
_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
with _lock:
with open(cache_path, "r") as file:
dump = file.read().splitlines()
Expand Down Expand Up @@ -204,7 +204,7 @@ def set_access_token(
cache_path = _token_cache_path(cache_dir)
os.makedirs(os.path.dirname(cache_path), exist_ok=True)

_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
with _lock:
with open(cache_path, "w") as file:
file.write("\n".join([token, name, str(expiry)]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import shutil

from ._utils import BUCKET_CACHE_NAME, _cache_directory, _rest_url
from .fetch_assets import fetch_manifest
from .save_assets import save_version
from .fetch_operations import fetch_manifest
from .save_operations import save_version

__author__ = "Jayaram Kancherla"
__copyright__ = "Jayaram Kancherla"
Expand Down
35 changes: 0 additions & 35 deletions src/gypsum_client/complete_upload.py

This file was deleted.

2 changes: 2 additions & 0 deletions src/gypsum_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
__copyright__ = "Jayaram Kancherla"
__license__ = "MIT"

## Set this to False if SSL certificates are not properly setup on your machine.
## essentially sets verify=False on all requests going out.

REQUESTS_MOD = {"verify": True}
File renamed without changes.
4 changes: 2 additions & 2 deletions src/gypsum_client/fetch_metadata_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def fetch_metadata_database(
if os.path.exists(cache_path) and not overwrite:
old_lastmod_raw = None

_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
if not _lock.is_locked:
old_lastmod_raw = open(cache_path + ".modified").readlines()

Expand All @@ -71,7 +71,7 @@ def fetch_metadata_database(
if new_lastmod is not None and old_lastmod == new_lastmod:
return cache_path

_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
with _lock:
mod_path = cache_path + ".modified"
_download_and_rename_file(base_url + "modified", mod_path)
Expand Down
4 changes: 2 additions & 2 deletions src/gypsum_client/fetch_metadata_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def fetch_metadata_schema(
os.makedirs(os.path.dirname(cache_path), exist_ok=True)

if os.path.exists(cache_path) and not overwrite:
_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
if not _lock.is_locked:
return cache_path

_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
with _lock:
url = "https://artifactdb.github.io/bioconductor-metadata-index/" + name
response = requests.get(url, verify=REQUESTS_MOD["verify"])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions src/gypsum_client/resolve_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
_release_lock,
_rest_url,
)
from .fetch_assets import fetch_manifest
from .save_file import save_file
from .fetch_operations import fetch_manifest

__author__ = "Jayaram Kancherla"
__copyright__ = "Jayaram Kancherla"
Expand Down Expand Up @@ -54,6 +53,8 @@ def resolve_links(
Returns:
True if all links are resolved.
"""
from .save_operations import save_file

cache_dir = _cache_directory(cache_dir)
_acquire_lock(cache_dir, project, asset, version)

Expand Down
4 changes: 2 additions & 2 deletions src/gypsum_client/s3_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def public_s3_config(

cache_path = _config_cache_path(cache_dir)
if os.path.exists(cache_path):
_lock = FileLock(cache_path + ".lock")
_lock = FileLock(cache_path + ".LOCK")
with _lock:
with open(cache_dir, "r") as f:
creds = json.load(f)
Expand All @@ -79,7 +79,7 @@ def public_s3_config(
config_path = _config_cache_path(cache_dir)
os.makedirs(os.path.dirname(config_path), exist_ok=True)

with FileLock(config_path + ".lock"):
with FileLock(config_path + ".LOCK"):
with open(config_path, "w") as f:
json.dump(creds, f)

Expand Down
131 changes: 0 additions & 131 deletions src/gypsum_client/save_assets.py

This file was deleted.

Loading

0 comments on commit dbdfdd1

Please sign in to comment.