nvidia-nat-s3 1.1.0a20251020__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of nvidia-nat-s3 might be problematic. Click here for more details.

File without changes
@@ -0,0 +1,49 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import os
17
+ from typing import ClassVar
18
+
19
+ from pydantic import Field
20
+
21
+ from nat.builder.builder import Builder
22
+ from nat.cli.register_workflow import register_object_store
23
+ from nat.data_models.object_store import ObjectStoreBaseConfig
24
+
25
+
26
+ class S3ObjectStoreClientConfig(ObjectStoreBaseConfig, name="s3"):
27
+ """
28
+ Object store that stores objects in an S3 bucket.
29
+ """
30
+
31
+ ACCESS_KEY_ENV: ClassVar[str] = "NAT_S3_OBJECT_STORE_ACCESS_KEY"
32
+ SECRET_KEY_ENV: ClassVar[str] = "NAT_S3_OBJECT_STORE_SECRET_KEY"
33
+
34
+ bucket_name: str = Field(..., description="The name of the bucket to use for the object store")
35
+ endpoint_url: str | None = Field(default=None, description="The URL of the S3 server to connect to")
36
+ access_key: str | None = Field(default=os.environ.get(ACCESS_KEY_ENV),
37
+ description=f"Access key. If omitted, reads from {ACCESS_KEY_ENV}")
38
+ secret_key: str | None = Field(default=os.environ.get(SECRET_KEY_ENV),
39
+ description=f"Secret key. If omitted, reads from {SECRET_KEY_ENV}")
40
+ region: str | None = Field(default=None, description="Region to access (or none if unspecified)")
41
+
42
+
43
+ @register_object_store(config_type=S3ObjectStoreClientConfig)
44
+ async def s3_object_store_client(config: S3ObjectStoreClientConfig, _builder: Builder):
45
+
46
+ from .s3_object_store import S3ObjectStore
47
+
48
+ async with S3ObjectStore(**config.model_dump(exclude={"type"}, exclude_none=False)) as store:
49
+ yield store
@@ -0,0 +1,21 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # flake8: noqa
17
+ # isort:skip_file
18
+
19
+ # Import any providers which need to be automatically registered here
20
+
21
+ from . import object_store
@@ -0,0 +1,166 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import logging
17
+
18
+ import aioboto3
19
+ from botocore.client import BaseClient
20
+ from botocore.exceptions import ClientError
21
+
22
+ from nat.data_models.object_store import KeyAlreadyExistsError
23
+ from nat.data_models.object_store import NoSuchKeyError
24
+ from nat.object_store.interfaces import ObjectStore
25
+ from nat.object_store.models import ObjectStoreItem
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+
30
+ class S3ObjectStore(ObjectStore):
31
+ """
32
+ S3ObjectStore is an ObjectStore implementation that uses S3 as the underlying storage.
33
+ """
34
+
35
+ def __init__(self,
36
+ *,
37
+ bucket_name: str,
38
+ endpoint_url: str | None,
39
+ access_key: str | None,
40
+ secret_key: str | None,
41
+ region: str | None):
42
+
43
+ super().__init__()
44
+
45
+ self.bucket_name = bucket_name
46
+ self.session = aioboto3.Session()
47
+ self._client: BaseClient | None = None
48
+ self._client_context = None
49
+
50
+ self._client_args: dict = {}
51
+ if access_key and secret_key:
52
+ self._client_args["aws_access_key_id"] = access_key
53
+ self._client_args["aws_secret_access_key"] = secret_key
54
+ if region:
55
+ self._client_args["region_name"] = region
56
+ if endpoint_url:
57
+ self._client_args["endpoint_url"] = endpoint_url
58
+
59
+ async def __aenter__(self) -> "S3ObjectStore":
60
+
61
+ if self._client_context is not None:
62
+ raise RuntimeError("Connection already established")
63
+
64
+ self._client_context = self.session.client("s3", **self._client_args)
65
+ if self._client_context is None:
66
+ raise RuntimeError("Connection unable to be established")
67
+ self._client = await self._client_context.__aenter__()
68
+ if self._client is None:
69
+ raise RuntimeError("Connection unable to be established")
70
+
71
+ # Ensure the bucket exists
72
+ try:
73
+ await self._client.head_bucket(Bucket=self.bucket_name)
74
+ except ClientError as e:
75
+ if e.response['Error']['Code'] == '404':
76
+ await self._client.create_bucket(Bucket=self.bucket_name)
77
+ logger.info("Created bucket %s", self.bucket_name)
78
+
79
+ return self
80
+
81
+ async def __aexit__(self, exc_type, exc_value, traceback) -> None:
82
+
83
+ if self._client_context is None:
84
+ raise RuntimeError("Connection not established")
85
+
86
+ await self._client_context.__aexit__(None, None, None)
87
+ self._client = None
88
+ self._client_context = None
89
+
90
+ async def put_object(self, key: str, item: ObjectStoreItem) -> None:
91
+
92
+ if self._client is None:
93
+ raise RuntimeError("Connection not established")
94
+
95
+ put_args = {
96
+ "Bucket": self.bucket_name,
97
+ "Key": key,
98
+ "Body": item.data,
99
+ }
100
+ if item.content_type:
101
+ put_args["ContentType"] = item.content_type
102
+
103
+ if item.metadata:
104
+ put_args["Metadata"] = item.metadata
105
+
106
+ try:
107
+ await self._client.put_object(
108
+ **put_args,
109
+ IfNoneMatch='*' # only succeed if the key does not already exist
110
+ )
111
+ except ClientError as e:
112
+ http_status_code = e.response.get("ResponseMetadata", {}).get("HTTPStatusCode", None)
113
+ if http_status_code == 412:
114
+ raise KeyAlreadyExistsError(
115
+ key=key,
116
+ additional_message=f"S3 object {self.bucket_name}/{key} already exists",
117
+ ) from e
118
+ # Other errors — rethrow or handle accordingly
119
+ raise
120
+
121
+ async def upsert_object(self, key: str, item: ObjectStoreItem) -> None:
122
+
123
+ if self._client is None:
124
+ raise RuntimeError("Connection not established")
125
+
126
+ put_args = {
127
+ "Bucket": self.bucket_name,
128
+ "Key": key,
129
+ "Body": item.data,
130
+ }
131
+ if item.content_type:
132
+ put_args["ContentType"] = item.content_type
133
+
134
+ if item.metadata:
135
+ put_args["Metadata"] = item.metadata
136
+
137
+ await self._client.put_object(**put_args)
138
+
139
+ async def get_object(self, key: str) -> ObjectStoreItem:
140
+ if self._client is None:
141
+ raise RuntimeError("Connection not established")
142
+
143
+ try:
144
+ response = await self._client.get_object(Bucket=self.bucket_name, Key=key)
145
+ data = await response["Body"].read()
146
+ return ObjectStoreItem(data=data, content_type=response['ContentType'], metadata=response['Metadata'])
147
+ except ClientError as e:
148
+ if e.response['Error']['Code'] == 'NoSuchKey':
149
+ raise NoSuchKeyError(key=key, additional_message=str(e)) from e
150
+ raise
151
+
152
+ async def delete_object(self, key: str) -> None:
153
+ if self._client is None:
154
+ raise RuntimeError("Connection not established")
155
+
156
+ try:
157
+ await self._client.get_object(Bucket=self.bucket_name, Key=key)
158
+ except ClientError as e:
159
+ if e.response['Error']['Code'] == 'NoSuchKey':
160
+ raise NoSuchKeyError(key=key, additional_message=str(e)) from e
161
+ raise
162
+
163
+ results = await self._client.delete_object(Bucket=self.bucket_name, Key=key)
164
+
165
+ if results.get('DeleteMarker', False):
166
+ raise NoSuchKeyError(key=key, additional_message="Object was a delete marker")
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: nvidia-nat-s3
3
+ Version: 1.1.0a20251020
4
+ Summary: Subpackage for S3-compatible integration in NeMo Agent toolkit
5
+ Author: NVIDIA Corporation
6
+ Maintainer: NVIDIA Corporation
7
+ License: Apache-2.0
8
+ Project-URL: documentation, https://docs.nvidia.com/nemo/agent-toolkit/latest/
9
+ Project-URL: source, https://github.com/NVIDIA/NeMo-Agent-Toolkit
10
+ Keywords: ai,agents,memory,data store
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Python: <3.14,>=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE-3rd-party.txt
18
+ License-File: LICENSE.md
19
+ Requires-Dist: nvidia-nat==v1.1.0a20251020
20
+ Requires-Dist: aioboto3>=11.0.0
21
+ Dynamic: license-file
@@ -0,0 +1,11 @@
1
+ nat/plugins/s3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ nat/plugins/s3/object_store.py,sha256=FDcO_8j__Nb-W8IY7JeUk5WoCRIqVNi1a1L1aVmYt10,2172
3
+ nat/plugins/s3/register.py,sha256=iBGq69m0rbZ3BTisA4Lt5UCHtW0Pc7m-l8G8dz-_pBc,813
4
+ nat/plugins/s3/s3_object_store.py,sha256=_2Sx1QXosuS2FnHXtG8qo4x9-xTNJVbNxoiJCZQcWgE,6052
5
+ nvidia_nat_s3-1.1.0a20251020.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
6
+ nvidia_nat_s3-1.1.0a20251020.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
7
+ nvidia_nat_s3-1.1.0a20251020.dist-info/METADATA,sha256=dYXVETGEaiIRtkFpDfz39iT98W3YSzUlvc_fbUH2gzQ,823
8
+ nvidia_nat_s3-1.1.0a20251020.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ nvidia_nat_s3-1.1.0a20251020.dist-info/entry_points.txt,sha256=HSc9lsaEu-3DyVezRMR-VZrfhWnDtA9llVaWE2CYZNw,63
10
+ nvidia_nat_s3-1.1.0a20251020.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
11
+ nvidia_nat_s3-1.1.0a20251020.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [nat.components]
2
+ nat_s3_object_store = nat.plugins.s3.register