Skip to content

Enhance concept of extension of job #21

Open
@eileen-kuehn

Description

@eileen-kuehn

In the context of caching the Job is defined by further information such as inputfiles but also statistics that are relevant for caching. The current implementation provides an extension of the basic Job and implements a CachingJob, see lapis/cachingjob.py.
With further extensions we might face issues by subclassing and specifically by overwriting the run method as it carries relevant logic for the simulation that is currently copied from the core Job:

async def run(self, drone: "Drone"):
"""
Handles the job's execution.
The job's runtime is given by max(calculation time, transfer time).
The calculation time is determined by `_calculate`, the transfer time by
`_transfer_inputfiles`.
The job will be executed successfully unless the selected drone does not
provide enough resources, is unavailable or an exception occurs.
:param drone: the drone object the job was allocated to and is executed in
"""
assert drone, "Jobs cannot run without a drone being assigned"
self.drone = drone
self.in_queue_until = time.now
self._success = None
await sampling_required.put(self)
try:
start = time.now
print(start)
async with Scope() as scope:
await instant
scope.do(self._transfer_inputfiles())
await (time + self._calculation_time)
except CancelTask:
print("CancelTask")
# self.drone = None
self._success = False
# await sampling_required.put(self)
# TODO: in_queue_until is still set
except BaseException:
# self.drone = None
self._success = False
await sampling_required.put(self)
# TODO: in_queue_until is still set
raise
else:
self.walltime = time.now - start
self._success = True
await sampling_required.put(self)

For future maintainability we should consider a different approach here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions