client

Attributes

S3_BASE_LANES_FILE

Exceptions

LeafGraphException

Common base class for all non-exit exceptions.

Classes

LeafGraphClient

Module Contents

exception client.LeafGraphException

Bases: Exception

Common base class for all non-exit exceptions.

class client.LeafGraphClient(host: str | None = None, port: int | None = 7687, username: str | None = None, password: str | None = None, **kwargs)

Bases: gqlalchemy.Memgraph

Parameters:
  • host (Optional[str]) –

  • port (Optional[int]) –

  • username (Optional[str]) –

  • password (Optional[str]) –

build_graph(drop_existing: bool = False) None

Pulls all network lanes from Postgres and updates the graph DB. Check the pgSQL analytics.get_company_network_lanes for details on which lanes are included.

Parameters:

drop_existing (bool, optional) – Drop existing graph nodes. Defaults to False.

Return type:

None

check_lanes(lane_ids: List[str]) int

Given a list of lane IDs, returns the number of lane IDs that exist in the graph.

Parameters:

lane_ids (List[str]) – List of lane IDs to check.

Returns:

Number of (lane) IDs that exist in the graph.

Return type:

int

count_nodes(labels: str | List[str] | None = None, **kwargs) int
Parameters:

labels (Union[str, List[str], None]) –

Return type:

int

count_relationships(relationship_type: str | None = None) int
Parameters:

relationship_type (str | None) –

Return type:

int

create_indexes() None
Return type:

None

delete_disconnected_locations() None

Delete origins and destinations that are not connected to any lanes.

Return type:

None

delete_lanes_by_company_id(company_id: int, record_type: str, equipment_class: str = 'DRY') None
Parameters:
  • company_id (int) –

  • record_type (str) –

  • equipment_class (str) –

Return type:

None

delete_lanes_by_id(lane_ids: list[str]) None
Parameters:

lane_ids (list[str]) –

Return type:

None

get_all_owners() List[int]

Returns a list of all owner IDs in the graph.

Returns:

List of owner IDs.

Return type:

List[int]

update_from_df(lanes_df: pandas.DataFrame) None
Parameters:

lanes_df (pandas.DataFrame) –

Return type:

None

update_from_file(file_url: str) None
Parameters:

file_url (str) –

Return type:

None

update_long_deadhead_relationships() None
Return type:

None

update_short_deadhead_relationships() None
Return type:

None

client.S3_BASE_LANES_FILE = 'adapt_assets/graph_lanes.json'