MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / create_workflow

Function create_workflow

monai/bundle/scripts.py:1921–1975  ·  view source on GitHub ↗

Specify `bundle workflow` to create monai bundle workflows. The workflow should be subclass of `BundleWorkflow` and be available to import. It can be MONAI existing bundle workflows or user customized workflows. Typical usage examples: .. code-block:: python # Specify

(
    workflow_name: str | BundleWorkflow | None = None,
    config_file: str | Sequence[str] | None = None,
    args_file: str | None = None,
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

1919
1920
1921def create_workflow(
1922 workflow_name: str | BundleWorkflow | None = None,
1923 config_file: str | Sequence[str] | None = None,
1924 args_file: str | None = None,
1925 **kwargs: Any,
1926) -> Any:
1927 """
1928 Specify `bundle workflow` to create monai bundle workflows.
1929 The workflow should be subclass of `BundleWorkflow` and be available to import.
1930 It can be MONAI existing bundle workflows or user customized workflows.
1931
1932 Typical usage examples:
1933
1934 .. code-block:: python
1935
1936 # Specify config_file path to create workflow:
1937 workflow = create_workflow(config_file="/workspace/spleen_ct_segmentation/configs/train.json", workflow_type="train")
1938
1939 # Set the workflow to other customized BundleWorkflow subclass to create workflow:
1940 workflow = create_workflow(workflow_name=CustomizedWorkflow)
1941
1942 Args:
1943 workflow_name: specified bundle workflow name, should be a string or class, default to "ConfigWorkflow".
1944 config_file: filepath of the config file, if it is a list of file paths, the content of them will be merged.
1945 args_file: a JSON or YAML file to provide default values for this API.
1946 so that the command line inputs can be simplified.
1947 kwargs: arguments to instantiate the workflow class.
1948
1949 """
1950 _args = update_kwargs(args=args_file, workflow_name=workflow_name, config_file=config_file, **kwargs)
1951 workflow_name, config_file = _pop_args(
1952 _args, workflow_name=ConfigWorkflow, config_file=None
1953 ) # the default workflow name is "ConfigWorkflow"
1954 if isinstance(workflow_name, str):
1955 workflow_class, has_built_in = optional_import("monai.bundle", name=str(workflow_name)) # search built-in
1956 if not has_built_in:
1957 workflow_class = locate(str(workflow_name)) # search dotted path
1958 if workflow_class is None:
1959 raise ValueError(f"cannot locate specified workflow class: {workflow_name}.")
1960 elif issubclass(workflow_name, BundleWorkflow): # type: ignore
1961 workflow_class = workflow_name
1962 else:
1963 raise ValueError(
1964 "Argument `workflow_name` must be a bundle workflow class name"
1965 f"or subclass of BundleWorkflow, got: {workflow_name}."
1966 )
1967
1968 if config_file is not None:
1969 workflow_ = workflow_class(config_file=config_file, **_args)
1970 else:
1971 workflow_ = workflow_class(**_args)
1972
1973 workflow_.initialize()
1974 _log_input_summary(tag="run", args=_args)
1975 return workflow_
1976
1977
1978def download_large_files(bundle_path: str | None = None, large_file_name: str | None = None) -> None:

Callers 5

loadFunction · 0.85
runFunction · 0.85
run_workflowFunction · 0.85

Calls 5

optional_importFunction · 0.90
update_kwargsFunction · 0.85
_pop_argsFunction · 0.85
_log_input_summaryFunction · 0.85
initializeMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…