Skip to content

Commit

Permalink
Configure local plugin to launch into czidnet (#111)
Browse files Browse the repository at this point in the history
* add config to miniwdl run

* configure local plugin to launch into czidnet

* remove config file
  • Loading branch information
rzlim08 authored Jan 31, 2024
1 parent 139b53f commit 43068c0
Showing 1 changed file with 33 additions and 2 deletions.
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 @@ -11,6 +11,7 @@
import threading
from typing import List
from uuid import uuid4
from pathlib import Path
import re

from plugins.plugin_types import (
Expand Down Expand Up @@ -51,6 +52,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" }
[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 @@ -61,10 +78,24 @@ async def _run_workflow_work(
"""Run miniwdl workflows locally"""
await event_bus.send(WorkflowStartedMessage(runner_id=runner_id))
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

0 comments on commit 43068c0

Please sign in to comment.