Skip to content

Commit

Permalink
Merge pull request #128 from seung-lab/expired_versions
Browse files Browse the repository at this point in the history
Expired versions flag
  • Loading branch information
fcollman authored Oct 23, 2023
2 parents e9ea541 + c25fe28 commit d5ab695
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions caveclient/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"join_query": mat_v3_api + "/datastack/{datastack_name}/version/{version}/query",
"table_count": mat_v2_api
+ "/datastack/{datastack_name}/version/{version}/table/{table_name}/count",
"versions": mat_v2_api + "/datastack/{datastack_name}/versions",
"version_metadata": mat_v2_api + "/datastack/{datastack_name}/version/{version}",
"versions": mat_v3_api + "/datastack/{datastack_name}/versions",
"version_metadata": mat_v3_api + "/datastack/{datastack_name}/version/{version}",
"tables": mat_v2_api + "/datastack/{datastack_name}/version/{version}/tables",
"metadata": mat_v3_api
+ "/datastack/{datastack_name}/version/{version}/table/{table_name}/metadata",
"all_tables_metadata": mat_v3_api
+ "/datastack/{datastack_name}/version/{version}/tables/metadata",
"versions_metadata": mat_v2_api + "/datastack/{datastack_name}/metadata",
"versions_metadata": mat_v3_api + "/datastack/{datastack_name}/metadata",
"ingest_annotation_table": mat_v2_api
+ "/materialize/run/ingest_annotations/datastack/{datastack_name}/{table_name}",
"segmentation_metadata": mat_v3_api
Expand Down
11 changes: 7 additions & 4 deletions caveclient/materializationengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def most_recent_version(self, datastack_name=None):
versions = self.get_versions(datastack_name=datastack_name)
return np.max(np.array(versions))

def get_versions(self, datastack_name=None):
def get_versions(self, datastack_name=None, expired=False):
"""get versions available
Args:
Expand All @@ -303,7 +303,8 @@ def get_versions(self, datastack_name=None):
endpoint_mapping = self.default_url_mapping
endpoint_mapping["datastack_name"] = datastack_name
url = self._endpoints["versions"].format_map(endpoint_mapping)
response = self.session.get(url)
query_args = {"expired": expired}
response = self.session.get(url, params=query_args)
self.raise_for_status(response)
return response.json()

Expand Down Expand Up @@ -422,11 +423,12 @@ def get_timestamp(self, version: int = None, datastack_name: str = None):
return convert_timestamp(meta["time_stamp"])

@cached(cache=TTLCache(maxsize=100, ttl=60 * 60 * 12))
def get_versions_metadata(self, datastack_name=None):
def get_versions_metadata(self, datastack_name=None, expired=False):
"""get the metadata for all the versions that are presently available and valid
Args:
datastack_name (str, optional): datastack to query. If None, defaults to the value set in the client.
expired (bool, optional): whether to include expired versions. Defaults to False.
Returns:
list[dict]: a list of metadata dictionaries
Expand All @@ -436,7 +438,8 @@ def get_versions_metadata(self, datastack_name=None):
endpoint_mapping = self.default_url_mapping
endpoint_mapping["datastack_name"] = datastack_name
url = self._endpoints["versions_metadata"].format_map(endpoint_mapping)
response = self.session.get(url)
query_args = {"expired": expired}
response = self.session.get(url, params=query_args)
d = handle_response(response)
for md in d:
md["time_stamp"] = convert_timestamp(md["time_stamp"])
Expand Down

0 comments on commit d5ab695

Please sign in to comment.