aiqtoolkit 1.2.0a20250803__py3-none-any.whl → 1.2.0a20250806__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 aiqtoolkit might be problematic. Click here for more details.

@@ -21,6 +21,7 @@ import typing
21
21
  from enum import Enum
22
22
  from functools import lru_cache
23
23
  from pathlib import Path
24
+ from types import ModuleType
24
25
  from typing import TYPE_CHECKING
25
26
 
26
27
  from pydantic import BaseModel
@@ -115,6 +116,55 @@ class DiscoveryMetadata(BaseModel):
115
116
  return data.get(root_package, None)
116
117
  return None
117
118
 
119
+ @staticmethod
120
+ @lru_cache
121
+ def get_distribution_name_from_module(module: ModuleType | None) -> str:
122
+ """Get the distribution name from the config type using the mapping of module names to distro names.
123
+
124
+ Args:
125
+ module (ModuleType): A registered component's module.
126
+
127
+ Returns:
128
+ str: The distribution name of the AIQ Toolkit component.
129
+ """
130
+ from aiq.runtime.loader import get_all_aiq_entrypoints_distro_mapping
131
+
132
+ if module is None:
133
+ return "aiqtoolkit"
134
+
135
+ # Get the mapping of module names to distro names
136
+ mapping = get_all_aiq_entrypoints_distro_mapping()
137
+ module_package = module.__package__
138
+
139
+ if module_package is None:
140
+ return "aiqtoolkit"
141
+
142
+ # Traverse the module package parts in reverse order to find the distro name
143
+ # This is because the module package is the root package for the AIQ Toolkit component
144
+ # and the distro name is the name of the package that contains the component
145
+ module_package_parts = module_package.split(".")
146
+ for part_idx in range(len(module_package_parts), 0, -1):
147
+ candidate_module_name = ".".join(module_package_parts[0:part_idx])
148
+ candidate_distro_name = mapping.get(candidate_module_name, None)
149
+ if candidate_distro_name is not None:
150
+ return candidate_distro_name
151
+
152
+ return "aiqtoolkit"
153
+
154
+ @staticmethod
155
+ @lru_cache
156
+ def get_distribution_name_from_config_type(config_type: type["TypedBaseModelT"]) -> str:
157
+ """Get the distribution name from the config type using the mapping of module names to distro names.
158
+
159
+ Args:
160
+ config_type (type[TypedBaseModelT]): A registered component's configuration object.
161
+
162
+ Returns:
163
+ str: The distribution name of the AIQ Toolkit component.
164
+ """
165
+ module = inspect.getmodule(config_type)
166
+ return DiscoveryMetadata.get_distribution_name_from_module(module)
167
+
118
168
  @staticmethod
119
169
  @lru_cache
120
170
  def get_distribution_name(root_package: str) -> str:
@@ -123,6 +173,7 @@ class DiscoveryMetadata(BaseModel):
123
173
  root package name 'aiq'. They provide mapping in a metadata file
124
174
  for optimized installation.
125
175
  """
176
+
126
177
  distro_name = DiscoveryMetadata.get_distribution_name_from_private_data(root_package)
127
178
  return distro_name if distro_name else root_package
128
179
 
@@ -142,8 +193,7 @@ class DiscoveryMetadata(BaseModel):
142
193
 
143
194
  try:
144
195
  module = inspect.getmodule(config_type)
145
- root_package: str = module.__package__.split(".")[0]
146
- distro_name = DiscoveryMetadata.get_distribution_name(root_package)
196
+ distro_name = DiscoveryMetadata.get_distribution_name_from_config_type(config_type)
147
197
 
148
198
  if not distro_name:
149
199
  # raise an exception
@@ -187,12 +237,13 @@ class DiscoveryMetadata(BaseModel):
187
237
 
188
238
  try:
189
239
  module = inspect.getmodule(fn)
190
- root_package: str = module.__package__.split(".")[0]
191
- root_package = DiscoveryMetadata.get_distribution_name(root_package)
240
+ distro_name = DiscoveryMetadata.get_distribution_name_from_module(module)
241
+
192
242
  try:
193
- version = importlib.metadata.version(root_package) if root_package != "" else ""
243
+ # version = importlib.metadata.version(root_package) if root_package != "" else ""
244
+ version = importlib.metadata.version(distro_name) if distro_name != "" else ""
194
245
  except importlib.metadata.PackageNotFoundError:
195
- logger.warning("Package metadata not found for %s", root_package)
246
+ logger.warning("Package metadata not found for %s", distro_name)
196
247
  version = ""
197
248
  except Exception as e:
198
249
  logger.exception("Encountered issue extracting module metadata for %s: %s", fn, e, exc_info=True)
@@ -201,7 +252,7 @@ class DiscoveryMetadata(BaseModel):
201
252
  if isinstance(wrapper_type, LLMFrameworkEnum):
202
253
  wrapper_type = wrapper_type.value
203
254
 
204
- return DiscoveryMetadata(package=root_package,
255
+ return DiscoveryMetadata(package=distro_name,
205
256
  version=version,
206
257
  component_type=component_type,
207
258
  component_name=wrapper_type,
@@ -220,7 +271,6 @@ class DiscoveryMetadata(BaseModel):
220
271
  """
221
272
 
222
273
  try:
223
- package_name = DiscoveryMetadata.get_distribution_name(package_name)
224
274
  try:
225
275
  metadata = importlib.metadata.metadata(package_name)
226
276
  description = metadata.get("Summary", "")
@@ -263,12 +313,11 @@ class DiscoveryMetadata(BaseModel):
263
313
 
264
314
  try:
265
315
  module = inspect.getmodule(config_type)
266
- root_package: str = module.__package__.split(".")[0]
267
- root_package = DiscoveryMetadata.get_distribution_name(root_package)
316
+ distro_name = DiscoveryMetadata.get_distribution_name_from_module(module)
268
317
  try:
269
- version = importlib.metadata.version(root_package) if root_package != "" else ""
318
+ version = importlib.metadata.version(distro_name) if distro_name != "" else ""
270
319
  except importlib.metadata.PackageNotFoundError:
271
- logger.warning("Package metadata not found for %s", root_package)
320
+ logger.warning("Package metadata not found for %s", distro_name)
272
321
  version = ""
273
322
  except Exception as e:
274
323
  logger.exception("Encountered issue extracting module metadata for %s: %s", config_type, e, exc_info=True)
@@ -279,7 +328,7 @@ class DiscoveryMetadata(BaseModel):
279
328
 
280
329
  description = generate_config_type_docs(config_type=config_type)
281
330
 
282
- return DiscoveryMetadata(package=root_package,
331
+ return DiscoveryMetadata(package=distro_name,
283
332
  version=version,
284
333
  component_type=component_type,
285
334
  component_name=component_name,
@@ -119,16 +119,15 @@ def build_wheel(package_root: str) -> WheelData:
119
119
 
120
120
  whl_version = Wheel(whl_path).version
121
121
 
122
- return WheelData(
123
- package_root=package_root,
124
- package_name=module_name, # should it be module name or distro name here
125
- toml_project=toml_project,
126
- toml_dependencies=toml_dependencies,
127
- toml_aiq_packages=toml_packages,
128
- union_dependencies=union_dependencies,
129
- whl_path=whl_path,
130
- whl_base64=whl_base64,
131
- whl_version=whl_version)
122
+ return WheelData(package_root=package_root,
123
+ package_name=toml_project_name,
124
+ toml_project=toml_project,
125
+ toml_dependencies=toml_dependencies,
126
+ toml_aiq_packages=toml_packages,
127
+ union_dependencies=union_dependencies,
128
+ whl_path=whl_path,
129
+ whl_base64=whl_base64,
130
+ whl_version=whl_version)
132
131
 
133
132
 
134
133
  def build_package_metadata(wheel_data: WheelData | None) -> dict[AIQComponentEnum, list[dict | DiscoveryMetadata]]:
@@ -155,7 +154,7 @@ def build_package_metadata(wheel_data: WheelData | None) -> dict[AIQComponentEnu
155
154
  if (wheel_data is not None):
156
155
  registry.register_package(package_name=wheel_data.package_name, package_version=wheel_data.whl_version)
157
156
  for entry_point in aiq_plugins:
158
- package_name = entry_point.module.split('.')[0]
157
+ package_name = entry_point.dist.name
159
158
  if (package_name == wheel_data.package_name):
160
159
  continue
161
160
  if (package_name in wheel_data.union_dependencies):
@@ -163,8 +162,7 @@ def build_package_metadata(wheel_data: WheelData | None) -> dict[AIQComponentEnu
163
162
 
164
163
  else:
165
164
  for entry_point in aiq_plugins:
166
- package_name = entry_point.module.split('.')[0]
167
- registry.register_package(package_name=package_name)
165
+ registry.register_package(package_name=entry_point.dist.name)
168
166
 
169
167
  discovery_metadata = {}
170
168
  for component_type in AIQComponentEnum:
aiq/runtime/loader.py CHANGED
@@ -21,6 +21,7 @@ import time
21
21
  from contextlib import asynccontextmanager
22
22
  from enum import IntFlag
23
23
  from enum import auto
24
+ from functools import lru_cache
24
25
  from functools import reduce
25
26
 
26
27
  from aiq.builder.workflow_builder import WorkflowBuilder
@@ -116,6 +117,7 @@ async def load_workflow(config_file: StrPath, max_concurrency: int = -1):
116
117
  yield AIQSessionManager(workflow.build(), max_concurrency=max_concurrency)
117
118
 
118
119
 
120
+ @lru_cache
119
121
  def discover_entrypoints(plugin_type: PluginTypes):
120
122
  """
121
123
  Discover all the requested plugin types which were registered via an entry point group and return them.
@@ -143,6 +145,25 @@ def discover_entrypoints(plugin_type: PluginTypes):
143
145
  return aiq_plugins
144
146
 
145
147
 
148
+ @lru_cache
149
+ def get_all_aiq_entrypoints_distro_mapping() -> dict[str, str]:
150
+ """
151
+ Get the mapping of all AIQ entry points to their distribution names.
152
+ """
153
+
154
+ mapping = {}
155
+ aiq_entrypoints = discover_entrypoints(PluginTypes.ALL)
156
+ for ep in aiq_entrypoints:
157
+ ep_module_parts = ep.module.split(".")
158
+ current_parts = []
159
+ for part in ep_module_parts:
160
+ current_parts.append(part)
161
+ module_prefix = ".".join(current_parts)
162
+ mapping[module_prefix] = ep.dist.name
163
+
164
+ return mapping
165
+
166
+
146
167
  def discover_and_register_plugins(plugin_type: PluginTypes):
147
168
  """
148
169
  Discover all the requested plugin types which were registered via an entry point group and register them into the
@@ -0,0 +1,32 @@
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 argparse
17
+ import json
18
+
19
+ from aiq.runtime.loader import get_all_aiq_entrypoints_distro_mapping
20
+
21
+
22
+ def dump_distro_mapping(path: str):
23
+ mapping = get_all_aiq_entrypoints_distro_mapping()
24
+ with open(path, "w", encoding="utf-8") as f:
25
+ json.dump(mapping, f, indent=4)
26
+
27
+
28
+ if __name__ == "__main__":
29
+ parser = argparse.ArgumentParser()
30
+ parser.add_argument("--path", type=str, required=True)
31
+ args = parser.parse_args()
32
+ dump_distro_mapping(args.path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiqtoolkit
3
- Version: 1.2.0a20250803
3
+ Version: 1.2.0a20250806
4
4
  Summary: NVIDIA Agent Intelligence toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -103,7 +103,7 @@ aiq/data_models/component.py,sha256=_HeHlDmz2fgJlVfmz0tG_yCyes86hQNaQwSWz1FDQvk,
103
103
  aiq/data_models/component_ref.py,sha256=_6DeNWJSHN3GSoAFe0RCQkCJ31_WA9GR3nP6vsxMj7Q,4594
104
104
  aiq/data_models/config.py,sha256=I7-9kJqpr6IvqmTU4nnALjDmq8YRlrKhYzq6g7DrJeo,17124
105
105
  aiq/data_models/dataset_handler.py,sha256=liMB3xRohkr4VTMmNWPvWi9qhbhlJQfQK36g5Rknweo,4027
106
- aiq/data_models/discovery_metadata.py,sha256=OcITQc5VeML4bTHurrsMNiK_oB3z7wudMxcyN7LI8pY,12785
106
+ aiq/data_models/discovery_metadata.py,sha256=ycrLQ2HTT4lOFZJGwvvGfXPAFRswygmNUWW0nKFNtHg,14662
107
107
  aiq/data_models/embedder.py,sha256=nPhthEQDtzAMGd8gFRB1ZfJpN5M9DJvv0h28ohHnTmI,1002
108
108
  aiq/data_models/evaluate.py,sha256=WBeABZsIa6W04MPj24SRu4s-ty2PkJ7_4SLojXmj5Pk,4704
109
109
  aiq/data_models/evaluator.py,sha256=bd2njsyQB2t6ClJ66gJiCjYHsQpWZwPD7rsU0J109TI,939
@@ -324,7 +324,7 @@ aiq/profiler/inference_optimization/experimental/concurrency_spike_analysis.py,s
324
324
  aiq/profiler/inference_optimization/experimental/prefix_span_analysis.py,sha256=nD46SCVi7zwxdPXRN5c61O58_OgMA2WCfaZdRJRqgP4,16600
325
325
  aiq/registry_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
326
326
  aiq/registry_handlers/metadata_factory.py,sha256=Urr_7mLLpoU0VPjl2Nknl9aZhzaAAwb66ydTGBBrIwc,2778
327
- aiq/registry_handlers/package_utils.py,sha256=WCENHOO55Vhwv9DbLYjR9SMu_ERzxMKX6oO9ywe9cpM,7468
327
+ aiq/registry_handlers/package_utils.py,sha256=waCWoW351EACof5NS1l8VKued03pknArRub8kHW2nM0,7459
328
328
  aiq/registry_handlers/register.py,sha256=k2gvV0htVpfMdzsRvZGnTZp17JA2Na8sO9ocMaxDSmo,902
329
329
  aiq/registry_handlers/registry_handler_base.py,sha256=BYLH6R9y3pySBDH9HKUR16rM0atFRt594IDyyhgCQVQ,5842
330
330
  aiq/registry_handlers/local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -355,7 +355,7 @@ aiq/retriever/nemo_retriever/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W
355
355
  aiq/retriever/nemo_retriever/register.py,sha256=ODV-TZfXzDs1VJHHLdj2kC05odirtlQZSeh9c1zw8AQ,2893
356
356
  aiq/retriever/nemo_retriever/retriever.py,sha256=IvScUr9XuDLiMR__I3QsboLaM52N5D5Qu94qtTOGQw8,6958
357
357
  aiq/runtime/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
358
- aiq/runtime/loader.py,sha256=drLE-OnrAPjFgWrQ3ZsnhHSbon8GkRsUk0p7Oe8Jn2I,7117
358
+ aiq/runtime/loader.py,sha256=F_CHLj3KR8PBxzqu1sy70JLyNBDFG55bFm9kVNGoSdM,7707
359
359
  aiq/runtime/runner.py,sha256=CqmlVAYfrBh3ml3t2n3V693RaNyxtK9ScWT4S-Isbr8,6365
360
360
  aiq/runtime/session.py,sha256=i1pIqopZCBgGJqVUskKLiBnZYH-lTdMhvFu56dXAU5A,6206
361
361
  aiq/runtime/user_metadata.py,sha256=9EiBc-EEJzOdpf3Q1obHqAdY_kRlJ1T0TVvY0Jonk6o,3692
@@ -400,6 +400,7 @@ aiq/tool/memory_tools/delete_memory_tool.py,sha256=wdB_I8y-1D1OpNtBi6ZOg36vvNkba
400
400
  aiq/tool/memory_tools/get_memory_tool.py,sha256=-i0Bt5xYeapbbd2wtAgPc0pOv0Dx4jK1-yyHG7YCeQ0,2749
401
401
  aiq/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
402
402
  aiq/utils/debugging_utils.py,sha256=6M4JhbHDNDnfmSRGmHvT5IgEeWSHBore3VngdE_PMqc,1332
403
+ aiq/utils/dump_distro_mapping.py,sha256=5I3IGsmhoW12VZrInxx9CyyVSEtRmhRyo1bSdJJUj-o,1155
403
404
  aiq/utils/log_utils.py,sha256=dZLHt7qFqLlpPqMMFO9UVtSkOpMjFwz9tkmbAfOiNlg,1355
404
405
  aiq/utils/metadata_utils.py,sha256=lGYvc8Gk0az4qZDGeRbVz4L7B_b-Gnjss8JT4goqL5I,2897
405
406
  aiq/utils/optional_imports.py,sha256=jQSVBc2fBSRw-2d6r8cEwvh5-di2EUUPakuuo9QbbwA,4039
@@ -428,10 +429,10 @@ aiq/utils/reactive/base/observer_base.py,sha256=UAlyAY_ky4q2t0P81RVFo2Bs_R7z5Nde
428
429
  aiq/utils/reactive/base/subject_base.py,sha256=Ed-AC6P7cT3qkW1EXjzbd5M9WpVoeN_9KCe3OM3FLU4,2521
429
430
  aiq/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
430
431
  aiq/utils/settings/global_settings.py,sha256=U9TCLdoZsKq5qOVGjREipGVv9e-FlStzqy5zv82_VYk,7454
431
- aiqtoolkit-1.2.0a20250803.dist-info/licenses/LICENSE-3rd-party.txt,sha256=8o7aySJa9CBvFshPcsRdJbczzdNyDGJ8b0J67WRUQ2k,183936
432
- aiqtoolkit-1.2.0a20250803.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
433
- aiqtoolkit-1.2.0a20250803.dist-info/METADATA,sha256=5pB_ls9-qYsouughtqE9OZMND7Q92kPgGZQEuYZXGzE,21564
434
- aiqtoolkit-1.2.0a20250803.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
435
- aiqtoolkit-1.2.0a20250803.dist-info/entry_points.txt,sha256=iZR3yrf1liXfbcLqn5_pUkLhZyr1bUw_Qh1d2i7gsv4,625
436
- aiqtoolkit-1.2.0a20250803.dist-info/top_level.txt,sha256=fo7AzYcNhZ_tRWrhGumtxwnxMew4xrT1iwouDy_f0Kc,4
437
- aiqtoolkit-1.2.0a20250803.dist-info/RECORD,,
432
+ aiqtoolkit-1.2.0a20250806.dist-info/licenses/LICENSE-3rd-party.txt,sha256=8o7aySJa9CBvFshPcsRdJbczzdNyDGJ8b0J67WRUQ2k,183936
433
+ aiqtoolkit-1.2.0a20250806.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
434
+ aiqtoolkit-1.2.0a20250806.dist-info/METADATA,sha256=aJrMPRk-wxuTuU-u_mo3nrAoPy6OnYFAgmxk8BJTLb4,21564
435
+ aiqtoolkit-1.2.0a20250806.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
436
+ aiqtoolkit-1.2.0a20250806.dist-info/entry_points.txt,sha256=iZR3yrf1liXfbcLqn5_pUkLhZyr1bUw_Qh1d2i7gsv4,625
437
+ aiqtoolkit-1.2.0a20250806.dist-info/top_level.txt,sha256=fo7AzYcNhZ_tRWrhGumtxwnxMew4xrT1iwouDy_f0Kc,4
438
+ aiqtoolkit-1.2.0a20250806.dist-info/RECORD,,