Class: MetadataRouter
Stores and handles metadata routing for a router object.
This class is used by router objects to store and handle metadata routing. Routing information is stored as a dictionary of the form {"object_name": RouteMappingPair(method_mapping, routing_info)}, where method_mapping is an instance of MethodMapping and routing_info is either a MetadataRequest or a MetadataRouter instance.
Constructors
new MetadataRouter()
new MetadataRouter(
opts?):MetadataRouter
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | object | - |
opts.owner? | string | The name of the object to which these requests belong. |
Returns MetadataRouter
Defined in generated/utils/metadata_routing/MetadataRouter.ts:23
Properties
| Property | Type | Default value | Defined in |
|---|---|---|---|
_isDisposed | boolean | false | generated/utils/metadata_routing/MetadataRouter.ts:21 |
_isInitialized | boolean | false | generated/utils/metadata_routing/MetadataRouter.ts:20 |
_py | PythonBridge | undefined | generated/utils/metadata_routing/MetadataRouter.ts:19 |
id | string | undefined | generated/utils/metadata_routing/MetadataRouter.ts:16 |
opts | any | undefined | generated/utils/metadata_routing/MetadataRouter.ts:17 |
Accessors
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge):void
Parameters
| Parameter | Type |
|---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/utils/metadata_routing/MetadataRouter.ts:33
Methods
add()
add(
opts):Promise<any>
Add named objects with their corresponding method mapping.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.method_mapping? | any | The mapping between the child and the parent’s methods. |
opts.objs? | any | A dictionary of objects from which metadata is extracted by calling get_routing_for_object on them. |
Returns Promise<any>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:102
add_self_request()
add_self_request(
opts):Promise<any>
Add self (as a consumer) to the routing.
This method is used if the router is also a consumer, and hence the router itself needs to be included in the routing. The passed object can be an estimator or a MetadataRequest.
A router should add itself using this method instead of add since it should be treated differently than the other objects to which metadata is routed by the router.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.obj? | any | This is typically the router instance, i.e. self in a get_metadata_routing() implementation. It can also be a MetadataRequest instance. |
Returns Promise<any>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:143
consumes()
consumes(
opts):Promise<any>
Check whether the given parameters are consumed by the given method.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.method? | string | The name of the method to check. |
opts.params? | any | An iterable of parameters to check. |
Returns Promise<any>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:177
dispose()
dispose():
Promise<void>
Disposes of the underlying Python resources.
Once dispose() is called, the instance is no longer usable.
Returns Promise<void>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:85
init()
init(
py):Promise<void>
Initializes the underlying Python resources.
This instance is not usable until the Promise returned by init() resolves.
Parameters
| Parameter | Type |
|---|---|
py | PythonBridge |
Returns Promise<void>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:46
route_params()
route_params(
opts):Promise<any>
Return the input parameters requested by child objects.
The output of this method is a bunch, which includes the metadata for all methods of each child object that is used in the router’s caller method.
If the router is also a consumer, it also checks for warnings of self’s/consumer’s requested metadata.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.caller? | string | The name of the method for which the parameters are requested and routed. If called inside the fit method of a router, it would be "fit". |
opts.params? | any | A dictionary of provided metadata. |
Returns Promise<any>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:218
validate_metadata()
validate_metadata(
opts):Promise<any>
Validate given metadata for a method.
This raises a TypeError if some of the passed metadata are not understood by child objects.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.method? | string | The name of the method for which the parameters are requested and routed. If called inside the fit method of a router, it would be "fit". |
opts.params? | any | A dictionary of provided metadata. |
Returns Promise<any>
Defined in generated/utils/metadata_routing/MetadataRouter.ts:257