-
Notifications
You must be signed in to change notification settings - Fork 39
#800 - Local workflow execution #802
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
Open
maufrancom
wants to merge
36
commits into
NVIDIA:main
Choose a base branch
from
maufrancom:mfrancomarti/local-execution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b54cce6
Added new feature to execute workflows without a kubernetes cluster, …
maufrancom 668c0a9
Add local.py and update dependencies in BUILD file
maufrancom 63b0620
Add GPU passthrough support in LocalExecutor
maufrancom b20f2b9
Update Docker command construction in LocalExecutor
maufrancom bcf4246
Add resume functionality to local workflow execution
maufrancom 3e4f7c3
Update .gitignore to include .venv directory
maufrancom 1aa8c30
Enhance local workflow execution with Docker command support
maufrancom d332f6c
Enhance documentation and comments in local execution modules
maufrancom 6297dc9
Refactor file handling in LocalExecutor for UTF-8 encoding
maufrancom 0dffb79
Enhance error handling and update documentation in local execution mo…
maufrancom 0a7e15c
Update copyright line in test_local_executor.py to comply with pylint…
maufrancom 84a26da
Add shared memory size support for GPU tasks in local execution
maufrancom 05f4ea6
Add tutorial specs filegroup and enhance local executor tests
maufrancom 684d554
Implement file path validation in LocalExecutor to prevent directory …
maufrancom 88bc295
Clear GPU device specification in Docker arguments for LocalExecutor
maufrancom 93fe43c
Refactor shared memory size handling in LocalExecutor
maufrancom ed0d746
Refactor LocalExecutor to use container paths for token mapping
maufrancom b1bf792
Add cycle detection in LocalExecutor for task DAGs
maufrancom 04615ca
Enhance LocalExecutor with lead-task failure policy and host token su…
maufrancom 3c88f8f
Enhance LocalExecutor with unresolved token detection
maufrancom 38a9e27
Refactor LocalExecutor to StandaloneExecutor for Docker-based execution
maufrancom 1b705ed
Add Docker Compose support for parallel workflow execution
maufrancom fd1a794
Enhance Docker Compose and Standalone Executors with error handling a…
maufrancom 47ff70f
Add cleanup functionality in StandaloneExecutor for rerun tasks
maufrancom dbf4790
Enhance CLI functionality with credential mapping and variable overrides
maufrancom 612fa2f
Enhance credential handling in Compose and Standalone Executors
maufrancom adad9d7
Enhance workflow fingerprinting in StandaloneExecutor
maufrancom e778e58
Improve error handling and logging in Compose and Standalone Executors
maufrancom f6df823
Refactor Compose and Standalone Executors for improved command handli…
maufrancom e9647a6
Refactor hash generation in StandaloneExecutor and improve cycle dete…
maufrancom 3c91e1d
Refactor file writing logic in StandaloneExecutor to support base64 e…
maufrancom 0bd4a99
Enhance credential handling in StandaloneExecutor
maufrancom e782e4d
Refactor GPU handling in StandaloneExecutor
maufrancom 1be5606
Refactor file handling and enhance test coverage in StandaloneExecuto…
maufrancom 3ff88a2
Merge branch 'NVIDIA:main' into mfrancomarti/local-execution
maufrancom 3cce831
Refactor test setup in TestComposeValidation to use temporary directo…
maufrancom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,7 @@ docs/**/domain_config.js | |
| .ruff_cache | ||
|
|
||
| .lycheecache | ||
|
|
||
| .venv/ | ||
| build/ | ||
| *.egg-info | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| filegroup( | ||
| name = "tutorial_specs", | ||
| srcs = glob(["*.yaml"]), | ||
| visibility = ["//src/utils/tests:__pkg__"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| """ | ||
| SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # pylint: disable=line-too-long | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| """ | ||
|
|
||
| import argparse | ||
| import os | ||
| import sys | ||
|
|
||
| import shtab | ||
|
|
||
| from src.utils import compose_executor | ||
|
|
||
|
|
||
| def setup_parser(parser: argparse._SubParsersAction): | ||
| """Register the 'docker-compose' subcommand for parallel workflow execution.""" | ||
| dc_parser = parser.add_parser( | ||
| 'docker-compose', | ||
| help='Run workflows using Docker Compose for parallel execution ' | ||
| '(no Kubernetes cluster required).') | ||
| subparsers = dc_parser.add_subparsers(dest='command') | ||
| subparsers.required = True | ||
|
|
||
| run_parser = subparsers.add_parser( | ||
| 'run', | ||
| help='Execute a workflow spec using Docker Compose for parallel task execution.') | ||
| run_parser.add_argument( | ||
| '-f', '--file', | ||
| required=True, | ||
| dest='workflow_file', | ||
| help='Path to the workflow YAML spec file.').complete = shtab.FILE | ||
| run_parser.add_argument( | ||
| '--work-dir', | ||
| dest='work_dir', | ||
| default=None, | ||
| help='Directory for task inputs/outputs and the generated docker-compose.yml. ' | ||
| 'Defaults to a temporary directory.') | ||
| run_parser.add_argument( | ||
| '--keep', | ||
| action='store_true', | ||
| default=False, | ||
| help='Keep the work directory after execution (always kept on failure).') | ||
| run_parser.add_argument( | ||
| '--compose-cmd', | ||
| dest='compose_cmd', | ||
| default='docker compose', | ||
| help='Docker Compose command to use (e.g. "docker-compose" for V1). ' | ||
| 'Default: "docker compose".') | ||
| run_parser.add_argument( | ||
| '--credential', | ||
| nargs='+', | ||
| default=[], | ||
| help='Map credential names to local directories. ' | ||
| 'Format: "<name>=<path>". The directory is bind-mounted read-only ' | ||
| 'into the container at the path declared in the spec. ' | ||
| 'Example: --credential hf-token=$HOME/.hf') | ||
| run_parser.add_argument( | ||
| '--set', | ||
| nargs='+', | ||
| default=[], | ||
| help='Override default-values in the workflow spec. ' | ||
| 'Format: "<field>=<value>". Values are cast as int or float if ' | ||
| 'applicable, otherwise kept as strings.') | ||
| run_parser.add_argument( | ||
| '--set-string', | ||
| dest='set_string', | ||
| nargs='+', | ||
| default=[], | ||
| help='Override default-values in the workflow spec, forcing string type. ' | ||
| 'Format: "<field>=<value>".') | ||
| run_parser.add_argument( | ||
| '--shm-size', | ||
| dest='shm_size', | ||
| default=None, | ||
| help='Shared memory size for GPU containers (e.g. 16g, 32g). ' | ||
| 'Defaults to 16g for tasks that request GPUs.') | ||
| run_parser.set_defaults(func=_run_compose) | ||
|
|
||
|
|
||
| def _parse_credentials(raw_credentials: list[str]) -> dict[str, str]: | ||
| """Parse --credential name=path arguments into a dict.""" | ||
| result: dict[str, str] = {} | ||
| for entry in raw_credentials: | ||
| if '=' not in entry: | ||
| raise ValueError( | ||
| f'--credential value "{entry}" is incorrectly formatted (expected name=/path)') | ||
| name, path = entry.split('=', 1) | ||
| if not os.path.isdir(path): | ||
| raise ValueError( | ||
| f'Credential path for "{name}" does not exist or is not a directory: {path}') | ||
| result[name] = path | ||
| return result | ||
|
|
||
|
|
||
| def _run_compose(service_client, args: argparse.Namespace): | ||
| """Execute a workflow via Docker Compose using the parsed CLI arguments.""" | ||
| try: | ||
| credentials = _parse_credentials(args.credential) | ||
| success = compose_executor.run_workflow_compose( | ||
| spec_path=args.workflow_file, | ||
| work_dir=args.work_dir, | ||
| keep_work_dir=args.keep, | ||
| compose_cmd=args.compose_cmd, | ||
| shm_size=args.shm_size, | ||
| set_variables=args.set, | ||
| set_string_variables=args.set_string, | ||
| credentials=credentials, | ||
| ) | ||
| except (ValueError, FileNotFoundError, PermissionError) as error: | ||
| print(f'Error: {error}', file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| if not success: | ||
| sys.exit(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| """ | ||
| SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # pylint: disable=line-too-long | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| """ | ||
|
|
||
| import argparse | ||
| import os | ||
| import sys | ||
|
|
||
| import shtab | ||
|
|
||
| from src.utils import standalone_executor | ||
|
|
||
|
|
||
| def setup_parser(parser: argparse._SubParsersAction): | ||
| """Register the 'standalone' subcommand and its nested 'run' action with the CLI argument parser.""" | ||
| standalone_parser = parser.add_parser( | ||
| 'standalone', | ||
| help='Run workflows in standalone mode using Docker containers (no Kubernetes cluster required).') | ||
| subparsers = standalone_parser.add_subparsers(dest='command') | ||
| subparsers.required = True | ||
|
|
||
| run_parser = subparsers.add_parser( | ||
| 'run', | ||
| help='Execute a workflow spec in standalone mode using Docker containers.') | ||
| run_parser.add_argument( | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| '-f', '--file', | ||
| required=True, | ||
| dest='workflow_file', | ||
| help='Path to the workflow YAML spec file.').complete = shtab.FILE | ||
| run_parser.add_argument( | ||
| '--work-dir', | ||
| dest='work_dir', | ||
| default=None, | ||
| help='Directory for task inputs/outputs. Defaults to a temporary directory.') | ||
| run_parser.add_argument( | ||
| '--keep', | ||
| action='store_true', | ||
| default=False, | ||
| help='Keep the work directory after execution (always kept on failure).') | ||
| run_parser.add_argument( | ||
| '--docker', | ||
| dest='docker_cmd', | ||
| default='docker', | ||
| help='Docker-compatible command to use (e.g. podman). Default: docker.') | ||
| run_parser.add_argument( | ||
| '--resume', | ||
| action='store_true', | ||
| default=False, | ||
| help='Resume a previous run, skipping tasks that already completed successfully. ' | ||
| 'Requires --work-dir pointing to the previous run directory.') | ||
| run_parser.add_argument( | ||
| '--from-step', | ||
| dest='from_step', | ||
| default=None, | ||
| help='Resume from a specific task, re-running it and all downstream tasks. ' | ||
| 'Tasks upstream of the specified step are skipped if they completed ' | ||
| 'successfully. Requires --work-dir pointing to the previous run directory.') | ||
| run_parser.add_argument( | ||
| '--credential', | ||
| nargs='+', | ||
| default=[], | ||
| help='Map credential names to local directories. ' | ||
| 'Format: "<name>=<path>". The directory is bind-mounted read-only ' | ||
| 'into the container at the path declared in the spec. ' | ||
| 'Example: --credential hf-token=$HOME/.hf') | ||
| run_parser.add_argument( | ||
| '--set', | ||
| nargs='+', | ||
| default=[], | ||
| help='Override default-values in the workflow spec. ' | ||
| 'Format: "<field>=<value>". Values are cast as int or float if ' | ||
| 'applicable, otherwise kept as strings.') | ||
| run_parser.add_argument( | ||
| '--set-string', | ||
| dest='set_string', | ||
| nargs='+', | ||
| default=[], | ||
| help='Override default-values in the workflow spec, forcing string type. ' | ||
| 'Format: "<field>=<value>".') | ||
| run_parser.add_argument( | ||
| '--shm-size', | ||
| dest='shm_size', | ||
| default=None, | ||
| help='Shared memory size for GPU containers (e.g. 16g, 32g). ' | ||
| 'Defaults to 16g for tasks that request GPUs. ' | ||
| 'PyTorch DataLoader workers require large shared memory.') | ||
| run_parser.set_defaults(func=_run_standalone) | ||
|
|
||
|
|
||
| def _parse_credentials(raw_credentials: list[str]) -> dict[str, str]: | ||
| """Parse --credential name=path arguments into a dict.""" | ||
| result: dict[str, str] = {} | ||
| for entry in raw_credentials: | ||
| if '=' not in entry: | ||
| raise ValueError( | ||
| f'--credential value "{entry}" is incorrectly formatted (expected name=/path)') | ||
| name, path = entry.split('=', 1) | ||
| if not os.path.isdir(path): | ||
| raise ValueError( | ||
| f'Credential path for "{name}" does not exist or is not a directory: {path}') | ||
| result[name] = path | ||
| return result | ||
|
|
||
|
|
||
| def _run_standalone(service_client, args: argparse.Namespace): | ||
| """Execute a workflow in standalone mode via Docker using the parsed CLI arguments.""" | ||
| try: | ||
| credentials = _parse_credentials(args.credential) | ||
| success = standalone_executor.run_workflow_standalone( | ||
| spec_path=args.workflow_file, | ||
| work_dir=args.work_dir, | ||
| keep_work_dir=args.keep, | ||
| resume=args.resume, | ||
| from_step=args.from_step, | ||
| docker_cmd=args.docker_cmd, | ||
| shm_size=args.shm_size, | ||
| set_variables=args.set, | ||
| set_string_variables=args.set_string, | ||
| credentials=credentials, | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| except (ValueError, FileNotFoundError, PermissionError) as error: | ||
| print(f'Error: {error}', file=sys.stderr) | ||
| sys.exit(1) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if not success: | ||
| sys.exit(1) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.