Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/ExamplesDocDBRestApi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ It's possible to attach a custom Session to retry certain requests errors:
Updating Metadata
~~~~~~~~~~~~~~~~~~~~~~

1. **Permissions**: Request permissions for AWS Credentials to write to DocDB through the API Gateway.
1. **Permissions**: Request permissions for AWS Credentials to write to DocDB through the API Gateway.
Note that the asset de/registration endpoints are intended for administrative use and require elevated AWS credentials/permissions.
2. **Query DocDB**: Filter for the records you want to update.
3. **Update DocDB**: Use ``upsert_one_docdb_record`` or ``upsert_list_of_docdb_records`` to update the records.

Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_access_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Init package"""

__version__ = "1.9.2"
__version__ = "1.9.3"
58 changes: 53 additions & 5 deletions src/aind_data_access_api/document_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ def _add_qc_evaluation_url(self) -> str:
return f"https://{self.host}/{self.version}/add_qc_evaluation"

def generate_data_summary(self, record_id: str) -> Dict[str, Any]:
"""Get an LLM-generated summary for a data asset."""
"""
Get an LLM-generated summary for a data asset with the given record id.
"""
url = f"{self._data_summary_url}/{record_id}"
signed_header = self._signed_request(method="GET", url=url)
response = self.session.get(
Expand All @@ -641,8 +643,21 @@ def generate_data_summary(self, record_id: str) -> Dict[str, Any]:
return response.json()

def register_asset(self, s3_location: str) -> Dict[str, Any]:
"""Register a data asset to Code Ocean and the DocDB metadata index."""
"""
Register a data asset to Code Ocean and add its metadata to DocDB
given the metadata exists at the top level of the provided S3 location.

Parameters
----------
s3_location : str
The S3 location containing the asset and its metadata.

Returns
-------
Dict[str, Any]
The response from the registration API, including registration
status and details.
"""
data = json.dumps({"s3_location": s3_location})
signed_header = self._signed_request(
method="POST", url=self._register_asset_url, data=data
Expand All @@ -662,8 +677,28 @@ def register_co_result(
co_asset_id: str,
co_computation_id: str,
) -> Dict[str, Any]:
"""Register a Code Ocean result asset to the DocDB metadata index."""
"""
Register a Code Ocean result asset and add its metadata to DocDB
given the metadata exists at the top level of the Code Ocean
computation result.

Parameters
----------
s3_location : str
The S3 location containing the result asset and its metadata.
name : str
The name of the result asset.
co_asset_id : str
The Code Ocean asset ID for the result.
co_computation_id : str
The Code Ocean computation ID associated with the result.

Returns
-------
Dict[str, Any]
The response from the registration API, including registration
status and details.
"""
data = json.dumps(
{
"s3_location": s3_location,
Expand All @@ -684,9 +719,22 @@ def register_co_result(
return response.json()

def deregister_asset(self, s3_location: str) -> Dict[str, Any]:
"""De-register (delete) a data asset in Code Ocean and the
DocDB metadata index."""
"""
De-register (delete) a data asset from Code Ocean and remove its
metadata from DocDB given that the asset and its metadata are located
at the provided S3 location.

Parameters
----------
s3_location : str
The S3 location containing the asset and metadata to be removed.

Returns
-------
Dict[str, Any]
The response from the deregistration API, including deregistration
status and details.
"""
data = json.dumps({"s3_location": s3_location})
signed_header = self._signed_request(
method="DELETE", url=self._deregister_asset_url, data=data
Expand Down