agentomics 1.0.2__tar.gz → 1.0.4__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 (78) hide show
  1. {agentomics-1.0.2/src/agentomics.egg-info → agentomics-1.0.4}/PKG-INFO +1 -1
  2. agentomics-1.0.4/src/agentomics/__init__.py +1 -0
  3. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/docker_utils.py +11 -0
  4. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/inference.py +20 -5
  5. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/run.py +36 -23
  6. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/create_datasets.py +5 -5
  7. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/csv_converter.py +5 -5
  8. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/data_contract.py +8 -4
  9. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/dataset_preparation.py +11 -11
  10. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/run_agent_interactive.py +6 -0
  11. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/evaluate.py +12 -4
  12. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/filesystem.py +6 -0
  13. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/generate_final_reports.py +68 -20
  14. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/inference_workflow.py +4 -12
  15. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/read_write_utils.py +2 -0
  16. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/config.py +1 -1
  17. {agentomics-1.0.2 → agentomics-1.0.4/src/agentomics.egg-info}/PKG-INFO +1 -1
  18. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_agent_permissions.py +3 -5
  19. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_best_iteration_snapshot_and_splits.py +12 -2
  20. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_forking.py +9 -19
  21. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_gpu_access.py +16 -25
  22. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_run_launcher_container_contract.py +4 -4
  23. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_utils.py +27 -4
  24. agentomics-1.0.2/src/agentomics/__init__.py +0 -1
  25. {agentomics-1.0.2 → agentomics-1.0.4}/LICENSE +0 -0
  26. {agentomics-1.0.2 → agentomics-1.0.4}/README.md +0 -0
  27. {agentomics-1.0.2 → agentomics-1.0.4}/pyproject.toml +0 -0
  28. {agentomics-1.0.2 → agentomics-1.0.4}/setup.cfg +0 -0
  29. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/__init__.py +0 -0
  30. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/check_dataset.py +0 -0
  31. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/download_dataset.py +0 -0
  32. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/retrain.py +0 -0
  33. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/cli/run_arguments.py +0 -0
  34. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/__init__.py +0 -0
  35. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/datasets_interactive.py +0 -0
  36. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/datasets/label_processing.py +0 -0
  37. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/run_agent.py +0 -0
  38. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/__init__.py +0 -0
  39. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/best_iteration_snapshot.py +0 -0
  40. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/conda_utils.py +0 -0
  41. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/evaluate_result.py +0 -0
  42. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/git_checkpoints.py +0 -0
  43. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/inference_runner.py +0 -0
  44. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/iteration_reports.py +0 -0
  45. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/report_workflow.py +0 -0
  46. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/run_lifecycle.py +0 -0
  47. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/run_workflow.py +0 -0
  48. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/setup_fork.py +0 -0
  49. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/step_outputs.py +0 -0
  50. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/system_resources.py +0 -0
  51. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/runtime/training_workflow.py +0 -0
  52. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/__init__.py +0 -0
  53. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/agent_id.py +0 -0
  54. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/api_keys.py +0 -0
  55. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/exceptions.py +0 -0
  56. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/metrics.py +0 -0
  57. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/metrics_interactive.py +0 -0
  58. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/printing_utils.py +0 -0
  59. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/task_types.py +0 -0
  60. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/text_processing_utils.py +0 -0
  61. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/user_input.py +0 -0
  62. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics/utils/versioning.py +0 -0
  63. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics.egg-info/SOURCES.txt +0 -0
  64. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics.egg-info/dependency_links.txt +0 -0
  65. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics.egg-info/entry_points.txt +0 -0
  66. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics.egg-info/requires.txt +0 -0
  67. {agentomics-1.0.2 → agentomics-1.0.4}/src/agentomics.egg-info/top_level.txt +0 -0
  68. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_bash_lines_collapsing.py +0 -0
  69. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_codex_provider.py +0 -0
  70. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_csv_converter.py +0 -0
  71. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_dataset_extras_and_input_structure.py +0 -0
  72. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_dataset_folder_split_contracts.py +0 -0
  73. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_dataset_preparation_publishing.py +0 -0
  74. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_environment_recreation.py +0 -0
  75. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_pydantic_ai_validators.py +0 -0
  76. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_replace_tool.py +0 -0
  77. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_retry_transport.py +0 -0
  78. {agentomics-1.0.2 → agentomics-1.0.4}/test/test_runtime_lifecycle.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentomics
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Package for running Agentomics - an autonomous agentic system for ML model development
5
5
  Author: Vlastimil Martinek
6
6
  Maintainer-email: Vlastimil Martinek <martinekvlastimil95@gmail.com>
@@ -0,0 +1 @@
1
+ __version__ = "1.0.4"
@@ -4,6 +4,7 @@ import argparse
4
4
  import os
5
5
  import shutil
6
6
  import subprocess
7
+ from pathlib import Path
7
8
 
8
9
  from agentomics.utils.versioning import get_version
9
10
 
@@ -24,6 +25,16 @@ def create_parser(description: str) -> argparse.ArgumentParser:
24
25
  )
25
26
  return parser
26
27
 
28
+ def docker_environment_arguments(*variable_names: str) -> list[str]:
29
+ docker_arguments: list[str] = []
30
+ env_file = Path.cwd() / ".env"
31
+ if env_file.is_file():
32
+ docker_arguments.extend(["--env-file", str(env_file.resolve())])
33
+ for variable_name in variable_names:
34
+ if variable_name in os.environ:
35
+ docker_arguments.extend(["-e", variable_name])
36
+ return docker_arguments
37
+
27
38
  def validate_docker_gpu_access(image: str) -> None:
28
39
  if shutil.which("docker") is None:
29
40
  raise RuntimeError("Missing required command: docker")
@@ -6,10 +6,11 @@ from pathlib import Path
6
6
 
7
7
  from agentomics.cli.docker_utils import (
8
8
  create_parser,
9
+ docker_environment_arguments,
9
10
  run_python_in_docker,
10
11
  )
11
12
 
12
- from agentomics.runtime.inference_workflow import resolve_inference_paths
13
+ from agentomics.runtime.filesystem import resolve_inference_paths
13
14
  from agentomics.utils.config import Config
14
15
 
15
16
  def build_parser() -> argparse.ArgumentParser:
@@ -39,9 +40,10 @@ def build_parser() -> argparse.ArgumentParser:
39
40
  help="Run every archived iteration",
40
41
  )
41
42
  parser.add_argument("--cpu-only", action="store_true", help="Disable GPU access")
43
+ parser.add_argument("--wandb-prefix", help="Enable W&B logging with this prefix; valid WANDB_API_KEY, WANDB_PROJECT_NAME, and WANDB_ENTITY are also required")
42
44
  return parser
43
45
 
44
- def run_inference_in_docker(arguments: argparse.Namespace) -> None:
46
+ def run_inference_in_docker(arguments: argparse.Namespace) -> int:
45
47
  resolve_inference_paths(arguments)
46
48
  container_input = "/inference-input"
47
49
  python_arguments = [
@@ -62,8 +64,10 @@ def run_inference_in_docker(arguments: argparse.Namespace) -> None:
62
64
  python_arguments.append("--all-iterations")
63
65
  if arguments.cpu_only:
64
66
  python_arguments.append("--cpu-only")
67
+ if arguments.wandb_prefix:
68
+ python_arguments.extend(["--wandb-prefix", arguments.wandb_prefix])
65
69
 
66
- run_python_in_docker(
70
+ return run_python_in_docker(
67
71
  image=arguments.image,
68
72
  cpu_only=arguments.cpu_only,
69
73
  mounts=[
@@ -72,12 +76,23 @@ def run_inference_in_docker(arguments: argparse.Namespace) -> None:
72
76
  f"type=bind,src={arguments.output.parent},dst=/inference-output",
73
77
  ],
74
78
  python_arguments=python_arguments,
79
+ docker_arguments=docker_environment_arguments(
80
+ "WANDB_API_KEY",
81
+ "WANDB_PROJECT_NAME",
82
+ "WANDB_ENTITY",
83
+ "HTTP_PROXY",
84
+ "HTTPS_PROXY",
85
+ "ALL_PROXY",
86
+ "http_proxy",
87
+ "https_proxy",
88
+ "all_proxy",
89
+ ),
90
+ check=False,
75
91
  )
76
92
 
77
93
  def main() -> int:
78
94
  arguments = build_parser().parse_args()
79
- run_inference_in_docker(arguments)
80
- return 0
95
+ return run_inference_in_docker(arguments)
81
96
 
82
97
  if __name__ == "__main__":
83
98
  sys.exit(main())
@@ -2,18 +2,19 @@ from __future__ import annotations
2
2
 
3
3
  import argparse
4
4
  import json
5
- import os
6
5
  import sys
7
6
  import tempfile
8
7
  from pathlib import Path
9
8
 
10
9
  from agentomics.cli.docker_utils import (
11
10
  create_parser,
11
+ docker_environment_arguments,
12
12
  run_python_in_docker,
13
13
  validate_docker_gpu_access,
14
14
  )
15
15
  from agentomics.cli.inference import run_inference_in_docker
16
16
  from agentomics.cli.run_arguments import add_run_arguments
17
+ from agentomics.datasets.data_contract import TEST_SPLIT_PREFIX
17
18
  from agentomics.datasets.dataset_preparation import prepare_test_dataset
18
19
  from agentomics.datasets.datasets_interactive import (
19
20
  get_all_datasets_info,
@@ -104,19 +105,13 @@ def _build_container_arguments(arguments: argparse.Namespace) -> list[str]:
104
105
  return workflow_arguments
105
106
 
106
107
  def _docker_environment_arguments(agent_id: str) -> list[str]:
107
- docker_arguments: list[str] = []
108
- env_file = Path.cwd() / ".env"
109
- if env_file.is_file():
110
- docker_arguments.extend(["--env-file", str(env_file.resolve())])
111
- for variable_name in (
108
+ docker_arguments = docker_environment_arguments(
112
109
  "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "OPENROUTER_API_KEY",
113
110
  "PROVISIONING_OPENROUTER_API_KEY", "OLLAMA_BASE_URL",
114
111
  "WANDB_API_KEY", "WANDB_PROJECT_NAME", "WANDB_ENTITY",
115
112
  "HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY",
116
113
  "http_proxy", "https_proxy", "all_proxy", "CUDA_VISIBLE_DEVICES",
117
- ):
118
- if variable_name in os.environ:
119
- docker_arguments.extend(["-e", variable_name])
114
+ )
120
115
  docker_arguments.extend(["-e", f"AGENT_ID={agent_id}"])
121
116
  if sys.stdin.isatty() and sys.stdout.isatty():
122
117
  docker_arguments.append("-it")
@@ -247,9 +242,9 @@ def _run_inference_on_test_input(
247
242
  cpu_only: bool,
248
243
  workspace_directory: Path,
249
244
  test_input: Path,
250
- ) -> None:
251
- print(f"Evaluating the best iteration on {test_input}")
252
- run_inference_in_docker(
245
+ ) -> int:
246
+ print(f"Evaluating the best iteration on {test_input.name}: {test_input}")
247
+ return run_inference_in_docker(
253
248
  argparse.Namespace(
254
249
  image=image,
255
250
  agent_dir=workspace_directory,
@@ -257,12 +252,13 @@ def _run_inference_on_test_input(
257
252
  output=(
258
253
  workspace_directory
259
254
  / Config.BEST_ITERATION_SNAPSHOT_DIRNAME
260
- / "eval_predictions_test.csv"
255
+ / f"eval_predictions_{test_input.name}.csv"
261
256
  ),
262
257
  label_col=None,
263
258
  iteration_dir=Path(Config.BEST_ITERATION_SNAPSHOT_DIRNAME),
264
259
  all_iterations=False,
265
260
  cpu_only=cpu_only,
261
+ wandb_prefix=test_input.name,
266
262
  )
267
263
  )
268
264
 
@@ -273,19 +269,30 @@ def _run_test_evaluation_in_docker(
273
269
  workspace_directory: Path,
274
270
  dataset_directory: Path,
275
271
  ) -> None:
276
- test_directory = dataset_directory / "test"
277
- if test_directory.is_dir():
278
- _run_inference_on_test_input(
279
- image, cpu_only, workspace_directory, test_directory
280
- )
272
+ test_directories = sorted(
273
+ path
274
+ for path in dataset_directory.iterdir()
275
+ if path.is_dir() and path.name.startswith(TEST_SPLIT_PREFIX)
276
+ )
277
+ if test_directories:
278
+ for test_directory in test_directories:
279
+ return_code = _run_inference_on_test_input(
280
+ image,
281
+ cpu_only,
282
+ workspace_directory,
283
+ test_directory,
284
+ )
285
+ if return_code != 0:
286
+ print(
287
+ f"Warning: Evaluation failed for {test_directory.name} "
288
+ f"with exit code {return_code}; continuing.",
289
+ file=sys.stderr,
290
+ )
281
291
  return
282
292
 
283
293
  test_csv = dataset_directory / "test.csv"
284
294
  if not test_csv.is_file():
285
- print(
286
- f"No test split found at {test_directory} or {test_csv}; "
287
- "skipping test evaluation."
288
- )
295
+ print(f"No test split found in {dataset_directory}; skipping test evaluation.")
289
296
  return
290
297
 
291
298
  metadata_path = (
@@ -306,12 +313,18 @@ def _run_test_evaluation_in_docker(
306
313
  label_column=metadata.get("label_column"),
307
314
  id_column=metadata.get("id_column"),
308
315
  )
309
- _run_inference_on_test_input(
316
+ return_code = _run_inference_on_test_input(
310
317
  image,
311
318
  cpu_only,
312
319
  workspace_directory,
313
320
  prepared_directory / "test",
314
321
  )
322
+ if return_code != 0:
323
+ print(
324
+ f"Warning: Evaluation failed for test with exit code "
325
+ f"{return_code}; continuing.",
326
+ file=sys.stderr,
327
+ )
315
328
 
316
329
 
317
330
  def _run_reporting_in_docker(
@@ -14,7 +14,7 @@ from agentomics.datasets.data_contract import (
14
14
  LABEL_COLUMN_NAME,
15
15
  LABELS_FILE_NAME,
16
16
  METADATA_FILE_NAME,
17
- TEST_SPLIT,
17
+ TEST_SPLIT_PREFIX,
18
18
  TRAIN_SPLIT,
19
19
  )
20
20
 
@@ -186,7 +186,7 @@ def generate_breast_cancer_files(_dataset_name: str = "breast_cancer") -> None:
186
186
  convert_csv_dataset(
187
187
  dataset_dir,
188
188
  label_column=LABEL_COLUMN,
189
- splits={TRAIN_SPLIT: train_df, TEST_SPLIT: test_df},
189
+ splits={TRAIN_SPLIT: train_df, TEST_SPLIT_PREFIX: test_df},
190
190
  id_column=ID_COLUMN_NAME,
191
191
  task_type="classification",
192
192
  )
@@ -217,7 +217,7 @@ def generate_digits_images_files(_dataset_name: str = "digits_images") -> None:
217
217
 
218
218
  split_indices = {
219
219
  TRAIN_SPLIT: train_indices,
220
- TEST_SPLIT: test_indices,
220
+ TEST_SPLIT_PREFIX: test_indices,
221
221
  }
222
222
 
223
223
  for split_name, split_idx in split_indices.items():
@@ -264,10 +264,10 @@ def generate_spoken_digits_files(_dataset_name: str = "spoken_digits") -> None:
264
264
  raise FileNotFoundError(f"No recordings directory found after extracting {archive_path}")
265
265
 
266
266
  recordings_dir = recordings_dirs[-1]
267
- split_labels = {TRAIN_SPLIT: [], TEST_SPLIT: []}
267
+ split_labels = {TRAIN_SPLIT: [], TEST_SPLIT_PREFIX: []}
268
268
  for wav_path in sorted(recordings_dir.glob("*.wav")):
269
269
  label, _speaker, index = wav_path.stem.rsplit("_", 2)
270
- split_name = TEST_SPLIT if int(index) < 5 else TRAIN_SPLIT
270
+ split_name = TEST_SPLIT_PREFIX if int(index) < 5 else TRAIN_SPLIT
271
271
  audio_dir = _make_split_dirs(dataset_dir, split_name, "audio")
272
272
  destination = audio_dir / wav_path.name
273
273
  shutil.copy2(wav_path, destination)
@@ -13,7 +13,7 @@ from agentomics.datasets.data_contract import (
13
13
  LABELS_FILE_NAME,
14
14
  METADATA_FILE_NAME,
15
15
  SUPPLEMENTARY_DIR_NAME,
16
- TEST_SPLIT,
16
+ TEST_SPLIT_PREFIX,
17
17
  TRAIN_SPLIT,
18
18
  VALIDATION_SPLIT,
19
19
  )
@@ -24,7 +24,7 @@ CSV_LABEL_COLUMN_METADATA_KEY = "label_column"
24
24
  CSV_ID_COLUMN_METADATA_KEY = "id_column"
25
25
  TRAIN_CSV_FILE_NAME = f"{TRAIN_SPLIT}.csv"
26
26
  VALIDATION_CSV_FILE_NAME = f"{VALIDATION_SPLIT}.csv"
27
- TEST_CSV_FILE_NAME = f"{TEST_SPLIT}.csv"
27
+ TEST_CSV_FILE_NAME = f"{TEST_SPLIT_PREFIX}.csv"
28
28
  CSV_CONVERTED_SOURCE_DIR_NAME = "_csv_converted_source"
29
29
  ALLOWED_PUBLIC_CSV_DATASET_ENTRIES = {
30
30
  TRAIN_CSV_FILE_NAME,
@@ -46,7 +46,7 @@ def is_public_csv_dataset(source_dir: Path) -> bool:
46
46
 
47
47
  def is_test_csv_dataset(source_dir: Path) -> bool:
48
48
  source_dir = Path(source_dir)
49
- return not (source_dir / TEST_SPLIT).exists() and (source_dir / TEST_CSV_FILE_NAME).is_file()
49
+ return not (source_dir / TEST_SPLIT_PREFIX).exists() and (source_dir / TEST_CSV_FILE_NAME).is_file()
50
50
 
51
51
  def convert_csv_dataset_to_standard_raw_dataset(
52
52
  source_dir: Path,
@@ -107,10 +107,10 @@ def convert_csv_test_dataset_to_standard_raw_dataset(
107
107
  converted_source_dir = _converted_source_dir(destination_dir)
108
108
  remove_path(converted_source_dir)
109
109
  _write_input_and_labels(
110
- split_dir=converted_source_dir / TEST_SPLIT,
110
+ split_dir=converted_source_dir / TEST_SPLIT_PREFIX,
111
111
  df=pd.read_csv(source_dir / TEST_CSV_FILE_NAME),
112
112
  label_column=str(label_column),
113
- id_prefix=TEST_SPLIT,
113
+ id_prefix=TEST_SPLIT_PREFIX,
114
114
  id_column=str(id_column) if id_column is not None else None,
115
115
  )
116
116
  return converted_source_dir
@@ -4,7 +4,7 @@ import pandas as pd
4
4
 
5
5
  TRAIN_SPLIT = "train"
6
6
  VALIDATION_SPLIT = "validation"
7
- TEST_SPLIT = "test"
7
+ TEST_SPLIT_PREFIX = "test"
8
8
  MINI_TRAIN_SPLIT = "mini_train"
9
9
 
10
10
  NON_TEST_SPLIT_NAMES = (TRAIN_SPLIT, VALIDATION_SPLIT)
@@ -22,7 +22,7 @@ DATASET_DESCRIPTION_FILE_NAME = "dataset_description.md"
22
22
  ALLOWED_PUBLIC_DATASET_ENTRIES = {
23
23
  TRAIN_SPLIT,
24
24
  VALIDATION_SPLIT,
25
- TEST_SPLIT,
25
+ TEST_SPLIT_PREFIX,
26
26
  SUPPLEMENTARY_DIR_NAME,
27
27
  METADATA_FILE_NAME,
28
28
  DATASET_DESCRIPTION_FILE_NAME,
@@ -54,12 +54,16 @@ def validate_split_entries(split_path: Path, split_name: str) -> None:
54
54
  def validate_public_dataset_entries(dataset_dir: Path) -> None:
55
55
  unsupported_entries = sorted(
56
56
  item.name for item in dataset_dir.iterdir()
57
- if item.name not in ALLOWED_PUBLIC_DATASET_ENTRIES
57
+ if (
58
+ item.name not in ALLOWED_PUBLIC_DATASET_ENTRIES
59
+ and not (item.is_dir() and item.name.startswith(TEST_SPLIT_PREFIX))
60
+ )
58
61
  )
59
62
  if unsupported_entries:
60
63
  raise ValueError(
61
64
  f"Public dataset {dataset_dir.name} has unsupported top-level entries: {unsupported_entries}. "
62
- f"Allowed: {sorted(ALLOWED_PUBLIC_DATASET_ENTRIES)}."
65
+ f"Allowed: {sorted(ALLOWED_PUBLIC_DATASET_ENTRIES)} and directories "
66
+ f"whose names start with '{TEST_SPLIT_PREFIX}'."
63
67
  )
64
68
 
65
69
  def validate_splits(split_paths: dict[str, Path], expected_input_structure: list[str]) -> None:
@@ -17,7 +17,7 @@ from agentomics.datasets.data_contract import (
17
17
  NON_TEST_SPLIT_NAMES,
18
18
  NUMERIC_LABEL_COLUMN_NAME,
19
19
  SUPPLEMENTARY_DIR_NAME,
20
- TEST_SPLIT,
20
+ TEST_SPLIT_PREFIX,
21
21
  TRAIN_SPLIT,
22
22
  VALIDATION_SPLIT,
23
23
  record_input_dir_structure,
@@ -270,7 +270,7 @@ def check_dataset(source_dir: Path, interactive: bool = False) -> dict:
270
270
  interactive=interactive,
271
271
  )
272
272
  test_rows = None
273
- has_test_split = (source_dir / TEST_SPLIT).is_dir() or is_test_csv_dataset(source_dir)
273
+ has_test_split = (source_dir / TEST_SPLIT_PREFIX).is_dir() or is_test_csv_dataset(source_dir)
274
274
  if has_test_split:
275
275
  test_metadata = prepare_test_dataset(
276
276
  source_dir=source_dir,
@@ -324,33 +324,33 @@ def prepare_test_dataset(
324
324
  id_column=id_column,
325
325
  )
326
326
 
327
- test_source = source_dir / TEST_SPLIT
327
+ test_source = source_dir / TEST_SPLIT_PREFIX
328
328
  if not test_source.is_dir():
329
329
  raise FileNotFoundError(f"Required test/ split is missing: {test_source}")
330
330
 
331
- validate_split_entries(test_source, TEST_SPLIT)
331
+ validate_split_entries(test_source, TEST_SPLIT_PREFIX)
332
332
 
333
- test_labels = load_split_label_dfs({TEST_SPLIT: test_source})
333
+ test_labels = load_split_label_dfs({TEST_SPLIT_PREFIX: test_source})
334
334
 
335
335
  if task_type == TaskTypes.CLASSIFICATION:
336
336
  if not label_to_scalar:
337
337
  raise ValueError("label_to_scalar is required for classification test data preparation")
338
338
  validate_single_label_classification(test_labels)
339
339
  label_to_scalar = {str(k): int(v) for k, v in label_to_scalar.items()}
340
- actual_labels = set(test_labels[TEST_SPLIT][LABEL_COLUMN_NAME].astype(str).unique())
340
+ actual_labels = set(test_labels[TEST_SPLIT_PREFIX][LABEL_COLUMN_NAME].astype(str).unique())
341
341
  unknown_labels = sorted(actual_labels - set(label_to_scalar))
342
342
  if unknown_labels:
343
343
  raise ValueError(
344
344
  f"Test split contains labels not present in train: {unknown_labels}. "
345
345
  f"Known labels: {sorted(label_to_scalar)}"
346
346
  )
347
- numeric_labels = convert_classification_labels(test_labels[TEST_SPLIT], label_to_scalar, TEST_SPLIT)
347
+ numeric_labels = convert_classification_labels(test_labels[TEST_SPLIT_PREFIX], label_to_scalar, TEST_SPLIT_PREFIX)
348
348
  elif task_type == TaskTypes.REGRESSION:
349
- numeric_labels = convert_regression_labels(test_labels[TEST_SPLIT], TEST_SPLIT)
349
+ numeric_labels = convert_regression_labels(test_labels[TEST_SPLIT_PREFIX], TEST_SPLIT_PREFIX)
350
350
  else:
351
351
  raise ValueError(f"Unknown task_type: {task_type}. Expected one of {TaskTypes}.")
352
352
 
353
- dest_test = destination_dir / TEST_SPLIT
353
+ dest_test = destination_dir / TEST_SPLIT_PREFIX
354
354
  dest_test.mkdir(parents=True, exist_ok=True)
355
355
  if csv_test_dataset:
356
356
  shutil.copytree(test_source / INPUT_DIR_NAME, dest_test / INPUT_DIR_NAME)
@@ -361,11 +361,11 @@ def prepare_test_dataset(
361
361
  )
362
362
  numeric_labels.to_csv(dest_test / LABELS_FILE_NAME, index=False)
363
363
 
364
- validate_splits({TEST_SPLIT: dest_test}, input_structure)
364
+ validate_splits({TEST_SPLIT_PREFIX: dest_test}, input_structure)
365
365
 
366
366
  test_metadata = {
367
367
  "task_type": task_type,
368
- "splits": {"test_rows": len(test_labels[TEST_SPLIT])},
368
+ "splits": {"test_rows": len(test_labels[TEST_SPLIT_PREFIX])},
369
369
  "numeric_label_col": NUMERIC_LABEL_COLUMN_NAME,
370
370
  "input_structure": input_structure,
371
371
  "prepared": True,
@@ -34,6 +34,12 @@ def resolve_run_arguments(arguments: argparse.Namespace) -> None:
34
34
  missing_ok=True,
35
35
  )
36
36
  if existing_config is not None:
37
+ if arguments.fork_from_run is None:
38
+ raise FileExistsError(
39
+ "The selected workspace already contains an Agentomics run. "
40
+ "Choose a new empty --workspace-dir, or use --fork-from-run to "
41
+ "continue from the existing run in a different workspace."
42
+ )
37
43
  next_iteration_index = get_next_iteration_index(existing_config)
38
44
  if arguments.dataset is not None and arguments.dataset != existing_config.dataset:
39
45
  console.print(
@@ -12,8 +12,9 @@ from agentomics.datasets.data_contract import (
12
12
  validate_and_read_labels,
13
13
  )
14
14
  from agentomics.datasets.label_processing import convert_classification_labels, convert_regression_labels
15
+ from agentomics.run_logging.wandb_setup import resume_wandb_run
15
16
  from agentomics.runtime.evaluate_result import get_metrics
16
- from agentomics.runtime.read_write_utils import load_config_from_run_dir
17
+ from agentomics.runtime.read_write_utils import load_config_from_run_dir_and_reroot
17
18
  from agentomics.utils.config import Config
18
19
  from agentomics.utils.task_types import TaskTypes
19
20
 
@@ -35,10 +36,9 @@ def evaluate_predictions(
35
36
  predictions_path: Path,
36
37
  labels_path: Path,
37
38
  output_path: Path,
39
+ wandb_prefix: str | None = None,
38
40
  ) -> dict:
39
- config = load_config_from_run_dir(agent_dir / Config.RUN_DIRNAME)
40
- if config is None:
41
- raise FileNotFoundError(f"Could not load run config under {agent_dir / Config.RUN_DIRNAME}")
41
+ config = load_config_from_run_dir_and_reroot(agent_dir / Config.RUN_DIRNAME)
42
42
 
43
43
  numeric_labels = _read_numeric_labels(labels_path, config)
44
44
  numeric_labels_path = predictions_path.parent / f"{predictions_path.stem}.numeric_labels.csv"
@@ -51,6 +51,14 @@ def evaluate_predictions(
51
51
  )
52
52
 
53
53
  output_path.write_text(json.dumps(metrics, indent=2) + "\n", encoding="utf-8")
54
+ if wandb_prefix:
55
+ wandb_run = resume_wandb_run(config)
56
+ if wandb_run is not None:
57
+ wandb_run.log({
58
+ f"{wandb_prefix}/{metric_name}": value
59
+ for metric_name, value in metrics.items()
60
+ })
61
+ wandb_run.finish()
54
62
  print(json.dumps(metrics, indent=2))
55
63
  print(f"Metrics written to {output_path}")
56
64
  return metrics
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  import shutil
5
5
  import subprocess
6
+ from argparse import Namespace
6
7
  from pathlib import Path
7
8
 
8
9
 
@@ -26,6 +27,11 @@ def resolve_output_path(path: Path) -> Path:
26
27
  )
27
28
  return path.parent.resolve() / path.name
28
29
 
30
+ def resolve_inference_paths(arguments: Namespace) -> None:
31
+ arguments.agent_dir = resolve_existing_directory(arguments.agent_dir)
32
+ arguments.input_path = resolve_existing_path(arguments.input_path)
33
+ arguments.output = resolve_output_path(arguments.output)
34
+
29
35
  def require_empty_directory(path: Path) -> None:
30
36
  if path.exists() and not path.is_dir():
31
37
  raise NotADirectoryError(f"Expected a directory: {path}")
@@ -5,6 +5,8 @@ import json
5
5
  import math
6
6
  import os
7
7
  import re
8
+ import shutil
9
+
8
10
  from dataclasses import dataclass
9
11
  from pathlib import Path
10
12
  from typing import Dict, List, Optional, Tuple
@@ -37,11 +39,6 @@ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
37
39
 
38
40
  from agentomics.datasets.data_contract import LABELS_FILE_NAME, NUMERIC_LABEL_COLUMN_NAME, TRAIN_SPLIT, VALIDATION_SPLIT
39
41
 
40
- TEST_PREDICTIONS_FILENAME = "eval_predictions_test.csv"
41
- TEST_NUMERIC_LABELS_FILENAME = "eval_predictions_test.numeric_labels.csv"
42
- TEST_METRICS_FILENAME = "eval_predictions_test.metrics.json"
43
-
44
-
45
42
  # Data models
46
43
  @dataclass(frozen=True)
47
44
  class DatasetMeta:
@@ -61,7 +58,7 @@ class RunMeta:
61
58
 
62
59
  @dataclass
63
60
  class SplitArtifacts:
64
- split_name: str # train/validation/test
61
+ split_name: str # train/validation/test*
65
62
  labeled_csv: Optional[Path]
66
63
  preds_csv: Optional[Path]
67
64
  metrics: Dict[str, float]
@@ -288,11 +285,15 @@ def gather_iteration_inputs(
288
285
  best_iter = load_best_iteration_snapshot_iteration(config)
289
286
  if best_iter is not None and iteration == best_iter:
290
287
  snapshot_dir = config.best_iteration_snapshot_dir
291
- test_preds = snapshot_dir / TEST_PREDICTIONS_FILENAME
292
- test_labeled = snapshot_dir / TEST_NUMERIC_LABELS_FILENAME
293
- test_metrics = load_saved_metrics(snapshot_dir / TEST_METRICS_FILENAME)
294
- if test_preds.exists() or test_labeled.exists() or bool(test_metrics):
295
- splits.append(SplitArtifacts("test", test_labeled, test_preds, test_metrics))
288
+ for test_metrics_path in sorted(snapshot_dir.glob("eval_predictions_test*.metrics.json")):
289
+ predictions_stem = test_metrics_path.name.removesuffix(".metrics.json")
290
+ split_name = predictions_stem.removeprefix("eval_predictions_")
291
+ test_preds = snapshot_dir / f"{predictions_stem}.csv"
292
+ test_labeled = snapshot_dir / f"{predictions_stem}.numeric_labels.csv"
293
+ test_metrics = load_saved_metrics(test_metrics_path)
294
+ splits.append(
295
+ SplitArtifacts(split_name, test_labeled, test_preds, test_metrics)
296
+ )
296
297
 
297
298
  return IterationInputs(iteration=iteration, report_md=report_md, splits=splits)
298
299
 
@@ -577,6 +578,21 @@ def plots_compare_splits_page_flowables(
577
578
  present_splits = [s for s in split_order if plot_groups.get(s)]
578
579
  if not present_splits:
579
580
  return []
581
+ if len(present_splits) > 3:
582
+ flows = []
583
+ for start in range(0, len(present_splits), 3):
584
+ if flows:
585
+ flows.append(PageBreak())
586
+ flows.extend(
587
+ plots_compare_splits_page_flowables(
588
+ iteration,
589
+ task_type,
590
+ plot_groups,
591
+ present_splits[start : start + 3],
592
+ styles,
593
+ )
594
+ )
595
+ return flows
580
596
 
581
597
  task_type = (task_type or "").strip().lower()
582
598
  if task_type == TaskTypes.CLASSIFICATION:
@@ -733,10 +749,18 @@ def metrics_table_flowable(metrics_by_split, split_order, val_metric, styles):
733
749
  if not present or not keys:
734
750
  return Paragraph("No metrics found.", styles["Muted"])
735
751
 
736
- data = [["Metric"] + [s.title() for s in present]]
737
- for k in keys:
738
- row = [k] + [_fmt_metric(metrics_by_split[s].get(k)) for s in present]
739
- data.append(row)
752
+ if len(present) > 3:
753
+ data = [["Split", "Metric", "Value"]]
754
+ for split in present:
755
+ data.extend(
756
+ [split, metric, _fmt_metric(value)]
757
+ for metric, value in sorted(metrics_by_split[split].items())
758
+ )
759
+ else:
760
+ data = [["Metric"] + [s.title() for s in present]]
761
+ for k in keys:
762
+ row = [k] + [_fmt_metric(metrics_by_split[s].get(k)) for s in present]
763
+ data.append(row)
740
764
 
741
765
  tbl = Table(data, hAlign="LEFT")
742
766
  ts = TableStyle(
@@ -752,9 +776,23 @@ def metrics_table_flowable(metrics_by_split, split_order, val_metric, styles):
752
776
  ]
753
777
  )
754
778
 
755
- if val_metric and val_metric in keys:
756
- r = 1 + keys.index(val_metric)
757
- ts.add("BACKGROUND", (0, r), (-1, r), colors.Color(1.0, 0.98, 0.90))
779
+ if val_metric and len(present) > 3:
780
+ for row_index, row in enumerate(data[1:], start=1):
781
+ if row[1] == val_metric:
782
+ ts.add(
783
+ "BACKGROUND",
784
+ (0, row_index),
785
+ (-1, row_index),
786
+ colors.Color(1.0, 0.98, 0.90),
787
+ )
788
+ elif val_metric and val_metric in keys:
789
+ row_index = 1 + keys.index(val_metric)
790
+ ts.add(
791
+ "BACKGROUND",
792
+ (0, row_index),
793
+ (-1, row_index),
794
+ colors.Color(1.0, 0.98, 0.90),
795
+ )
758
796
 
759
797
  tbl.setStyle(ts)
760
798
  return tbl
@@ -844,10 +882,9 @@ def main() -> None:
844
882
  ensure_dir(out_dir)
845
883
  ensure_dir(plots_dir)
846
884
  config.markdown_reports_dir.mkdir(parents=True, exist_ok=True)
847
- split_order = ["train", "validation", "test"]
848
-
849
885
  for it in iterations:
850
886
  inp = gather_iteration_inputs(config, it)
887
+ split_order = [split.split_name for split in inp.splits]
851
888
  report_path = inp.report_md
852
889
  if report_path is None:
853
890
  report_metrics = {
@@ -893,5 +930,16 @@ def main() -> None:
893
930
  split_order=split_order,
894
931
  )
895
932
 
933
+ best_iteration = load_best_iteration_snapshot_iteration(config)
934
+ if best_iteration in iterations:
935
+ shutil.copy2(
936
+ config.markdown_reports_dir / f"run_report_iter_{best_iteration}.md",
937
+ config.reports_dir / "best_iteration.md",
938
+ )
939
+ shutil.copy2(
940
+ config.pdf_reports_dir / f"iteration_{best_iteration}.pdf",
941
+ config.reports_dir / "best_iteration.pdf",
942
+ )
943
+
896
944
  if __name__ == "__main__":
897
945
  main()
@@ -12,21 +12,13 @@ from agentomics.datasets.data_contract import INPUT_DIR_NAME, LABELS_FILE_NAME
12
12
  from agentomics.runtime.conda_utils import restore_iteration_environment
13
13
  from agentomics.runtime.evaluate import evaluate_predictions
14
14
  from agentomics.runtime.filesystem import (
15
- resolve_existing_directory,
16
- resolve_existing_path,
15
+ resolve_inference_paths,
17
16
  resolve_iteration_root,
18
- resolve_output_path,
19
17
  restore_host_ownership,
20
18
  )
21
19
  from agentomics.runtime.inference_runner import run_inference_script
22
20
  from agentomics.utils.config import Config
23
21
 
24
-
25
- def resolve_inference_paths(arguments: Namespace) -> None:
26
- arguments.agent_dir = resolve_existing_directory(arguments.agent_dir)
27
- arguments.input_path = resolve_existing_path(arguments.input_path)
28
- arguments.output = resolve_output_path(arguments.output)
29
-
30
22
  def prepare_inference_input(
31
23
  input_path: Path,
32
24
  output_split_dir: Path,
@@ -50,14 +42,14 @@ def prepare_inference_input(
50
42
  )
51
43
  return output_split_dir
52
44
 
53
- def _compute_metrics(agent_dir: Path, input_split: Path, output_path: Path) -> Path | None:
45
+ def _compute_metrics(agent_dir: Path, input_split: Path, output_path: Path, wandb_prefix: str | None) -> Path | None:
54
46
  labels_path = input_split / LABELS_FILE_NAME
55
47
  if not labels_path.is_file():
56
48
  return None
57
49
 
58
50
  metrics_path = output_path.with_suffix(".metrics.json")
59
51
  print("Computing metrics...")
60
- evaluate_predictions(agent_dir, output_path, labels_path, metrics_path)
52
+ evaluate_predictions(agent_dir, output_path, labels_path, metrics_path, wandb_prefix)
61
53
  return metrics_path
62
54
 
63
55
  def _run_single_inference(arguments: Namespace) -> None:
@@ -102,7 +94,7 @@ def _run_single_inference(arguments: Namespace) -> None:
102
94
  f"Inference completed without creating the prediction output: {arguments.output}"
103
95
  )
104
96
  print("Inference done")
105
- metrics_path = _compute_metrics(arguments.agent_dir, input_split, arguments.output)
97
+ metrics_path = _compute_metrics(arguments.agent_dir, input_split, arguments.output, arguments.wandb_prefix)
106
98
  restore_host_ownership(arguments.output)
107
99
  if metrics_path is not None:
108
100
  restore_host_ownership(metrics_path)
@@ -51,6 +51,8 @@ def load_config_from_run_dir_and_reroot(run_dir: Path) -> Config:
51
51
  def initialize_current_iteration_workspace(config: Config) -> None:
52
52
  config.current_iteration_dir.mkdir(parents=True, exist_ok=True)
53
53
  config.current_iteration_runtime_info_dir.mkdir(exist_ok=True)
54
+ if config.agent_user:
55
+ chown_tree_to_root(config.current_iteration_dir)
54
56
 
55
57
  def archive_current_iteration(config: Config, iteration: int) -> None:
56
58
  export_shared_environment_descriptor(config)
@@ -26,7 +26,7 @@ class Config:
26
26
 
27
27
  DEFAULT_ITERATIONS: ClassVar[int] = 5
28
28
  DEFAULT_SPLIT_ALLOWED_ITERATIONS: ClassVar[int] = 1
29
- DEFAULT_EXPLORATION_ITERATIONS: ClassVar[int] = 4
29
+ DEFAULT_EXPLORATION_ITERATIONS: ClassVar[int] = 2
30
30
  DEFAULT_STEP_SEQUENCE: ClassVar[list[str]] = [
31
31
  "iteration_plan",
32
32
  "data_exploration",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentomics
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Package for running Agentomics - an autonomous agentic system for ML model development
5
5
  Author: Vlastimil Martinek
6
6
  Maintainer-email: Vlastimil Martinek <martinekvlastimil95@gmail.com>
@@ -1,9 +1,9 @@
1
1
  import os
2
2
  import subprocess
3
3
  import unittest
4
- from pathlib import Path
5
4
 
6
5
  from test.test_utils import BaseAgentTest
6
+ from agentomics.runtime.conda_utils import get_shared_environment_path
7
7
  from agentomics.utils.config import Config
8
8
 
9
9
  class TestAgentPermissions(BaseAgentTest):
@@ -85,9 +85,6 @@ class TestAgentPermissions(BaseAgentTest):
85
85
  "The co-located test split must not be exposed to the agent",
86
86
  )
87
87
 
88
- def test_agent_access_to_repository_datasets(self):
89
- self.assertTrue(Path("/repository/datasets/").is_dir())
90
-
91
88
  @unittest.skipUnless(os.getenv("AGENT_USER"), "Agent user sandboxing only enforced in Docker mode")
92
89
  def test_api_key_protection(self):
93
90
  """Test that agent cannot access API keys."""
@@ -109,7 +106,8 @@ class TestAgentPermissions(BaseAgentTest):
109
106
  """Test that conda environment is set up and isolated."""
110
107
  which_python = self.bash_tool.function("which python")
111
108
  self.assertNotIn("Command failed", which_python, "'which python' should succeed")
112
- self.assertIn(f"{self.config.shared_dir}/.conda/envs/{self.agent_id}_env/bin/python", which_python.strip(),
109
+ expected_python = get_shared_environment_path(self.config) / "bin" / "python"
110
+ self.assertIn(str(expected_python), which_python.strip(),
113
111
  "Python should be from the agent's conda environment")
114
112
 
115
113
  install_result = self.bash_tool.function("conda install matplotlib -y 2>&1")
@@ -75,6 +75,7 @@ class TestBestIterationSnapshot(unittest.TestCase):
75
75
  user_prompt="test",
76
76
  task_type="classification",
77
77
  input_structure=["data.csv"],
78
+ conda_export_mode="yaml",
78
79
  )
79
80
  initialize_run_directories(config)
80
81
  save_config(config)
@@ -119,10 +120,19 @@ class TestBestIterationSnapshot(unittest.TestCase):
119
120
  self._create_iteration_with_validation(iteration=1, is_new_best=True, split_changed=False)
120
121
  iteration_dir = self.config.iteration_dir(1)
121
122
  (iteration_dir / "inference.py").write_text("print('ok')", encoding="utf-8")
122
- conda_env = self.config.shared_dir / ".conda" / "envs" / f"{self.config.agent_id}_env"
123
+ conda_env = self.root / "agent_env"
123
124
  conda_env.mkdir(parents=True, exist_ok=True)
124
125
 
125
- with patch("agentomics.runtime.best_iteration_snapshot.export_environment_descriptor_to_path"):
126
+ with (
127
+ patch(
128
+ "agentomics.runtime.best_iteration_snapshot.get_shared_environment_path",
129
+ return_value=conda_env,
130
+ ),
131
+ patch(
132
+ "agentomics.runtime.best_iteration_snapshot."
133
+ "export_environment_descriptor_to_path"
134
+ ),
135
+ ):
126
136
  update_best_iteration_snapshot(self.config, iteration=1)
127
137
 
128
138
  self.assertTrue((self.config.best_iteration_snapshot_dir / "inference.py").exists())
@@ -7,7 +7,7 @@ import sys
7
7
  import tempfile
8
8
  import unittest
9
9
  from pathlib import Path
10
- from unittest.mock import call, patch
10
+ from unittest.mock import patch
11
11
 
12
12
  REPO_ROOT = Path(__file__).resolve().parents[1]
13
13
  SRC_PATH = REPO_ROOT / "src"
@@ -259,32 +259,22 @@ class TestForkRun(unittest.TestCase):
259
259
  / Config.RUN_DIRNAME
260
260
  / Config.SHARED_DIRNAME
261
261
  / Config.ENVIRONMENT_DESCRIPTOR_FILENAME,
262
- self.target_workspace
263
- / Config.RUN_DIRNAME
264
- / Config.SHARED_DIRNAME
265
- / ".conda"
266
- / "envs"
267
- / "tgt_run_env",
262
+ Path("/tmp/agentomics/envs/tgt_run_env"),
268
263
  )
269
264
 
270
- def test_syncs_shared_and_snapshot_environments_from_descriptors(self):
265
+ def test_rebuilds_shared_environment_on_container_local_storage(self):
271
266
  target_run_id = "tgt_run"
272
267
  ensure_environment = self._fork("src_run", target_run_id, fork_from_step=None, fork_from_iteration=None)
273
268
  target_run_dir = self.target_workspace / Config.RUN_DIRNAME
274
269
  target_snapshot_dir = self.target_workspace / Config.BEST_ITERATION_SNAPSHOT_DIRNAME
275
270
  self.assertFalse((target_run_dir / "shared" / ".conda").exists())
276
271
  self.assertFalse((target_snapshot_dir / ".conda").exists())
277
- ensure_environment.assert_has_calls([
278
- call(
279
- target_run_dir / Config.SHARED_DIRNAME / Config.ENVIRONMENT_DESCRIPTOR_FILENAME,
280
- target_run_dir / Config.SHARED_DIRNAME / ".conda" / "envs" / f"{target_run_id}_env",
281
- ),
282
- call(
283
- target_snapshot_dir / Config.RUNTIME_INFO_DIRNAME / Config.ENVIRONMENT_DESCRIPTOR_FILENAME,
284
- target_snapshot_dir / ".conda" / "envs" / f"{target_run_id}_env",
285
- ),
286
- ])
287
- self.assertEqual(ensure_environment.call_count, 2)
272
+ ensure_environment.assert_called_once_with(
273
+ target_run_dir
274
+ / Config.SHARED_DIRNAME
275
+ / Config.ENVIRONMENT_DESCRIPTOR_FILENAME,
276
+ Path(f"/tmp/agentomics/envs/{target_run_id}_env"),
277
+ )
288
278
 
289
279
  def test_raises_when_target_workspace_not_empty(self):
290
280
  self._build_source_run("src_run")
@@ -1,5 +1,13 @@
1
+ import os
2
+ import unittest
3
+
1
4
  from test.test_utils import BaseAgentTest
2
5
 
6
+
7
+ @unittest.skipIf(
8
+ os.getenv("CUDA_VISIBLE_DEVICES") == "",
9
+ "GPU access tests do not apply in CPU-only mode",
10
+ )
3
11
  class TestGpuAccess(BaseAgentTest):
4
12
  """Test suite for GPU agent access"""
5
13
 
@@ -19,8 +27,14 @@ class TestGpuAccess(BaseAgentTest):
19
27
  """Test if the agent can access the GPU using python tool (PyTorch)."""
20
28
 
21
29
  print("Installing PyTorch, might take a while...")
22
- install_result = self.bash_tool.function("pip install torch")
23
- self.assertNotIn("ERROR", install_result, "Failed to install PyTorch through pip")
30
+ install_result = self.bash_tool.function(
31
+ "pip install torch && echo TORCH_INSTALL_SUCCEEDED"
32
+ )
33
+ self.assertIn(
34
+ "TORCH_INSTALL_SUCCEEDED",
35
+ install_result,
36
+ "Failed to install PyTorch through pip",
37
+ )
24
38
 
25
39
  code = (
26
40
  "import torch\n"
@@ -41,26 +55,3 @@ class TestGpuAccess(BaseAgentTest):
41
55
  run_result = self.run_python_tool.function(python_file_path=file_path)
42
56
  self.assertIn("CUDA is available", run_result, "GPU access failed in python tool")
43
57
  self.assertIn("GPU Name:", run_result, "Failed to retrieve GPU name in python tool")
44
-
45
- def test_gpu_tensorflow_python(self):
46
- """Test if the agent can access the GPU using python tool (Tensorflow)."""
47
-
48
- print("Installing tensorflow with CUDA support, might take a while...")
49
- install_result = self.bash_tool.function("pip install tensorflow[and-cuda]") #without [and-cuda] would not detect GPU
50
- self.assertNotIn("ERROR", install_result, "Failed to install tensorflow through pip")
51
-
52
- code = (
53
- "import tensorflow as tf\n"
54
- "gpus = tf.config.list_physical_devices('GPU')\n"
55
- "print(f'GPU devices found: {len(gpus)}')\n"
56
- "if not gpus:\n"
57
- " print('No GPU devices found for TensorFlow')\n"
58
- )
59
-
60
- file_path = self._tool_file_path("test_tensorflow.py")
61
- write_result = self.write_python_tool.function(file_path=file_path, code=code)
62
- self.assertNotIn("Command failed", write_result, "Should be able to write TensorFlow test file")
63
- self.assertNotIn("Error:", write_result, "Should be able to write TensorFlow test file")
64
-
65
- run_result = self.run_python_tool.function(python_file_path=file_path)
66
- self.assertNotIn("GPU devices found: 0", run_result, "No GPU devices found for TensorFlow")
@@ -46,14 +46,14 @@ class RunLauncherSourceContractTest(unittest.TestCase):
46
46
  def test_launcher_invokes_container_workflow(self):
47
47
  self.assertIn("agentomics.runtime.run_workflow", self.launcher)
48
48
 
49
- def test_test_evaluation_reuses_inference_on_co_located_split(self):
49
+ def test_test_evaluation_reuses_inference_on_co_located_splits(self):
50
50
  # The old separate hidden-test tree and flag are gone; evaluation runs
51
- # the best model on the dataset's own ``test`` split via inference.
51
+ # the best model on every test-prefixed split via inference.
52
52
  self.assertNotIn("test_datasets", self.launcher)
53
53
  self.assertNotIn("--test-datasets-dir", self.launcher)
54
- self.assertIn('dataset_directory / "test"', self.launcher)
54
+ self.assertIn("path.name.startswith(TEST_SPLIT_PREFIX)", self.launcher)
55
55
  self.assertIn("run_inference_in_docker", self.launcher)
56
- self.assertIn('"eval_predictions_test.csv"', self.launcher)
56
+ self.assertIn('f"eval_predictions_{test_input.name}.csv"', self.launcher)
57
57
  self.assertIn("agentomics.runtime.report_workflow", self.launcher)
58
58
 
59
59
  def test_help_text_has_no_prepared_datasets_user_concept(self):
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import shutil
2
3
  import subprocess
3
4
  import sys
4
5
  import unittest
@@ -21,6 +22,27 @@ from agentomics.runtime.read_write_utils import (
21
22
 
22
23
  _shared_test_resources = None
23
24
 
25
+
26
+ def _create_agent_visible_dataset() -> Path:
27
+ datasets_dir = Path("/tmp/agentomics/test_runtime_datasets")
28
+ dataset_dir = datasets_dir / "agent_permissions_fixture"
29
+ if datasets_dir.exists():
30
+ shutil.rmtree(datasets_dir)
31
+
32
+ input_dir = dataset_dir / "train" / "input"
33
+ input_dir.mkdir(parents=True)
34
+ (input_dir / "sample.txt").write_text("sample", encoding="utf-8")
35
+ (dataset_dir / "metadata.json").write_text(
36
+ '{"task_type": "classification"}',
37
+ encoding="utf-8",
38
+ )
39
+ subprocess.run(
40
+ ["chmod", "-R", "u=rwX,go=rX", str(datasets_dir)],
41
+ check=True,
42
+ )
43
+ return dataset_dir
44
+
45
+
24
46
  def get_shared_test_resources():
25
47
  global _shared_test_resources
26
48
 
@@ -28,17 +50,19 @@ def get_shared_test_resources():
28
50
  agent_user = os.getenv('AGENT_USER')
29
51
 
30
52
  if _shared_test_resources is None:
53
+ workspace_dir = Path(WORKSPACE_DIR).resolve()
54
+ dataset_dir = _create_agent_visible_dataset()
31
55
  config = Config(
32
56
  agent_id=agent_id,
33
57
  model_name="openai/gpt-3.5-turbo",
34
58
  iteration_plan_model_name="openai/gpt-3.5-turbo",
35
- dataset="AGO2_CLASH_Hejret2023",
59
+ dataset=dataset_dir.name,
36
60
  tags=[],
37
61
  val_metric="ACC",
38
62
  task_type="classification",
39
63
  input_structure=["data.csv"],
40
- workspace_dir=str(Path("/workspace").resolve()),
41
- datasets_dir=str(Path('../repository/datasets').resolve()),
64
+ workspace_dir=str(workspace_dir),
65
+ datasets_dir=str(dataset_dir.parent),
42
66
  iterations=5,
43
67
  user_prompt="Create the best possible machine learning model that will generalize to new unseen data.",
44
68
  agent_user=agent_user,
@@ -48,7 +72,6 @@ def get_shared_test_resources():
48
72
  save_config(config)
49
73
  # Clean up leftover workspace from a previous failed setup attempt.
50
74
  if config.current_iteration_dir.exists():
51
- import shutil
52
75
  shutil.rmtree(config.current_iteration_dir)
53
76
  initialize_current_iteration_workspace(config)
54
77
 
@@ -1 +0,0 @@
1
- __version__ = "1.0.2"
File without changes
File without changes
File without changes
File without changes