digitalkin 0.2.20__py3-none-any.whl → 0.2.22__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.
digitalkin/__version__.py CHANGED
@@ -5,4 +5,4 @@ from importlib.metadata import PackageNotFoundError, version
5
5
  try:
6
6
  __version__ = version("digitalkin")
7
7
  except PackageNotFoundError:
8
- __version__ = "0.2.20"
8
+ __version__ = "0.2.22"
@@ -100,6 +100,9 @@ class ModuleServicer(module_service_pb2_grpc.ModuleServiceServicer, ArgParser):
100
100
  ServicerError: if the setup data is not returned or job creation fails.
101
101
  """
102
102
  logger.info("ConfigSetupVersion called for module: '%s'", self.module_class.__name__)
103
+ logger.info(
104
+ "Context : %s, setup_version: %s, mission_id: %s", context, request.setup_version, request.mission_id
105
+ )
103
106
  # Process the module input
104
107
  # TODO: Secret should be used here as well
105
108
  setup_version = request.setup_version
@@ -157,6 +160,7 @@ class ModuleServicer(module_service_pb2_grpc.ModuleServiceServicer, ArgParser):
157
160
  ServicerError: the necessary query didn't work.
158
161
  """
159
162
  logger.info("StartModule called for module: '%s'", self.module_class.__name__)
163
+ logger.info("Context : %s, setup_id: %s, mission_id: %s", context, request.setup_id, request.mission_id)
160
164
  # Process the module input
161
165
  # TODO: Check failure of input data format
162
166
  input_data = self.module_class.create_input_model(dict(request.input.items()))
@@ -84,7 +84,6 @@ class DefaultFilesystem(FilesystemStrategy):
84
84
  if (not filters.names or f.name in filters.names)
85
85
  and (not filters.file_ids or f.id in filters.file_ids)
86
86
  and (not filters.file_types or f.file_type in filters.file_types)
87
- and f.context == self.mission_id
88
87
  and (not filters.status or f.status == filters.status)
89
88
  and (not filters.content_type_prefix or f.content_type.startswith(filters.content_type_prefix))
90
89
  and (not filters.min_size_bytes or f.size_bytes >= filters.min_size_bytes)
@@ -215,6 +214,7 @@ class DefaultFilesystem(FilesystemStrategy):
215
214
  def get_file(
216
215
  self,
217
216
  file_id: str,
217
+ context: Literal["mission", "setup"] = "mission", # noqa: ARG002
218
218
  *,
219
219
  include_content: bool = False,
220
220
  ) -> FilesystemRecord:
@@ -226,6 +226,7 @@ class DefaultFilesystem(FilesystemStrategy):
226
226
 
227
227
  Args:
228
228
  file_id: The ID of the file to be retrieved
229
+ context: The context of the files (mission or setup)
229
230
  include_content: Whether to include file content in response
230
231
 
231
232
  Returns:
@@ -33,6 +33,9 @@ class FilesystemRecord(BaseModel):
33
33
  class FileFilter(BaseModel):
34
34
  """Filter criteria for querying files."""
35
35
 
36
+ context: Literal["mission", "setup"] = Field(
37
+ default="mission", description="The context of the files (mission or setup)"
38
+ )
36
39
  names: list[str] | None = Field(default=None, description="Filter by file names (exact matches)")
37
40
  file_ids: list[str] | None = Field(default=None, description="Filter by file IDs")
38
41
  file_types: (
@@ -130,6 +133,7 @@ class FilesystemStrategy(BaseStrategy, ABC):
130
133
  def get_file(
131
134
  self,
132
135
  file_id: str,
136
+ context: Literal["mission", "setup"] = "mission",
133
137
  *,
134
138
  include_content: bool = False,
135
139
  ) -> FilesystemRecord:
@@ -141,6 +145,7 @@ class FilesystemStrategy(BaseStrategy, ABC):
141
145
 
142
146
  Args:
143
147
  file_id: The ID of the file to be retrieved
148
+ context: The context of the files (mission or setup)
144
149
  include_content: Whether to include file content in response
145
150
 
146
151
  Returns:
@@ -85,25 +85,8 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
85
85
  except AttributeError:
86
86
  return filesystem_pb2.FileStatus.FILE_STATUS_UNSPECIFIED
87
87
 
88
- def _filter_to_proto(self, filters: FileFilter) -> filesystem_pb2.FileFilter:
89
- """Convert a FileFilter to a FileFilter proto message.
90
-
91
- Args:
92
- filters: The FileFilter to convert
93
-
94
- Returns:
95
- filesystem_pb2.FileFilter: The converted FileFilter proto message
96
- """
97
- return filesystem_pb2.FileFilter(
98
- context=self.setup_id,
99
- **filters.model_dump(exclude={"file_types", "status"}),
100
- file_types=[self._file_type_to_enum(file_type) for file_type in filters.file_types]
101
- if filters.file_types
102
- else None,
103
- status=self._file_status_to_enum(filters.status) if filters.status else None,
104
- )
105
-
106
- def _file_proto_to_data(self, file: filesystem_pb2.File) -> FilesystemRecord:
88
+ @staticmethod
89
+ def _file_proto_to_data(file: filesystem_pb2.File) -> FilesystemRecord:
107
90
  """Convert a File proto message to FilesystemRecord.
108
91
 
109
92
  Args:
@@ -114,7 +97,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
114
97
  """
115
98
  return FilesystemRecord(
116
99
  id=file.file_id,
117
- context=self.setup_id,
100
+ context=file.context,
118
101
  name=file.name,
119
102
  file_type=filesystem_pb2.FileType.Name(file.file_type),
120
103
  content_type=file.content_type,
@@ -127,6 +110,23 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
127
110
  content=file.content,
128
111
  )
129
112
 
113
+ def _filter_to_proto(self, filters: FileFilter) -> filesystem_pb2.FileFilter:
114
+ """Convert a FileFilter to a FileFilter proto message.
115
+
116
+ Args:
117
+ filters: The FileFilter to convert
118
+
119
+ Returns:
120
+ filesystem_pb2.FileFilter: The converted FileFilter proto message
121
+ """
122
+ return filesystem_pb2.FileFilter(
123
+ **filters.model_dump(exclude={"file_types", "status"}),
124
+ file_types=[self._file_type_to_enum(file_type) for file_type in filters.file_types]
125
+ if filters.file_types
126
+ else None,
127
+ status=self._file_status_to_enum(filters.status) if filters.status else None,
128
+ )
129
+
130
130
  def __init__(
131
131
  self,
132
132
  mission_id: str,
@@ -172,7 +172,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
172
172
  metadata_struct.update(file.metadata)
173
173
  upload_files.append(
174
174
  filesystem_pb2.UploadFileData(
175
- context=self.setup_id,
175
+ context=self.mission_id,
176
176
  name=file.name,
177
177
  file_type=self._file_type_to_enum(file.file_type),
178
178
  content_type=file.content_type or "application/octet-stream",
@@ -191,6 +191,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
191
191
  def get_file(
192
192
  self,
193
193
  file_id: str,
194
+ context: Literal["mission", "setup"] = "mission",
194
195
  *,
195
196
  include_content: bool = False,
196
197
  ) -> FilesystemRecord:
@@ -198,6 +199,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
198
199
 
199
200
  Args:
200
201
  file_id: The ID of the file to be retrieved
202
+ context: The context of the files (mission or setup)
201
203
  include_content: Whether to include file content in response
202
204
 
203
205
  Returns:
@@ -206,9 +208,14 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
206
208
  Raises:
207
209
  FilesystemServiceError: If there is an error retrieving the file
208
210
  """
211
+ match context:
212
+ case "setup":
213
+ context_id = self.setup_id
214
+ case "mission":
215
+ context_id = self.mission_id
209
216
  with GrpcFilesystem._handle_grpc_errors("GetFile"):
210
217
  request = filesystem_pb2.GetFileRequest(
211
- context=self.setup_id,
218
+ context=context_id,
212
219
  file_id=file_id,
213
220
  include_content=include_content,
214
221
  )
@@ -256,7 +263,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
256
263
  """
257
264
  with GrpcFilesystem._handle_grpc_errors("UpdateFile"):
258
265
  request = filesystem_pb2.UpdateFileRequest(
259
- context=self.setup_id,
266
+ context=self.mission_id,
260
267
  file_id=file_id,
261
268
  content=content,
262
269
  file_type=self._file_type_to_enum(file_type) if file_type else None,
@@ -290,7 +297,7 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
290
297
  """
291
298
  with GrpcFilesystem._handle_grpc_errors("DeleteFiles"):
292
299
  request = filesystem_pb2.DeleteFilesRequest(
293
- context=self.setup_id,
300
+ context=self.mission_id,
294
301
  filters=self._filter_to_proto(filters),
295
302
  permanent=permanent,
296
303
  force=force,
@@ -320,9 +327,14 @@ class GrpcFilesystem(FilesystemStrategy, GrpcClientWrapper):
320
327
  Returns:
321
328
  tuple[list[FilesystemRecord], int]: List of files and total count
322
329
  """
330
+ match filters.context:
331
+ case "setup":
332
+ context_id = self.setup_id
333
+ case "mission":
334
+ context_id = self.mission_id
323
335
  with GrpcFilesystem._handle_grpc_errors("GetFiles"):
324
336
  request = filesystem_pb2.GetFilesRequest(
325
- context=self.setup_id,
337
+ context=context_id,
326
338
  filters=self._filter_to_proto(filters),
327
339
  include_content=include_content,
328
340
  list_size=list_size,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: digitalkin
3
- Version: 0.2.20
3
+ Version: 0.2.22
4
4
  Summary: SDK to build kin used in DigitalKin
5
5
  Author-email: "DigitalKin.ai" <contact@digitalkin.ai>
6
6
  License: Attribution-NonCommercial-ShareAlike 4.0 International
@@ -7,13 +7,13 @@ base_server/mock/__init__.py,sha256=YZFT-F1l_TpvJYuIPX-7kTeE1CfOjhx9YmNRXVoi-jQ,
7
7
  base_server/mock/mock_pb2.py,sha256=sETakcS3PAAm4E-hTCV1jIVaQTPEAIoVVHupB8Z_k7Y,1843
8
8
  base_server/mock/mock_pb2_grpc.py,sha256=BbOT70H6q3laKgkHfOx1QdfmCS_HxCY4wCOX84YAdG4,3180
9
9
  digitalkin/__init__.py,sha256=7LLBAba0th-3SGqcpqFO-lopWdUkVLKzLZiMtB-mW3M,162
10
- digitalkin/__version__.py,sha256=xyy1KDxstIdKxcpHjRqocBqBoSJHYg0P7CqiadzMtOo,191
10
+ digitalkin/__version__.py,sha256=Fv41tGy4IXZqByuVB-6U6fI-NrUwsO6YXQ_VYoZtjmE,191
11
11
  digitalkin/logger.py,sha256=cFbIAZHOFx3nddOssRNYLXyqUPzR4CgDR_c-5wmB-og,1685
12
12
  digitalkin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  digitalkin/grpc_servers/__init__.py,sha256=0cJBlwipSmFdXkyH3T0i6OJ1WpAtNsZgYX7JaSnkbtg,804
14
14
  digitalkin/grpc_servers/_base_server.py,sha256=NXnnZPjJqUDWoumhEbb7EOEWB7d8XYwpQs-l97NTe4k,18647
15
15
  digitalkin/grpc_servers/module_server.py,sha256=hOvoY2XFjxmgkbAsMex5a-m7OPyljnz0Gh9BJxtDtJo,10259
16
- digitalkin/grpc_servers/module_servicer.py,sha256=L7xzrFChGNUNdUGylmTz0Uy73gGWvjSp5nesI3Z-mC0,18547
16
+ digitalkin/grpc_servers/module_servicer.py,sha256=dnEozIDwkAoinh3lIbT3ZJ9YANlghC3iiQKNYFNHmTI,18805
17
17
  digitalkin/grpc_servers/registry_server.py,sha256=StY18DKYoPKQIU1SIzgito6D4_QA1aMVddZ8O2WGlHY,2223
18
18
  digitalkin/grpc_servers/registry_servicer.py,sha256=dqsKGHZ0LnaIvGt4ipaAuigd37sbJBndT4MAT029GsY,16471
19
19
  digitalkin/grpc_servers/utils/exceptions.py,sha256=SyOgvjggaUECYmSiqy8KJLHwHVt5IClSTxslHM-IZzI,931
@@ -51,9 +51,9 @@ digitalkin/services/cost/cost_strategy.py,sha256=MpPX33P_S5b2by6F4zT-rcyeRuh2V4N
51
51
  digitalkin/services/cost/default_cost.py,sha256=XE7kNFde8NmbulU9m1lc3mi-vHFkbaJf0XHUc0D4UHE,3945
52
52
  digitalkin/services/cost/grpc_cost.py,sha256=cGtb0atPXSEEOrNIWee-o3ScfNRSAFXJGDu0vcWT6zg,6295
53
53
  digitalkin/services/filesystem/__init__.py,sha256=BhwMl_BUvM0d65fmglkp0SVwn3RfYiUOKJgIMnOCaGM,381
54
- digitalkin/services/filesystem/default_filesystem.py,sha256=3chjexNaAP8_t5RT6SvHjO1w5kKv5ZZp8kMocvFt-9U,15088
55
- digitalkin/services/filesystem/filesystem_strategy.py,sha256=k2hujknNnQwUktJKUuXU_COv-eGJuMJpe1gVkikWYVY,9223
56
- digitalkin/services/filesystem/grpc_filesystem.py,sha256=NB415FFWOSZDvzgFAhji7VVXG8zXCSspY3R0JZSUbWw,12550
54
+ digitalkin/services/filesystem/default_filesystem.py,sha256=qfC4jorfo86fBBnth-4ft13VuaGdvIHgWOVurCykXIk,15182
55
+ digitalkin/services/filesystem/filesystem_strategy.py,sha256=zibVLvX_IBQ-kgh-KYzHdszDeiHFPEAZszu_k99x1GQ,9487
56
+ digitalkin/services/filesystem/grpc_filesystem.py,sha256=ilxTFjelmf8_bVSs3xLlsyWFHVlSJf27c4j8H7R1Rkw,12987
57
57
  digitalkin/services/identity/__init__.py,sha256=InkeyLgFYYwItx8mePA8HpfacOMWZwwuc0G4pWtKq9s,270
58
58
  digitalkin/services/identity/default_identity.py,sha256=Y2auZHrGSZTIN5D8HyjLvLcNbYFM1CNUE23x7p5VIGw,386
59
59
  digitalkin/services/identity/identity_strategy.py,sha256=skappBbds1_qa0Gr24FGrNX1N0_OYhYT1Lh7dUaAirE,429
@@ -76,14 +76,14 @@ digitalkin/utils/arg_parser.py,sha256=nvjI1pKDY1HfS0oGcMQPtdTQcggXLtpxXMbnMxNEKR
76
76
  digitalkin/utils/development_mode_action.py,sha256=TqRuAF_A7bDD4twRB4PnZcRoNeaiAnEdxM5kvy4aoaA,1511
77
77
  digitalkin/utils/llm_ready_schema.py,sha256=JjMug_lrQllqFoanaC091VgOqwAd-_YzcpqFlS7p778,2375
78
78
  digitalkin/utils/package_discover.py,sha256=3e9-6Vf3yAAv2VkHHVK4QVqHJBxQqg3d8uuDTsXph24,13471
79
- digitalkin-0.2.20.dist-info/licenses/LICENSE,sha256=Ies4HFv2r2hzDRakJYxk3Y60uDFLiG-orIgeTpstnIo,20327
79
+ digitalkin-0.2.22.dist-info/licenses/LICENSE,sha256=Ies4HFv2r2hzDRakJYxk3Y60uDFLiG-orIgeTpstnIo,20327
80
80
  modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
81
  modules/cpu_intensive_module.py,sha256=ejB9XPnFfA0uCuFUQbM3fy5UYfqqAlF36rv_P5Ri8ho,8363
82
82
  modules/minimal_llm_module.py,sha256=Ijld__ZnhzfLwpXD1XVkLZ7jyKZKyOFZczOpiPttJZc,11216
83
83
  modules/text_transform_module.py,sha256=bwPSnEUthZQyfLwcTLo52iAxItAoknkLh8Y3m5aywaY,7251
84
84
  services/filesystem_module.py,sha256=71Mcja8jCQqiqFHPdsIXplFIHTvgkxRhp0TRXuCfgkk,7430
85
85
  services/storage_module.py,sha256=ybTMqmvGaTrR8PqJ4FU0cwxaDjT36TskVrGoetTGmno,6955
86
- digitalkin-0.2.20.dist-info/METADATA,sha256=2sPBkq_RDcLjtEe_BGZHPYJSWsYRzYXwDrDLaEOd_-c,30579
87
- digitalkin-0.2.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
88
- digitalkin-0.2.20.dist-info/top_level.txt,sha256=gcjqlyrZuLjIyxrOIavCQM_olpr6ND5kPKkZd2j0xGo,40
89
- digitalkin-0.2.20.dist-info/RECORD,,
86
+ digitalkin-0.2.22.dist-info/METADATA,sha256=3GGfNJVjNOaH-Zw9q4bK0Db345xqTrDzzQvgfygihnU,30579
87
+ digitalkin-0.2.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
88
+ digitalkin-0.2.22.dist-info/top_level.txt,sha256=gcjqlyrZuLjIyxrOIavCQM_olpr6ND5kPKkZd2j0xGo,40
89
+ digitalkin-0.2.22.dist-info/RECORD,,