Setup base for training jobs. Added sd-scripts as a submodule

This commit is contained in:
Jaret Burkett
2023-07-08 13:50:59 -06:00
parent 37354b006e
commit 47d094e528
13 changed files with 151 additions and 18 deletions

View File

@@ -1,4 +1,7 @@
from collections import OrderedDict
from typing import List
from jobs.process import BaseProcess
class BaseJob:
@@ -6,6 +9,7 @@ class BaseJob:
job: str
name: str
meta: OrderedDict
process: List[BaseProcess]
def __init__(self, config: OrderedDict):
if not config:
@@ -37,6 +41,25 @@ class BaseJob:
# be sure to call super().run() first
pass
def load_processes(self, process_dict: dict):
# only call if you have processes in this job type
if 'process' not in self.config:
raise ValueError('config file is invalid. Missing "config.process" key')
if len(self.config['process']) == 0:
raise ValueError('config file is invalid. "config.process" must be a list of processes')
# add the processes
self.process = []
for i, process in enumerate(self.config['process']):
if 'type' not in process:
raise ValueError(f'config file is invalid. Missing "config.process[{i}].type" key')
# check if dict key is process type
if process['type'] in process_dict:
self.process.append(process_dict[process['type']](i, self, process))
else:
raise ValueError(f'config file is invalid. Unknown process type: {process["type"]}')
def cleanup(self):
# if you implement this in child clas,
# be sure to call super().cleanup() LAST