Skip to content

Commit 0a7ab01

Browse files
authored
Merge pull request #23 from aldbr/metadata-model-semantics
Rename MetadataProcessor to ExecutionHooks
2 parents 7405ffa + aba1afd commit 0a7ab01

File tree

44 files changed

+1567
-1423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1567
-1423
lines changed

scripts/generate_schemas.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This script automatically generates JSON schemas for all registered metadata
55
plugins in the DIRAC CWL prototype system. It includes schemas for:
66
7-
1. Core metadata models (BaseMetadataModel, MetadataDescriptor, TaskDescriptor)
7+
1. Core metadata models (ExecutionHooksBasePlugin, MetadataDescriptor, TaskDescriptor)
88
2. Submission models (JobSubmissionModel, etc.)
99
3. All registered metadata plugins (user plugins included)
1010
@@ -38,18 +38,18 @@ def collect_pydantic_models() -> Dict[str, Any]:
3838
# Import core models
3939
try:
4040
from dirac_cwl_proto.metadata.core import (
41-
BaseMetadataModel,
42-
DataManager,
43-
JobExecutor,
44-
TransformationDataManager,
41+
ExecutionHooksBasePlugin,
42+
ExecutionHooksHint,
43+
SchedulingHint,
44+
TransformationExecutionHooksHint,
4545
)
4646

4747
models.update(
4848
{
49-
"BaseMetadataModel": BaseMetadataModel,
50-
"DataManager": DataManager,
51-
"JobExecutor": JobExecutor,
52-
"TransformationDataManager": TransformationDataManager,
49+
"ExecutionHooksBasePlugin": ExecutionHooksBasePlugin,
50+
"ExecutionHooksHint": ExecutionHooksHint,
51+
"SchedulingHint": SchedulingHint,
52+
"TransformationExecutionHooksHint": TransformationExecutionHooksHint,
5353
}
5454
)
5555
logger.info("Collected core metadata models")
@@ -59,22 +59,18 @@ def collect_pydantic_models() -> Dict[str, Any]:
5959
# Import submission models
6060
try:
6161
from dirac_cwl_proto.submission_models import (
62-
JobParameterModel,
62+
JobInputModel,
6363
JobSubmissionModel,
64-
ProductionStepMetadataModel,
6564
ProductionSubmissionModel,
66-
TaskDescriptionModel,
6765
TransformationSubmissionModel,
6866
)
6967

7068
models.update(
7169
{
72-
"TaskDescriptionModel": TaskDescriptionModel,
73-
"JobParameterModel": JobParameterModel,
70+
"JobInputModel": JobInputModel,
7471
"JobSubmissionModel": JobSubmissionModel,
7572
"TransformationSubmissionModel": TransformationSubmissionModel,
7673
"ProductionSubmissionModel": ProductionSubmissionModel,
77-
"ProductionStepMetadataModel": ProductionStepMetadataModel,
7874
}
7975
)
8076
logger.info("Collected submission models")
@@ -103,9 +99,6 @@ def collect_pydantic_models() -> Dict[str, Any]:
10399

104100
excluded_prefixes = (
105101
"BaseMetadata",
106-
"MetadataDescriptor",
107-
"TaskDescriptor",
108-
"TaskDescription",
109102
"Job",
110103
"Transformation",
111104
"Production",
@@ -208,8 +201,8 @@ def generate_schema(model_class: Any, model_name: str) -> Dict[str, Any]:
208201
schema["dirac_description"] = model_class.description
209202
if hasattr(model_class, "vo"):
210203
schema["dirac_vo"] = model_class.vo
211-
if hasattr(model_class, "get_metadata_class"):
212-
schema["dirac_metadata_class"] = model_class.get_metadata_class()
204+
if hasattr(model_class, "get_hook_plugin"):
205+
schema["dirac_hook_plugin"] = model_class.name()
213206

214207
# Set title if not present
215208
if "title" not in schema:
@@ -345,17 +338,15 @@ def main():
345338
save_schema(unified_schema, unified_file, args.format)
346339

347340
# Generate plugin summary
348-
plugin_models = {
349-
k: v for k, v in models.items() if hasattr(v, "get_metadata_class")
350-
}
341+
plugin_models = {k: v for k, v in models.items() if hasattr(v, "name")}
351342
if plugin_models:
352343
summary = {
353344
"plugins": {
354345
name: {
355346
"class": model_class.__name__,
356-
"metadata_class": (
357-
model_class.get_metadata_class()
358-
if hasattr(model_class, "get_metadata_class")
347+
"hook_plugin": (
348+
model_class.name()
349+
if hasattr(model_class, "get_hook_plugin")
359350
else None
360351
),
361352
"description": getattr(model_class, "description", None),

src/dirac_cwl_proto/job/__init__.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
from ruamel.yaml import YAML
2828
from schema_salad.exceptions import ValidationException
2929

30-
from dirac_cwl_proto.metadata.core import BaseMetadataModel
30+
from dirac_cwl_proto.metadata.core import ExecutionHooksBasePlugin
3131
from dirac_cwl_proto.submission_models import (
32-
JobParameterModel,
32+
JobInputModel,
3333
JobSubmissionModel,
3434
extract_dirac_hints,
3535
)
@@ -81,7 +81,7 @@ def submit_job_client(
8181

8282
# Extract and validate dirac hints; unknown hints are logged as warnings.
8383
try:
84-
job_metadata, job_description = extract_dirac_hints(task)
84+
job_metadata, job_scheduling = extract_dirac_hints(task)
8585
except Exception as exc:
8686
console.print(
8787
f"[red]:heavy_multiplication_x:[/red] [bold]CLI:[/bold] Invalid DIRAC hints:\n{exc}"
@@ -106,18 +106,18 @@ def submit_job_client(
106106
if overrides:
107107
override_hints = overrides[next(iter(overrides))].get("hints", {})
108108
if override_hints:
109-
job_description = job_description.model_copy(
110-
update=override_hints.pop("dirac:job-execution", {})
109+
job_scheduling = job_scheduling.model_copy(
110+
update=override_hints.pop("dirac:scheduling", {})
111111
)
112112
job_metadata = job_metadata.model_copy(
113-
update=override_hints.pop("dirac:data-management", {})
113+
update=override_hints.pop("dirac:execution-hooks", {})
114114
)
115115

116116
# Upload the local files to the sandbox store
117117
sandbox_id = upload_local_input_files(parameter)
118118

119119
parameters.append(
120-
JobParameterModel(
120+
JobInputModel(
121121
sandbox=[sandbox_id] if sandbox_id else None,
122122
cwl=parameter,
123123
)
@@ -129,8 +129,8 @@ def submit_job_client(
129129
job = JobSubmissionModel(
130130
task=task,
131131
parameters=parameters,
132-
description=job_description,
133-
metadata=job_metadata,
132+
scheduling=job_scheduling,
133+
execution_hooks=job_metadata,
134134
)
135135
console.print(
136136
"[green]:heavy_check_mark:[/green] [bold]CLI:[/bold] Job(s) validated."
@@ -230,8 +230,8 @@ def submit_job_router(job: JobSubmissionModel) -> bool:
230230
JobSubmissionModel(
231231
task=job.task,
232232
parameters=[parameter],
233-
description=job.description,
234-
metadata=job.metadata,
233+
scheduling=job.scheduling,
234+
execution_hooks=job.execution_hooks,
235235
)
236236
)
237237
logger.info("Job(s) validated!")
@@ -255,8 +255,8 @@ def submit_job_router(job: JobSubmissionModel) -> bool:
255255

256256
def _pre_process(
257257
executable: CommandLineTool | Workflow | ExpressionTool,
258-
arguments: JobParameterModel | None,
259-
runtime_metadata: BaseMetadataModel | None,
258+
arguments: JobInputModel | None,
259+
runtime_metadata: ExecutionHooksBasePlugin | None,
260260
job_path: Path,
261261
) -> list[str]:
262262
"""
@@ -334,7 +334,7 @@ def _post_process(
334334
stdout: str,
335335
stderr: str,
336336
job_path: Path,
337-
runtime_metadata: BaseMetadataModel | None,
337+
runtime_metadata: ExecutionHooksBasePlugin | None,
338338
):
339339
"""
340340
Post-process the job after execution.
@@ -364,7 +364,9 @@ def run_job(job: JobSubmissionModel) -> bool:
364364
logger = logging.getLogger("JobWrapper")
365365
# Instantiate runtime metadata from the serializable descriptor and
366366
# the job context so implementations can access task inputs/overrides.
367-
runtime_metadata = job.metadata.to_runtime(job) if job.metadata else None
367+
runtime_metadata = (
368+
job.execution_hooks.to_runtime(job) if job.execution_hooks else None
369+
)
368370

369371
# Isolate the job in a specific directory
370372
job_path = Path(".") / "workernode" / f"{random.randint(1000, 9999)}"

src/dirac_cwl_proto/metadata/__init__.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
"""
99

1010
from .core import (
11-
BaseMetadataModel,
1211
DataCatalogInterface,
13-
DataManager,
14-
JobExecutor,
15-
MetadataProcessor,
16-
TransformationDataManager,
12+
ExecutionHooksBasePlugin,
13+
ExecutionHooksHint,
14+
SchedulingHint,
15+
TransformationExecutionHooksHint,
1716
)
1817
from .registry import (
19-
MetadataPluginRegistry,
2018
discover_plugins,
2119
get_registry,
2220
)
@@ -32,15 +30,12 @@
3230
pass
3331

3432
__all__ = [
35-
# Core classes
36-
"BaseMetadataModel",
33+
# Core metadata and plugins
34+
"ExecutionHooksHint",
35+
"TransformationExecutionHooksHint",
36+
"ExecutionHooksBasePlugin",
37+
"SchedulingHint",
3738
"DataCatalogInterface",
38-
"DataManager",
39-
"MetadataProcessor",
40-
"JobExecutor",
41-
"TransformationDataManager",
42-
# Registry functions
43-
"MetadataPluginRegistry",
44-
"discover_plugins",
39+
"MetadataRegistry",
4540
"get_registry",
4641
]

0 commit comments

Comments
 (0)