modaic 0.2.0__py3-none-any.whl → 0.3.0__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 modaic might be problematic. Click here for more details.

modaic/module_utils.py CHANGED
@@ -243,6 +243,12 @@ def init_agent_repo(repo_path: str, with_code: bool = True) -> Path:
243
243
  if src_init.exists() and not dest_init.exists():
244
244
  shutil.copy2(src_init, dest_init)
245
245
 
246
+ for extra_file in get_extra_files():
247
+ if extra_file.is_dir():
248
+ shutil.copytree(extra_file, repo_dir / extra_file.relative_to(project_root))
249
+ else:
250
+ shutil.copy2(extra_file, repo_dir / extra_file.relative_to(project_root))
251
+
246
252
  return repo_dir
247
253
 
248
254
 
@@ -272,23 +278,52 @@ def get_ignored_files() -> list[Path]:
272
278
  pyproject_path = Path("pyproject.toml")
273
279
  doc = tomlk.parse(pyproject_path.read_text(encoding="utf-8"))
274
280
 
275
- # Safely get [tool.modaic.ignore]
276
- ignore_table = (
281
+ # Safely get [tool.modaic.exclude]
282
+ files = (
277
283
  doc.get("tool", {}) # [tool]
278
284
  .get("modaic", {}) # [tool.modaic]
279
- .get("ignore") # [tool.modaic.ignore]
285
+ .get("exclude", {}) # [tool.modaic.exclude]
286
+ .get("files", []) # [tool.modaic.exclude] files = ["file1", "file2"]
280
287
  )
281
288
 
282
- if ignore_table is None or "files" not in ignore_table:
283
- return []
289
+ excluded: list[Path] = []
290
+ for entry in files:
291
+ entry = Path(entry)
292
+ if not entry.is_absolute():
293
+ entry = project_root / entry
294
+ if entry.exists():
295
+ excluded.append(entry)
296
+ return excluded
284
297
 
285
- ignored: list[Path] = []
286
- for entry in ignore_table["files"]:
287
- try:
288
- ignored.append((project_root / entry).resolve())
289
- except OSError:
290
- continue
291
- return ignored
298
+
299
+ def get_extra_files() -> list[Path]:
300
+ """Return a list of extra files that should be excluded from staging."""
301
+ project_root = resolve_project_root()
302
+ pyproject_path = Path("pyproject.toml")
303
+ doc = tomlk.parse(pyproject_path.read_text(encoding="utf-8"))
304
+ files = (
305
+ doc.get("tool", {}) # [tool]
306
+ .get("modaic", {}) # [tool.modaic]
307
+ .get("include", {}) # [tool.modaic.include]
308
+ .get("files", []) # [tool.modaic.include] files = ["file1", "file2"]
309
+ )
310
+ included: list[Path] = []
311
+ for entry in files:
312
+ entry = Path(entry)
313
+ if entry.is_absolute():
314
+ try:
315
+ entry = entry.resolve()
316
+ entry.relative_to(project_root.resolve())
317
+ except ValueError:
318
+ warnings.warn(
319
+ f"{entry} will not be bundled because it is not inside the current working directory", stacklevel=4
320
+ )
321
+ else:
322
+ entry = project_root / entry
323
+ if entry.resolve().exists():
324
+ included.append(entry)
325
+
326
+ return included
292
327
 
293
328
 
294
329
  def create_pyproject_toml(repo_dir: Path, package_name: str):
@@ -304,7 +339,7 @@ def create_pyproject_toml(repo_dir: Path, package_name: str):
304
339
  if "project" not in doc_old:
305
340
  raise KeyError("No [project] table in old TOML")
306
341
  doc_new["project"] = doc_old["project"]
307
- doc_new["project"]["dependencies"] = get_filtered_dependencies(doc_old["project"]["dependencies"])
342
+ doc_new["project"]["dependencies"] = get_final_dependencies(doc_old["project"]["dependencies"])
308
343
  if "tool" in doc_old and "uv" in doc_old["tool"] and "sources" in doc_old["tool"]["uv"]:
309
344
  doc_new["tool"] = {"uv": {"sources": doc_old["tool"]["uv"]["sources"]}}
310
345
  warn_if_local(doc_new["tool"]["uv"]["sources"])
@@ -315,29 +350,32 @@ def create_pyproject_toml(repo_dir: Path, package_name: str):
315
350
  tomlk.dump(doc_new, fp)
316
351
 
317
352
 
318
- def get_filtered_dependencies(dependencies: list[str]) -> list[str]:
353
+ def get_final_dependencies(dependencies: list[str]) -> list[str]:
319
354
  """
320
355
  Get the dependencies that should be included in the bundled agent.
356
+ Filters out "[tool.modaic.ignore] dependencies. Adds [tool.modaic.include] dependencies.
321
357
  """
322
358
  pyproject_path = Path("pyproject.toml")
323
359
  doc = tomlk.parse(pyproject_path.read_text(encoding="utf-8"))
324
360
 
325
- # Safely get [tool.modaic.ignore]
326
- ignore_table = (
361
+ # Safely get [tool.modaic.exclude]
362
+ exclude_deps = (
327
363
  doc.get("tool", {}) # [tool]
328
364
  .get("modaic", {}) # [tool.modaic]
329
- .get("ignore", {}) # [tool.modaic.ignore]
365
+ .get("exclude", {}) # [tool.modaic.exclude]
366
+ .get("dependencies", []) # [tool.modaic.exclude] dependencies = ["praw", "sagemaker"]
367
+ )
368
+ include_deps = (
369
+ doc.get("tool", {}) # [tool]
370
+ .get("modaic", {}) # [tool.modaic]
371
+ .get("include", {}) # [tool.modaic.include]
372
+ .get("dependencies", []) # [tool.modaic.include] dependencies = ["praw", "sagemaker"]
330
373
  )
331
374
 
332
- if "dependencies" not in ignore_table:
333
- return dependencies
334
-
335
- ignored_dependencies = ignore_table["dependencies"]
336
- if not ignored_dependencies:
337
- return dependencies
338
- pattern = re.compile(r"\b(" + "|".join(map(re.escape, ignored_dependencies)) + r")\b")
339
- filtered_dependencies = [pkg for pkg in dependencies if not pattern.search(pkg)]
340
- return filtered_dependencies
375
+ if exclude_deps:
376
+ pattern = re.compile(r"\b(" + "|".join(map(re.escape, exclude_deps)) + r")\b")
377
+ dependencies = [pkg for pkg in dependencies if not pattern.search(pkg)]
378
+ return dependencies + include_deps
341
379
 
342
380
 
343
381
  def warn_if_local(sources: dict[str, dict]):
modaic/precompiled.py CHANGED
@@ -128,6 +128,7 @@ class PrecompiledConfig(BaseModel):
128
128
  return self.model_dump_json()
129
129
 
130
130
 
131
+ # Use a metaclass to enforce super().__init__() with config
131
132
  class PrecompiledAgent(dspy.Module):
132
133
  """
133
134
  Bases: `dspy.Module`
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modaic
3
- Version: 0.2.0
4
- Summary: Modular Agent Infrastructure Collective, a python framework for managing and sharing DSPy agents
3
+ Version: 0.3.0
4
+ Summary: Modular Agent Infrastructure Collection, a python framework for managing and sharing DSPy agents
5
5
  Author-email: Tyrin <tytodd@mit.edu>, Farouk <farouk@modaic.dev>
6
6
  License: MIT License
7
7
 
@@ -4,9 +4,9 @@ modaic/datasets.py,sha256=K-PpPSYIxJI0-yH-SBVpk_EfCM9i_uPz-brmlzP7hzI,513
4
4
  modaic/exceptions.py,sha256=XxzxOWjZTzT3l1BqTr7coJnVGxJq53uppRNrqP__YGo,651
5
5
  modaic/hub.py,sha256=d5HQjaE26K1qNCBc32qJtrpESyRv6OiniAteasiN_rk,11290
6
6
  modaic/indexing.py,sha256=VdILiXiLVzgV1pSTV8Ho7x1dZtd31Y9z60d_Qtqr2NU,4195
7
- modaic/module_utils.py,sha256=oJUOddvNGEIvEABOf7rzMB9erOkjDPm7FWLaBJ0XTSA,11797
7
+ modaic/module_utils.py,sha256=I6kGCmGSuHM9lxz8rpCIkdFHCh0M7OIyw3GZ3966YWY,13442
8
8
  modaic/observability.py,sha256=LgR4gJM4DhD-xlVX52mzRQSPgLQzbeh2LYPmQVqSh-A,9947
9
- modaic/precompiled.py,sha256=cLRNoDB_ivawGftDpWQbkjjThrtID7bG1E-XVxi5kEM,14804
9
+ modaic/precompiled.py,sha256=_FwosgvItwnliVOc6nUp15RaBinmo1tTYhR9haun020,14864
10
10
  modaic/query_language.py,sha256=BJIigR0HLapiIn9fF7jM7PkLM8OWUDjwYuxmzcCVvyo,9487
11
11
  modaic/types.py,sha256=gcx8J4oxrHwxA7McyYV4OKHsuPhhmowJtJIgjJQbLto,10081
12
12
  modaic/utils.py,sha256=doJs-XL4TswSQFBINZeKrik-cvjZk-tS9XmWH8fOYiw,794
@@ -33,8 +33,8 @@ modaic/databases/vector_database/vendors/qdrant.py,sha256=AbpHGcgLb-kRsJGnwFEktk
33
33
  modaic/storage/__init__.py,sha256=Zs-Y_9jfYUE8XVp8z-El0ZXFM_ZVMqM9aQ6fgGPZsf8,131
34
34
  modaic/storage/file_store.py,sha256=kSS7gTP_-16wR3Xgq3frF1BZ8Dw8N--kG4V9rrCXPcc,7315
35
35
  modaic/storage/pickle_store.py,sha256=fu9jkmmKNE852Y4R1NhOFePLfd2gskhHSXxuq1G1S3I,778
36
- modaic-0.2.0.dist-info/licenses/LICENSE,sha256=7LMx9j453Vz1DoQbFot8Uhp9SExF5wlOx7c8vw2qhsE,1333
37
- modaic-0.2.0.dist-info/METADATA,sha256=71CN4H1DdXoN4f-ahbju8JqUaTU4zagjm-E__nIwesY,8651
38
- modaic-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
- modaic-0.2.0.dist-info/top_level.txt,sha256=RXWGuF-TsW8-17DveTJMPRiAgg_Rf2mq5F3R7tNu6t8,7
40
- modaic-0.2.0.dist-info/RECORD,,
36
+ modaic-0.3.0.dist-info/licenses/LICENSE,sha256=7LMx9j453Vz1DoQbFot8Uhp9SExF5wlOx7c8vw2qhsE,1333
37
+ modaic-0.3.0.dist-info/METADATA,sha256=Cw0LkkLDfVGdxif1ZSx9HI9q9c5HSIuzDI-VVWRFRO4,8651
38
+ modaic-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
+ modaic-0.3.0.dist-info/top_level.txt,sha256=RXWGuF-TsW8-17DveTJMPRiAgg_Rf2mq5F3R7tNu6t8,7
40
+ modaic-0.3.0.dist-info/RECORD,,
File without changes