Commit 153f5268 authored by Vlad Calin's avatar Vlad Calin

remove params

parent 9ddeea42
from workloads import params
from workloads.registry import WorkloadRegistry
from workloads.workload import Workload, step
......@@ -8,11 +7,6 @@ registry = WorkloadRegistry()
@registry.register
class FileProcessingWorkload(Workload):
name = 'file_processing'
parameters = [
params.Parameter('test_1'),
params.Parameter('test_2'),
params.Parameter('test_3'),
]
@step('start')
def start(self):
......
......@@ -16,7 +16,6 @@ setup(
packages=find_packages(exclude=['examples']),
install_requires=[
'click',
'celery',
'redis'
],
extras_require={
......
class Parameter(object):
def __init__(self, name):
self.name = name
......@@ -45,10 +45,7 @@ class WorkloadRegistry(object):
for wl in self.workloads:
decorator = run_cli.command(wl.name)
decorator = decorator(functools.partial(run_workload, wl))
decorator = click.option('--queue', required=True)(decorator)
for param in wl.parameters:
decorator = parameter_to_click_option(param)(decorator)
return cli
......
import inspect
class Workload(object):
name = None
parameters = []
def __init__(self):
self.steps = self.discover_steps()
def run(self, queue, *, start_step='start'):
print("running with queue {}".format(queue))
print("start step {}".format(start_step))
def discover_steps(self):
steps = {}
for attr_name in dir(self):
attr = getattr(self, attr_name)
if inspect.ismethod(attr) and hasattr(attr, '__workloads_step__'):
steps[attr.__workloads_step__] = attr
return steps
def step(name):
def decorator(func):
func.__workloads_step__ = name
return func
def step(func):
pass
return decorator
def run_workload(cls, queue, **params):
print(cls)
print(queue)
print(params)
def run_workload(cls, queue):
workload = cls()
workload.run(queue)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment