databay.inlet

See also

  • Extending Inlets to learn how to extend this class correctly.

  • Outlet representing the corresponding output of the data stream.

class databay.inlet.Inlet(metadata: dict = None)[source]

databay.inlet.Inlet

Abstract class representing an input of the data stream.

Parameters

metadata (dict) – Global metadata that will be attached to each record generated by this inlet. It can be overridden or appended to by providing metadata when creating a record using new_record() function.

Default:
None

Bases: abc.ABC

metadata(self)[source]

property

Global metadata that will be attached to each record generated by this inlet. It can be overridden or appended to by providing metadata when creating a record using new_record() function.

Returns

Metadata dictionary.

Return type

dict

pull(self, update: da.Update) → List[Record][source]

abstractmethod

Produce new data.

Override this method to define how this inlet will produce new data.

Parameters

update (Update) – Update object representing the particular Link update run.

Returns

List of records produced

Return type

list[Record]

new_record(self, payload, metadata: dict = None) → Record[source]

Create a new Record. This should be the preferred way of creating new records.

Parameters
  • payload (Any) – Data produced by this inlet.

  • metadata (dict) – Local metadata that will override and/or append to the global metadata. It will be attached to the new record.

    Default:
    None

Returns

New record created

Return type

Record

try_start(self)[source]

Wrapper around on_start call that will ensure it only gets executed once.

on_start(self)[source]

Called once per inlet just before the governing planner is about to start.

Override this method to provide starting functionality on this inlet.

try_shutdown(self)[source]

Wrapper around on_shutdown call that will ensure it only gets executed once.

on_shutdown(self)[source]

Called once per inlet just after the governing planner has shutdown.

Override this method to provide shutdown functionality on this inlet.

active(self)[source]

property

Whether this inlet is active and ready to pull. This variable is set by the governing link to True on start and to False on shutdown.

Default:
False

Return type

bool