Skip to content
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

Python: Derive FluxExecutor from concurrent.futures.Executor #5323

Closed
wants to merge 1 commit into from
Closed

Conversation

jan-janssen
Copy link

In analogy to the FluxExecutorFuture being derived from concurrent.futures.Future now also the FluxExecutor is derived from concurrent.futures.Executor . This has two advantages, on the one hand the __enter__() and __exit__() functions are already defined and on the other hand frameworks which integrate interfaces for multiple Executors can check for classes derived from the concurrent.futures.Executor class.

In analogy to the `FluxExecutorFuture` being derived from `concurrent.futures.Future` now also the `FluxExecutor` is derived from `concurrent.futures.Executor` . This has two advantages, on the one hand the `__enter__()` and `__exit__()` functions are already defined and on the other hand frameworks which integrate interfaces for multiple Executors can check for classes derived from the `concurrent.futures.Executor` class.
@jameshcorbett
Copy link
Member

jameshcorbett commented Jul 12, 2023

When I wrote it I made a choice not to derive FluxExecutor from concurrent.futures.Executor, because the interface isn't the same. You can't take a FluxExecutor and treat it like an Executor. As the docstring of the class says:

    Inspired by the ``concurrent.futures.Executor`` class, with the following
    interface differences:

        - the ``submit`` method takes a ``flux.job.Jobspec`` instead of a
          callable and its arguments, and returns a ``FluxExecutorFuture``
          representing that job.
        - the ``map`` method is not supported, given that the executor consumes
          Jobspecs rather than callables.

I think these differences are significant and make it so that isinstance(FluxExecutor(), Executor) checks should not pass. Can you explain why you think they should pass?

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

❗ No coverage uploaded for pull request base (master@7696e21). Click here to learn what that means.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master    #5323   +/-   ##
=========================================
  Coverage          ?   83.33%           
=========================================
  Files             ?      463           
  Lines             ?    78739           
  Branches          ?        0           
=========================================
  Hits              ?    65617           
  Misses            ?    13122           
  Partials          ?        0           
Impacted Files Coverage Δ
src/bindings/python/flux/job/executor.py 94.33% <100.00%> (ø)

@jan-janssen
Copy link
Author

I think these differences are significant and make it so that isinstance(FluxExecutor(), Executor) checks should not pass. Can you explain why you think they should pass?

Makes sense - thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants