Machine Elf

An elf is an agent that perfoms tasks and share information on the mycelium. All elves must inherit from the MachineElf class.

Machine Elf

class blumycelium.machine_elf.Job(task, run_job_id, worker_elf, parameters, start_date, completion_date, status, mycelium, return_placeholder, dependencies)[source]

a Job for an elf

commit()[source]

save the job to the mycelium

class blumycelium.machine_elf.MachineElf(uid, mycelium)[source]

An elf that runs tasks

find_tasks()[source]

find all function whose name starts by task_

get_jobs()[source]

retuen the list of jobs for an elf

inspect_self()[source]

inspect the elf to get the source code etc…

register(store_source=False)[source]

register the elf to the mycelium

run_task(job_id: str, task_name: str, parameters: dict, store_failures: bool, raise_exceptions: bool)[source]

run a task for an elf

start_jobs(store_failures=True, raise_exceptions=True)[source]

start a job for an elf

class blumycelium.machine_elf.Task(machine_elf, function, name)[source]

Represent a task for an elf

inspect_function()[source]

inspect the function of a task

run(job_id, *args, **kwargs)[source]

run the task

wrap(*args, **kwargs)[source]

wrap the function inside a new function that creates a Job

class blumycelium.machine_elf.TaskParameters(fct, run_job_id, worker_elf)[source]

Parameters of a task

classmethod develop(mycelium, dct_params: dict)[source]

compute the value of parameters

find_placeholders_in_key_value_iterrator(iterator)[source]

find placeholders in dicts lists etc…

get_job_dependencies()[source]

return the dependencies of a job (jobs that must run before) based on the parameters received

get_parameter_dict()[source]

return a dictionary of parameters

validate()[source]

returns placeholders

class blumycelium.machine_elf.TaskReturnPlaceHolder(worker_elf, task_function, run_job_id)[source]

A place for the return of a task. Works as a dict, where each value is a key

get_result_id(name)[source]

return the result_id for value in the placeholder

make_placeholder()[source]

make and validate the placeholder

class blumycelium.machine_elf.ValuePlaceholder(*args, **kwargs)[source]

A placeholder for a value return by a task

set_origin(result_id)[source]

set the result id represented by the placeholder