mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-25 11:18:06 +00:00
revert check.py
This commit is contained in:
parent
2ff0ee423e
commit
12a5366ab3
@ -19,6 +19,7 @@ class DesignError(RuntimeError):
|
|||||||
"""Raised when a workflow design cannot be loaded or validated."""
|
"""Raised when a workflow design cannot be loaded or validated."""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _allowed_node_types() -> set[str]:
|
def _allowed_node_types() -> set[str]:
|
||||||
names = set(iter_node_schemas().keys())
|
names = set(iter_node_schemas().keys())
|
||||||
if not names:
|
if not names:
|
||||||
@ -72,9 +73,7 @@ def load_config(
|
|||||||
|
|
||||||
data = prepare_design_mapping(raw_data, source=str(config_path))
|
data = prepare_design_mapping(raw_data, source=str(config_path))
|
||||||
|
|
||||||
schema_errors = validate_design(
|
schema_errors = validate_design(data, set_defaults=set_defaults, fn_module_ref=fn_module)
|
||||||
data, set_defaults=set_defaults, fn_module_ref=fn_module
|
|
||||||
)
|
|
||||||
if schema_errors:
|
if schema_errors:
|
||||||
formatted = "\n".join(f"- {err}" for err in schema_errors)
|
formatted = "\n".join(f"- {err}" for err in schema_errors)
|
||||||
raise DesignError(f"Design validation failed for '{config_path}':\n{formatted}")
|
raise DesignError(f"Design validation failed for '{config_path}':\n{formatted}")
|
||||||
@ -87,9 +86,7 @@ def load_config(
|
|||||||
logic_errors = check_workflow_structure(data)
|
logic_errors = check_workflow_structure(data)
|
||||||
if logic_errors:
|
if logic_errors:
|
||||||
formatted = "\n".join(f"- {err}" for err in logic_errors)
|
formatted = "\n".join(f"- {err}" for err in logic_errors)
|
||||||
raise DesignError(
|
raise DesignError(f"Workflow logical issues detected for '{config_path}':\n{formatted}")
|
||||||
f"Workflow logical issues detected for '{config_path}':\n{formatted}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
print("Workflow OK.")
|
print("Workflow OK.")
|
||||||
|
|
||||||
@ -121,29 +118,4 @@ def check_config(yaml_content: Any) -> str:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Validate workflow design file.")
|
|
||||||
parser.add_argument(
|
|
||||||
"--path", type=Path, required=True, help="Path to the design file."
|
|
||||||
)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
try:
|
|
||||||
load_config(args.path)
|
|
||||||
print(f"Design '{args.path}' is valid.")
|
|
||||||
except DesignError as e:
|
|
||||||
print(f"Validation failed: {e}")
|
|
||||||
sys.exit(1)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"An unexpected error occurred: {e}")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user