Lighthouse library doc

Warning

This document is autogenerated

class Task

Base class for implementing task. Payload goes to execute method

execute(enter_params, result_writer, log_writer, temp_directory)

Payload for task goes here

Parameters
  • enter_params (collections.namedtuple) –

  • result_writer (ResultWriter) –

  • log_writer (LogWriter) –

  • temp_directory (str) –

get_category()

Returns task category

Return type

str

get_description()

Returns task short description

Return type

str

get_display_name()

Returns task display name

Return type

str

abstract get_enter_params()

Returns task enter parameters collection. If they are not required, must return empty collection

Return type

EnterParamCollection

get_gis_macros()

Returns collection of gis macros

Return type

MacroCollection

get_graph_macros()

Returns collection of schema macros

Return type

MacroCollection

abstract get_headers()

Returns all task headers in collection, or just one header

Return type

HeaderCollection or Header

get_id()

Task unique id in uuid4 format (string)

Return type

str

get_schemas()

Returns all task schemas in collection, or just one schema

Return type

SchemaCollection or Schema

get_weight_function()
Returns

weight calculation function for task

Return type

str

class Utils

Miscellaneous utils class

classmethod base64string(path)

Gets base64 string from given file. Use this to set image properties

Parameters

path (str) – path to file

Returns

base64 string

Return type

str

classmethod base64string_from_bytes(obj)

Gets base64 string from bytes object

Parameters

obj (bytes) –

Returns

base64 string

Return type

str

class BinaryType

Defines type of binary fields

classmethod values()
Return type

set

class ValueType

Defines the only allowed types for enter parameters, header fields, etc.

classmethod values()
Return type

set

class ValueSource(source, param_switch=None, value_switch=None)

Describes value source of attribute for schema extensions

property name
Return type

str

property param_switch
Return type

str

property value_switch
Return type

str

class Field(display_name, type, binary_type='none', system_name='')

Describes field in result table header. Base for EnterParamField

property binary_type
Return type

str

property display_name
Return type

str

property system_name
Return type

str

property type
Return type

str

class EnterParamField(system_name, display_name, type, is_array=False, required=False, geo_json=False, file_path=False, default_value=None, predefined_values=None, value_sources=None, category=None, description=None)

Enter parameter for task

class EnterParamCollection(*fields)

Ordered collection of task enter parameters

add(ep_field)

Add EnterParamField to collection

Parameters

ep_field (EnterParamField) –

add_enter_param(system_name, display_name, type, is_array=False, required=False, geo_json=False, file_path=False, default_value=None, predefined_values=None, value_sources=None, category=None, description=None)

Adds new enter parameter to collection

Parameters
  • system_name (str) – field system name; system names in collection must be unique

  • display_name (str) – field name to show

  • type (ValueType) – field type

  • is_array (bool) – is array of values instead of single value

  • required (bool) – is required parameter

  • geo_json (bool) –

  • file_path (bool) – is field representing path to a file

  • default_value – default value, depending on ValueType

  • predefined_values (list) – List[Any, …], list of predefined field values

  • value_sources (list) – List[ValueSource, …], list of value sources

  • category (str) – category for grouping enter parameters

  • description (str) – text description of enter parameter

get(key, default=None)

Get EnterParamField by system name

Parameters
  • key (str) – field system name

  • default

Returns

field

Return type

EnterParamField

class Header

Describes result data table header

create_empty()

Creates empty line

Returns

Dictionary with header fields and empty values

Return type

dict

property dtype

Dtype for pandas as dict {field.system_name: type}

property fields

All header fields as list

get_fields()
Returns

All header fields and their names as keys, ordered

Return type

collections.OrderedDict

set_property(field_name, property, value)

Set custom header property

Parameters
  • field_name (str) –

  • property (str) –

  • value

property system_name
Return type

str

class HeaderCollection(*headers)

Collection of all resulting headers in task

add_headers(*headers)

Adds multiple headers to collection

Parameters

headers (Header) –

class Condition(column, operation, operand)

Defines condition, leading to object or link appearance in result graph. Example: Condition(“name”, Operation.StartsWith, “A”)

class Operations

Defines basic logical operations for Condition class

classmethod values()
Return type

set

class GraphMappingFlags

Defines mapping flags for schema Macro

classmethod values()
Return type

set

class GisMappingFlags

Defines mapping flags for gis Macro

classmethod values()
Return type

set

class UnionMode

Defines union mode between multiple Conditions (“And”, “Or”)

classmethod values()
Return type

set

class Schema

Describes graph schema, mapped to specific header, with objects and links between them

get_entities()
Return type

tuple

get_name()
Return type

str

set_property(key1, key2, value)

Set custom schema property

Parameters
  • key1 (str) –

  • key2 (str) –

  • value

class SchemaCollection(*schemas)

Collection of all task’s schemas

add_schemas(*schemas)

Adds schema(s) to collection.

Throws exception if schema with such name already presented in collection (names must be unique)

class Object

Custom object type for schema

get_attributes()
Returns

All object attributes, ordered

Return type

list

get_attributes_dict()
Returns

Dict of attributes {class field name: attribute}

Return type

dict

schematic(mapping, conditions=None, condition_union_mode='And', condition_ignore_case=True)

Creates SchemaObject instance of this type on schema

Parameters
  • mapping (dict|Header) –

  • conditions (list) –

  • condition_union_mode (str) –

  • condition_ignore_case (bool) –

Returns

SchemaObject instance of this type

Return type

SchemaObject

Custom type of the link. Must contain Begin and End attributes, which are object types

between(begin, end, mapping, conditions=None, condition_union_mode='And', condition_ignore_case=True)

Dynamically creates SchemaLink of this type between two objects on schema

Parameters
  • begin (SchemaObject) –

  • end (SchemaObject) –

  • mapping (dict|Header) –

  • conditions (list) –

  • condition_union_mode (str) –

  • condition_ignore_case (bool) –

Returns

SchemaLink, connecting objects

Return type

SchemaLink

get_attributes()
Returns

All link attributes, ordered

Return type

list

get_attributes_dict()
Returns

Dict of attributes {class field name: attribute}

Return type

dict

property system_name
Return type

str

class SchemaObject(type, mapping, conditions=None, condition_union_mode='And', condition_ignore_case=True)

Describes object on schema or map

Create empty link between objects

Parameters
  • other (SchemaObject) – any SchemaObject

  • custom_name (str) – set a specific name to generated Link type

Returns

link from this to other object

Return type

SchemaLink

Link between two objects on schema

copy()

Creates a copy of Link and preserves begin and end objects references

Return type

SchemaLink

Returns

new SchemaLink, connecting same objects

class Attribute(name, type, image=None)

Describes custom link or object attribute

add_columns(*columns)

Adds column to attribute

Parameters

columns (Field) – header column

clone()

Creates identical copy of Attribute object

Return type

Attribute

Returns

new Attribute object

property columns
Return type

list

property name
Return type

str

similar_to(other)

Compare name and ValueType

Parameters

other (Attribute) –

Returns

Attributes are the same (or cloned)

Return type

bool

property value_type
Return type

str

class Macro(name, mapping_flags=None, schemas=None, switches=None, drops=None, drop_delta=False)

Describes a macro for schema extensions

add_drops(fields)

Set which params will be dropped to default values by this macro

Parameters

fields (list|str) – Iterable[EnterParamField or system_name] or single EnterParamField or system_name

add_mapping_flags(*flags)

Adds mapping flags to a macro

Parameters

flags (str) – GraphMappingFlags or GisMappingFlags: unique mapping flags

add_schemas(*schemas)

Adds schemas names to a macro

Parameters

schemas (Schema) – unique mapping flags

add_switches(values)

Define values for enterparams

Parameters

values (dict) – {EnterParamField or system_name: obj}

property name
Return type

str

class MacroCollection(*macros)

Collection of all user macros

add_macro(name, mapping_flags=None, schemas=None)

Adds new macro to collection

Parameters
  • name (str) – macro name

  • mapping_flags (list) – [str, …] list of mapping flags (defined in GraphMappingFlags, GisMappingFlags)

  • schemas (list) – list of schems

add_macros(*macros)

Adds macros to collection

Parameters

macros (Macro) –

class Task

Base class for implementing task. Payload goes to execute method

execute(enter_params, result_writer, log_writer, temp_directory)

Payload for task goes here

Parameters
  • enter_params (collections.namedtuple) –

  • result_writer (ResultWriter) –

  • log_writer (LogWriter) –

  • temp_directory (str) –

get_category()

Returns task category

Return type

str

get_description()

Returns task short description

Return type

str

get_display_name()

Returns task display name

Return type

str

abstract get_enter_params()

Returns task enter parameters collection. If they are not required, must return empty collection

Return type

EnterParamCollection

get_gis_macros()

Returns collection of gis macros

Return type

MacroCollection

get_graph_macros()

Returns collection of schema macros

Return type

MacroCollection

abstract get_headers()

Returns all task headers in collection, or just one header

Return type

HeaderCollection or Header

get_id()

Task unique id in uuid4 format (string)

Return type

str

get_schemas()

Returns all task schemas in collection, or just one schema

Return type

SchemaCollection or Schema

get_weight_function()
Returns

weight calculation function for task

Return type

str

class ResultWriter(output_file, headers)

Writes result row to table(s). This class is not supposed to be instatiated by user.

close()

Closes all output file handlers. For internal usage

write_dataframe(dataframe, header_class=None)

Write pandas Dataframe rows to result table. If no header_class provided, columns must be named after field names or field system names

If header_class IS provided, columns must fit header length (field count)

Parameters
  • dataframe (pandas.Dataframe) –

  • header_class (Header) –

write_line(values, header_class=None)

Writes line of data to specific (or the auto-detected) header

Parameters
  • values (dict) – flat dictionary of header columns and their values: {header.field: value}

  • header_class (Header) – (optional) [recommended] specify header for line

class LogWriter

Logs user messages to STDOUT or STDERR. This class is not supposed to be instatiated by user.

error(message, *args)

Prints formatted message to STDERR. Formatting is similar to message.format(*args)

Parameters
  • message (str) – message

  • args (str) – format arguments

info(message, *args)

Prints formatted message to STDOUT. Formatting is similar to message.format(*args)

Parameters
  • message (str) – message

  • args (str) – format arguments

class RelativeDate(reference_point, offset)

Describes relative date using datetime.timedelta for offset

class ReferencePoint

Starting point options for time offset - from start of the day or current time

classmethod values()
Return type

set

class Localization

Describes how to translate task and entities to another language

class LocalizationScopes

Scopes, available for manual add into culture

class TaskLocalizationItems

All values in ‘Task’ scope, that can be localized