forked from slac-lcls/lute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_task.py
47 lines (38 loc) · 1.15 KB
/
run_task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
import argparse
import logging
import os
from lute.io.config import *
from lute.execution.executor import *
if __debug__:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
logger: logging.Logger = logging.getLogger(__name__)
parser: argparse.ArgumentParser = argparse.ArgumentParser(
prog="run_managed_task",
description="Run a LUTE managed task.",
epilog="Refer to https://github.com/slac-lcls/lute for more information.",
)
parser.add_argument(
"-c", "--config", type=str, help="Path to config file with Task parameters."
)
parser.add_argument(
"-t",
"--taskname",
type=str,
help="Name of the Managed Task to run.",
default="test",
)
args: argparse.Namespace = parser.parse_args()
config: str = args.config
task_name: str = args.taskname
# Environment variables need to be set before importing Executors
os.environ["LUTE_CONFIGPATH"] = config
from lute import managed_tasks
if hasattr(managed_tasks, task_name):
managed_task: Executor = getattr(managed_tasks, task_name)
else:
logger.debug(f"{task_name} unrecognized!")
sys.exit(-1)
managed_task.execute_task()