Reworked so everything is in classes for easy expansion. Single entry point for all config files now.

This commit is contained in:
Jaret Burkett
2023-07-08 09:51:42 -06:00
parent 27df03a486
commit 37354b006e
16 changed files with 424 additions and 189 deletions

43
jobs/BaseJob.py Normal file
View File

@@ -0,0 +1,43 @@
from collections import OrderedDict
class BaseJob:
config: OrderedDict
job: str
name: str
meta: OrderedDict
def __init__(self, config: OrderedDict):
if not config:
raise ValueError('config is required')
self.config = config['config']
self.job = config['job']
self.name = self.get_conf('name', required=True)
if 'meta' in config:
self.meta = config['meta']
else:
self.meta = OrderedDict()
def get_conf(self, key, default=None, required=False):
if key in self.config:
return self.config[key]
elif required:
raise ValueError(f'config file error. Missing "config.{key}" key')
else:
return default
def run(self):
print("")
print(f"#############################################")
print(f"# Running job: {self.name}")
print(f"#############################################")
print("")
# implement in child class
# be sure to call super().run() first
pass
def cleanup(self):
# if you implement this in child clas,
# be sure to call super().cleanup() LAST
del self