arcade-core 3.2.0__tar.gz → 3.3.1__tar.gz

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.
Files changed (29) hide show
  1. {arcade_core-3.2.0 → arcade_core-3.3.1}/PKG-INFO +1 -1
  2. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/catalog.py +7 -2
  3. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/toolkit.py +20 -0
  4. {arcade_core-3.2.0 → arcade_core-3.3.1}/pyproject.toml +1 -1
  5. {arcade_core-3.2.0 → arcade_core-3.3.1}/.gitignore +0 -0
  6. {arcade_core-3.2.0 → arcade_core-3.3.1}/README.md +0 -0
  7. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/__init__.py +0 -0
  8. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/annotations.py +0 -0
  9. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/auth.py +0 -0
  10. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/config.py +0 -0
  11. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/config_model.py +0 -0
  12. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/constants.py +0 -0
  13. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/context.py +0 -0
  14. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/converters/openai.py +0 -0
  15. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/discovery.py +0 -0
  16. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/errors.py +0 -0
  17. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/executor.py +0 -0
  18. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/output.py +0 -0
  19. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/parse.py +0 -0
  20. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/py.typed +0 -0
  21. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/schema.py +0 -0
  22. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/__init__.py +0 -0
  23. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/__main__.py +0 -0
  24. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/constants.py +0 -0
  25. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/identity.py +0 -0
  26. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/usage_service.py +0 -0
  27. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/usage/utils.py +0 -0
  28. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/utils.py +0 -0
  29. {arcade_core-3.2.0 → arcade_core-3.3.1}/arcade_core/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arcade-core
3
- Version: 3.2.0
3
+ Version: 3.3.1
4
4
  Summary: Arcade Core - Core library for Arcade platform
5
5
  Author-email: Arcade <dev@arcade.dev>
6
6
  License: MIT
@@ -255,11 +255,17 @@ class ToolCatalog(BaseModel):
255
255
  output_model=output_model,
256
256
  )
257
257
 
258
- def add_module(self, module: ModuleType) -> None:
258
+ def add_module(self, module: ModuleType, name: str | None = None) -> None:
259
259
  """
260
260
  Add all the tools in a module to the catalog.
261
+
262
+ Args:
263
+ module: The module to add.
264
+ name: Optionally override the name of the toolkit with this parameter
261
265
  """
262
266
  toolkit = Toolkit.from_module(module)
267
+ if name:
268
+ toolkit.name = name
263
269
  self.add_toolkit(toolkit)
264
270
 
265
271
  def add_toolkit(self, toolkit: Toolkit) -> None:
@@ -277,7 +283,6 @@ class ToolCatalog(BaseModel):
277
283
  module = import_module(module_name)
278
284
  tool_func = getattr(module, tool_name)
279
285
  self.add_tool(tool_func, toolkit, module)
280
-
281
286
  except ToolDefinitionError as e:
282
287
  raise e.with_context(tool_name) from e
283
288
  except ToolkitLoadError as e:
@@ -1,7 +1,9 @@
1
+ import contextlib
1
2
  import importlib.metadata
2
3
  import importlib.util
3
4
  import logging
4
5
  import os
6
+ import sys
5
7
  import types
6
8
  from collections import defaultdict
7
9
  from pathlib import Path, PurePosixPath, PureWindowsPath
@@ -293,9 +295,27 @@ class Toolkit(BaseModel):
293
295
  f"Failed to locate Python files in package directory for '{package_name}'."
294
296
  ) from e
295
297
 
298
+ # Get the currently executing file (the entrypoint file) so that we can skip it when loading tools.
299
+ # Skipping this file is necessary because tools are discovered via AST parsing, but those tools
300
+ # aren't in the module's namespace yet since the file is still executing.
301
+ current_file = None
302
+ main_module = sys.modules.get("__main__")
303
+ if main_module and hasattr(main_module, "__file__") and main_module.__file__:
304
+ with contextlib.suppress(Exception):
305
+ current_file = Path(main_module.__file__).resolve()
306
+
296
307
  tools: dict[str, list[str]] = {}
297
308
 
298
309
  for module_path in modules:
310
+ # Skip adding tools from the currently executing file
311
+ if current_file:
312
+ try:
313
+ module_path_resolved = module_path.resolve()
314
+ if module_path_resolved == current_file:
315
+ continue
316
+ except Exception: # noqa: S110
317
+ pass
318
+
299
319
  relative_path = module_path.relative_to(package_dir)
300
320
  cls.validate_file(module_path)
301
321
  # Build import path and avoid duplicating the package prefix if it already exists
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "arcade-core"
3
- version = "3.2.0"
3
+ version = "3.3.1"
4
4
  description = "Arcade Core - Core library for Arcade platform"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
File without changes
File without changes