-
Notifications
You must be signed in to change notification settings - Fork 3
[fournos_launcher] Allow launching multiple jobs concurrently #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
36e0371
eb23d29
411428a
7dad239
7c132a7
eaa8d00
c07959e
f1df707
af53ee3
e3256db
178a374
20ffe97
147497d
75e6c18
5d2a204
e402cde
f4ef838
109bee4
2208063
bd79fee
0314955
60f17f0
da8b002
b56b35b
fe14f38
d97d6dc
2e4d685
ce8fabd
f89e4d3
d282d53
1da5b7d
77fe447
6124bae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,6 @@ | |
|
|
||
| import yaml | ||
|
|
||
| from projects.core.library import run | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
|
|
@@ -129,8 +127,8 @@ def parse_and_save_pr_arguments_fournos(): | |
| # Create CI metadata directory | ||
| metadata_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Fetch and save FournosJob YAML | ||
| fjob, fjob_spec = fetch_and_save_fjob_yaml(metadata_dir / "fjob.yaml") | ||
| # Load FournosJob YAML | ||
| fjob, fjob_spec = load_fjob_yaml(metadata_dir.parent / "fournos_fjob.yaml") | ||
|
|
||
| if not fjob_spec: | ||
| raise ValueError("FournosJob YAML not found, cannot parse FOURNOS PR arguments") | ||
|
|
@@ -247,40 +245,38 @@ def process_forge_config(fjob_spec, metadata_dir, fjob): | |
| return variable_overrides | ||
|
|
||
|
|
||
| def fetch_and_save_fjob_yaml(fjob_yaml_dest): | ||
| def load_fjob_yaml(fjob_yaml_path): | ||
| """ | ||
| Fetch FournosJob YAML and save to artifact directory. | ||
| Load FournosJob YAML from file. | ||
|
|
||
| Args: | ||
| fjob_yaml_dest: Path where to save the FournosJob YAML | ||
| fjob_yaml_path: Path to the FournosJob YAML file | ||
|
|
||
| Returns: | ||
| Tuple of (full_fjob, fjob_spec), or (None, None) if not found | ||
| """ | ||
|
|
||
| namespace = "psap-automation-wip" | ||
|
|
||
| result = run.run( | ||
| f"oc get fjobs -n {namespace} -oyaml", | ||
| capture_stdout=True, | ||
| ) | ||
|
|
||
| fjobs_data = yaml.safe_load(result.stdout) | ||
| if not (fjobs_data and "items" in fjobs_data and fjobs_data["items"]): | ||
| logger.warning("No FournosJobs found") | ||
| if not fjob_yaml_path.exists(): | ||
| logger.warning(f"FournosJob YAML file not found: {fjob_yaml_path}") | ||
| return None, None | ||
|
|
||
| # Take the last fjob from the list | ||
| fjob = fjobs_data["items"][-1] | ||
|
|
||
| try: | ||
| del fjob["status"] | ||
| except KeyError: | ||
| pass # ignore | ||
| with open(fjob_yaml_path) as f: | ||
| fjob = yaml.safe_load(f) | ||
|
|
||
| with open(fjob_yaml_dest, "w") as f: | ||
| yaml.dump(fjob, f, default_flow_style=False, sort_keys=False) | ||
| if not fjob: | ||
| logger.warning(f"Empty or invalid FournosJob YAML: {fjob_yaml_path}") | ||
| return None, None | ||
|
|
||
| logger.info(f"Saved FournosJob YAML to {fjob_yaml_dest}") | ||
| # Remove status if present | ||
| try: | ||
| del fjob["status"] | ||
| except KeyError: | ||
| pass # ignore | ||
|
|
||
| return fjob, fjob["spec"] | ||
| logger.info(f"Loaded FournosJob YAML from {fjob_yaml_path}") | ||
|
|
||
| return fjob, fjob["spec"] | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Failed to load FournosJob YAML from {fjob_yaml_path}: {e}") | ||
| return None, None | ||
|
Comment on lines
+266
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid collapsing malformed YAML into a “not found” outcome. At Line 266-282, parse/shape errors and missing file all become Suggested fix def load_fjob_yaml(fjob_yaml_path):
@@
try:
with open(fjob_yaml_path) as f:
fjob = yaml.safe_load(f)
- if not fjob:
+ if not fjob:
logger.warning(f"Empty or invalid FournosJob YAML: {fjob_yaml_path}")
return None, None
+
+ if not isinstance(fjob, dict):
+ logger.error(f"Invalid FournosJob root type in {fjob_yaml_path}: expected mapping")
+ return None, None
+
+ fjob_spec = fjob.get("spec")
+ if not isinstance(fjob_spec, dict):
+ logger.error(f"Invalid or missing 'spec' section in {fjob_yaml_path}")
+ return None, None
# Remove status if present
- try:
- del fjob["status"]
- except KeyError:
- pass # ignore
+ fjob.pop("status", None)
logger.info(f"Loaded FournosJob YAML from {fjob_yaml_path}")
-
- return fjob, fjob["spec"]
+ return fjob, fjob_spec🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.