databay
stable
  • Key Concepts
  • Advanced Concepts
  • Extending Databay
  • Examples
  • Databay API Reference
    • - inlets
    • - misc
    • - outlets
    • - planners
    • - support
    • base_planner
    • errors
    • inlet
    • link
      • Update
      • Link
        • inlets
        • add_inlets
        • remove_inlets
        • outlets
        • add_outlets
        • remove_outlets
        • interval
        • set_job
        • job
        • name
        • tags
        • transfer
        • on_start
        • on_shutdown
    • outlet
    • record
  • Source Code
  • GitHub Page
databay
  • »
  • Databay API Reference »
  • databay.link
  • Edit on GitHub

databay.link¶

Contents:

Update

Data structure representing one Link transfer. When converted to string returns {tags}.{transfer_number}

Link

Link in the relationship graph. Use this class to define relationships between inlets and outlets.

class databay.link.Update(tags: List[str], transfer_number: int)[source]¶

databay.link.Update

Data structure representing one Link transfer. When converted to string returns {tags}.{transfer_number}

Parameters
  • tags (List[str]) – Tags of the link, see: Link.

  • transfer_number (int) – Incremental identifier of the current transfer.

class databay.link.Link(inlets: Union[Inlet, List[Inlet]], outlets: Union[Outlet, List[Outlet]], interval: Union[datetime.timedelta, int, float], tags: Union[str, List[str]] = None, copy_records: bool = True, ignore_exceptions: bool = False, catch_exceptions: bool = None, inlet_concurrency: int = 9999, immediate_transfer: bool = True, processors: Union[callable, List[callable]] = None, groupers: Union[callable, List[callable]] = None, name=None)[source]¶

databay.link.Link

Link in the relationship graph. Use this class to define relationships between inlets and outlets.

Parameters
  • inlets (Inlet or list[Inlet]) – inlets to add to this link.

  • outlets (Outlet or list[Outlet]) – outlets to add to this link.

  • interval (Union[datetime.timedelta, int, float]) – Expects datetime.timedelta. Alternatively, you can provide int or float which will be coerced explicitly to datetime.timedelta.seconds.

  • tags (Union[str, List[str]]) – List of tags of this link.

    Default:
    []

  • copy_records (bool) – Whether to copy records before passing them to outlets.

    Default:
    True

  • ignore_exceptions (bool) – Whether exceptions in inlets and outlets should be logged and ignored, or raised.

    Default:
    True

  • inlet_concurrency (int) – How many inlets are allowed to execute concurrently.

    Default:
    9999

  • immediate_transfer (bool) – Whether governing planners that have BasePlanner.immediate_transfer set to True should execute this link’s transfer once immediately upon starting.

    Default:
    True

  • processors (callable or list[callable]) – Processors of this link.

    Default:
    None

  • groupers (callable or list[callable]) – groupers of this link.

    Default:
    None

inlets(self) → List[Inlet][source]¶

property

Inlets handled by this link.

Returns

list[Inlet]

add_inlets(self, inlets: Union[Inlet, List[Inlet]])[source]¶

Add inlets to this link. Inlets must be of type Inlet and not currently added to this link.

Parameters

inlets (Inlet or list[Inlet]) – inlets to add to this link

Raises

InvalidNodeError if this link already contains any of the inlets being added.

remove_inlets(self, inlets: Union[Inlet, List[Inlet]])[source]¶

Remove inlets from this link.

Parameters

inlets (Inlet or list[Inlet]) – inlets to remove from this link

Raises

InvalidNodeError if this link doesn’t contain any of the inlets being removed.

outlets(self) → List[Outlet][source]¶

property

Outlets handled by this link.

Returns

list[Outlet]

add_outlets(self, outlets: Union[Outlet, List[Outlet]])[source]¶

Add outlets to this link. Outlets must be of type Outlet and not currently added to this link.

Parameters

outlets (Outlet or list[Outlet]) – outlets to add to this link

Raises

InvalidNodeError if this link already contains any of the outlets being added.

remove_outlets(self, outlets: Union[Outlet, List[Outlet]])[source]¶

Remove outlets from this link.

Parameters

outlets (Outlet or list[Outlet]) – outlets to remove from this link

Raises

InvalidNodeError if this link doesn’t contain any of the outlets being removed.

interval(self) → datetime.timedelta[source]¶

property

Frequency at which this link should transfer.

Returns

interval object

Return type

datetime.timedelta

set_job(self, job)[source]¶
Parameters

job (Any) – specify the job this link is executed with.

job(self) → Any[source]¶

property

The job this link is executed with. Job should persist between link transfers.

Default:
None

Returns

Job this link is executed with.

name(self) → str[source]¶

property

Deprecated in 0.2.0, will be removed in 1.0. Use Link.tags instead.

Name of this Link, equivalent to first tag of this link.

Returns

Name of this link

Return type

str

tags(self) → List[str][source]¶

property

The tags of this link.

Default:
[]

Returns

Tags of this link

Return type

List[str]

transfer(self)[source]¶

Execute one transfer on this link. This will run through all inlets querying them for data, then pass that data to all outlets.

See Link transfer to learn more about the transfer.

on_start(self)[source]¶

Called when the governing planner is about to start. Calls try_start on all inlets and outlets of this link.

If an inlet or outlet is present in multiple links its on_start will only be called once by whichever link executes first.

on_shutdown(self)[source]¶

Called just after the governing planner has shutdown. Calls try_shutdown on all inlets and outlets of this link.

If an inlet or outlet is present in multiple links its on_shutdown will only be called once by whichever link executes first.

Next Previous

© Copyright 2020, Voy Zan Revision e9caae58.

Built with Sphinx using a theme provided by Read the Docs.