-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconsider [Job|JobExecutor].setJobStatusCallback #177
Comments
@andre-merzky, thoughts? |
I think some of the difficulty here is that there are too many ways to do the same thing. I'd prefer fixing the definition of the job at initialization, making these properties read-only everywhere that can be tolerated. Similarly, for executors, if they have default properties like callbacks, they should be fixed on creation of the executor. Changes to the executor should definitely not effect already created jobs. |
I think I am in the opposite camp to @frobnitzem I'm afraid. I like that job's can be initialized in multiple steps as one then can separate concerns in job creation code: job = create_job
add_staging(job)
add_environment(job)
submit_job(job) That's not a useful example, but I hope it illustrates the point.
I think that adding a state callback at any point should trigger state callbacks for all jobs of that executor, not only for the ones submitted after. That would (needlessly) complicate implementation, but more importantly we need to consider reconnecting executors which certainly should invoke callbacks for jobs submitted earlier by different instances of the executor. I would favor |
While it would generally be good to keep discussions on different topics separate, I can see how the read-only properties and callbacks may be related. I'd like to point out that two ways to do things is not quite that many and the ability to initialize read-write fields through constructors is nearly universal across the imperative/OO language spectrum. There is also some precedent in Python standard libraries for this. Unfortunately, most classes in the Python standard libraries are rather simplistic, but, e.g., Thread allows setting the As for add/remove, there is some precedent in |
I'd like to append to my comment above that mutable state is much harder to reason about - so should not be used unless there's no other way. Especially for data that will be executed later it's important to control the number of code paths that update it (attack surface), and ideally have a single validation point where everything can be considered as a whole. Also practically, too many ways to modify the task graph (e.g. in Fireworks) creates many potential deadlock scenarios. |
Perhaps this should be documented better, but it's more of a quasi-mutable state: you build your spec object up to the point when you submit the job, after which modifications are irrelevant. There is also purposefully no task graph in PSI/J and the tasks are completely independent. A system built on top of it can and should take reasonable steps to avoid way of creating deadlocks. |
First, it seems like a property may be more appropriate here and, the inclusion of "job" in the method name may be superfluous. It is unlikely that significant ambiguity would be introduced if the name was simply
setStatusCallback
or even 'setCallback`.However, there are two other, more functional issues:
JobExecutor.get_instance
may return a singleton instance. A callback set on that instance previously would be overwritten by any new call tosetJobStatusCallback
. And, because the callback is a "write-only" property, there is no way to check whether a callback is already set.Suggested Clarification
We should either make
setJobStatusCallback
into a read/write property (jobStatusCallback
) or allow for multiple callbacks directly, e.g., by changing toaddJobStatusCallback
/removeJobStatusCallback
since it's a tried and tested method in both Java and Python.The text was updated successfully, but these errors were encountered: