Enabled and fixed python type annotations in some modules in the executors
package.
#3525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enabled and fixed python type annotations in some modules in the
executors
package.This revealed two Python typing-related issues:
executor_base.Executor
was using a property on the corresponding subclass ofexecutor_value_base.ExecutorValue
without having access to that property. This was fixed by:federating_executor.FederatingStrategy
(FederatedComposingStrategy
andFederatedResolvingStrategy
) were annotated to return types specific to that subclass. This return type conflicted with the return types of the shared implementations defined inexecutor_utils
.target_executors
parameter ofFederatedResolvingStrategy
was incorrect.federated_composing_strategy
federated_resolving_strategy
federating_executor
reference_resolving_executor
remote_executor
thread_delegating_executor
value_serialization
To fix issue #1:
reference
property from the subclasses ofexecutor_value_base.ExecutorValue
toexecutor_value_base.ExecutorValue
.To fix issue #2:
federating_executor.FederatingStrategy
(FederatedComposingStrategy
andFederatedResolvingStrategy
) to accept and returnexecutor_value_base.ExecutorValue
types.Note: That this does make the return types more generic, but I believe this is the intended interface. An alternative fix could be to update the
executor_utils
function to take and returnTypeVar
's (i.e. generic functions). However, I don't think this is the intended interface.To fix issue #3:
target_executors
parameter todict[placements.PlacementLiteral, Union[list[executor_base.Executor], executor_base.Executor]]
.