Skip to content
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

Configure local plugin to launch into czidnet #111

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions workflows/plugins/workflow_runners/local/workflow_runner_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import threading
from typing import List
from uuid import uuid4
from pathlib import Path
import re

from plugin_types import (
Expand Down Expand Up @@ -43,6 +44,22 @@ def _detect_task_output(self, line: str) -> None:
for key, output in outputs.items():
print(f"{key}: {output}")

def config_file(self, dir_path: str) -> str:
config_file_str = """
[download_awscli]
host_credentials = true

[task_runtime]
defaults = {
"docker_network": "czidnet" }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if I should make this configurable


[docker_swarm]
allow_networks = ["czidnet"]"""
file_path = str(Path(dir_path) / "miniwdl.cfg")
with open(file_path, "w+") as f:
f.write(config_file_str)
return file_path

async def _run_workflow_work(
self,
event_bus: EventBus,
Expand All @@ -53,10 +70,24 @@ async def _run_workflow_work(
await event_bus.send(WorkflowStartedMessage(runner_id=runner_id))
# Running docker-in-docker requires the paths to files and outputs to be the same between
with tempfile.TemporaryDirectory(dir="/tmp") as tmpdir:
config_path = self.config_file(tmpdir)
cmd = [
"miniwdl",
"run",
"--verbose",
]
if os.environ.get("BOTO_ENDPOINT_URL"):
cmd += ["--env", f"AWS_ENDPOINT_URL={os.environ.get('BOTO_ENDPOINT_URL')}"]
if config_path:
cmd += [
"--cfg",
config_path,
]
cmd += [os.path.abspath(workflow_path)]
cmd += [f"{k}={v}" for k, v in inputs.items()]
try:
p = subprocess.Popen(
["miniwdl", "run", "--verbose", os.path.abspath(workflow_path)]
+ [f"{k}={v}" for k, v in inputs.items()],
cmd,
cwd=tmpdir,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down