diff --git a/annotationengine/api.py b/annotationengine/api.py index 3138031..80a9f0c 100644 --- a/annotationengine/api.py +++ b/annotationengine/api.py @@ -16,6 +16,8 @@ from caveclient.auth import AuthClient import werkzeug import traceback +import datetime +import pytz from annotationengine.aligned_volume import ( get_aligned_volumes, @@ -100,6 +102,14 @@ def handle_invalid_usage(error): location="args", help="whether to only return valid items", ) +query_parser.add_argument( + "timestamp", + type=str, + default=None, + location="args", + required=False, + help="timestamp for filtering results (will default to now if not required)", +) def check_aligned_volume(aligned_volume): @@ -243,11 +253,19 @@ def put(self, aligned_volume_name: str) -> FullMetadataSchema: @api_bp.expect(query_parser) def get(self, aligned_volume_name: str): """Get list of annotation tables for a aligned_volume""" + args = query_parser.parse_args() + timestamp_str = args.get("timestamp", None) + if timestamp_str is None: + timestamp = datetime.datetime.now(datetime.timezone.utc) + else: + timestamp = datetime.datetime.strptime(timestamp_str, '%Y-%m-%dT%H:%M:%S.%f') + timestamp = pytz.utc.localize(timestamp) + check_aligned_volume(aligned_volume_name) db = get_db(aligned_volume_name) - args = query_parser.parse_args() tables = db.database._get_existing_table_names( - filter_valid=args.get("filter_valid", True) + filter_valid=args.get("filter_valid", True), + filter_timestamp=timestamp ) return tables, 200 diff --git a/requirements.txt b/requirements.txt index ede4846..ab77ef7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,7 +29,7 @@ decorator==5.1.1 # via ipython deprecated==1.2.13 # via redis -dynamicannotationdb==5.8.1 +dynamicannotationdb==5.14.1 # via -r requirements.in emannotationschemas==5.24.12 # via