feat: multi-input multi-resource type operators - #1248
Draft
michael-johnston wants to merge 38 commits into
Draft
Conversation
- ADOResourceReference - this is a model that refers to a resource in the metastore i.e. an id and a kind. The model is not frozen, and kind can be None, allowing kind to be deduced after model instantion. - ADOResourcePropertyDescriptor - this is a model that says a identifier (str) has a particular type. The model is frozen, kind must be given. The use of this is to carry information about the type of an ado operator function parameter.
Prior to this change only a single DiscoverySpace could be specified as an ADOResource input to an operation. This change allows any number of resources of any kind to be passed DiscoveryOperationResourceConfiguration: - New "input" field allows specifying, for named operator input parameters, the ADO resource in the metadstore that should be used to pass a value to that parameter. - validation: the input field can (conditionally via a context) be validated against the operator i.e. check the parameters named exist, check the kind of the resource referenced matches the parameters type. Also if the kind in reference is None, this sets it with the correct kind. OperatorMetadata: New field required_resource_inputs for holding the operator parameters that required ADO resources, and the kind of resource. Used to do the validation above.
In preflight check for operation ids
- Defines rich types for ado resources (DataContainer and DiscoverySpace for now) - Converts a resource reference (resource id + kind) to the rich type instance
Prior to this there was a single rule for all operators types - only 1 discovery space alloed. The module expresses the expanded rules for resource inputs for each operator type e.g. fuse must have 2+ discovery spaces. It also provides a function validate_resource_inputs_for_operation_type to validate if a set of resource inputs are valid for a given operation type
Previously we had strict function signature defined in a protocol. Now operators can have more general signature new validation is required - validate_operator_call_shape: Checks the operator function has some number of resource inputs, followed by operationInfo, followed by keyword args - validate_resource_input_types: Checks that a set of proposed inputs to an operator match what it wants - validate_operator_registration: Combines the three checks (two above + validate_resource_inputs_for_operation_type)
Also add new collections for compare and fuse operators
instead of pydantic.BaseModel
Also - pass metastore explicitly - use GenericOptionaParameters not dict
Instead of kwargs
wrong name
Also use orchestrate_core interface
Also use GenericOperatorParameters
Also use GenericOperatorParameters
Previously wrappers took and passed a dump of the operators parameters. Now it takes and passes the actual object. In addition with multiple inputs its not guaranteed the metastore can be accessed (previously was always available as only discoveryspace's could be passed). Now retrieve the context to use via FunctionOperationInfo or use active context if that isn't available. Create metastore from this.
So it can be retrieved in other places in the code. However this will not work in multi-process jobs.
Instead as fall back look for resources that carry the context with them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces multi-input multi-resource type operators. It also enforces passing of operator parameters by instances of the operator parameter model (answers #647) e.g.
Note: Here we use
OperatorInputTypeto denote the allowed input types e.g. DiscoverySpace (see more below) and GenericOperatorParameters as a placeholder for the specific parameter model of the operatorPrior to this PR operators could only work on a single input resource, which had to be of type DiscoverySpace and named discoverySpace. Further the parameters for the operator were passed as keyword args i.e.
Operator Input Types
ADO resources that can be operated on are now associated with a "rich" type that will be passed to the operator. In the PR we have two resources that can be operated on
Note: Its a particular property of DataContainerResource that it can be its own rich type.
Setting inputs in operation.yaml
The PR removes the DiscoveryOperationConfiguration
spacesfield and introduce the more generalinputfield.before
now, for an operator with two DiscoverySpace input params called space_one and space_two
In practice
kindcan be inferred when the YAML is read so users can omit itNon-breaking changes
spacesfield is kept as a computed field, so any code relying on querying it in metastore does not need to be changedinputfield if read. Not breakingBreaking changes
Code Changes
The code changes fall into three groups: