DocumentationClassesMetadataRouter

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.

Python Reference

Constructors

new MetadataRouter()

new MetadataRouter(opts?): MetadataRouter

Parameters

ParameterTypeDescription
opts?object-
opts.owner?stringThe name of the object to which these requests belong.

Returns MetadataRouter

Defined in generated/utils/metadata_routing/MetadataRouter.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/utils/metadata_routing/MetadataRouter.ts:21
_isInitializedbooleanfalsegenerated/utils/metadata_routing/MetadataRouter.ts:20
_pyPythonBridgeundefinedgenerated/utils/metadata_routing/MetadataRouter.ts:19
idstringundefinedgenerated/utils/metadata_routing/MetadataRouter.ts:16
optsanyundefinedgenerated/utils/metadata_routing/MetadataRouter.ts:17

Accessors

py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

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

ParameterTypeDescription
optsobject-
opts.method_mapping?anyThe mapping between the child and the parent’s methods.
opts.objs?anyA 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

ParameterTypeDescription
optsobject-
opts.obj?anyThis 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

ParameterTypeDescription
optsobject-
opts.method?stringThe name of the method to check.
opts.params?anyAn 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

ParameterType
pyPythonBridge

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

ParameterTypeDescription
optsobject-
opts.caller?stringThe 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?anyA 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

ParameterTypeDescription
optsobject-
opts.method?stringThe 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?anyA dictionary of provided metadata.

Returns Promise<any>

Defined in generated/utils/metadata_routing/MetadataRouter.ts:257