Utils

orion_notebook.utils.execute_js_on_notebook(code: str)None

Executes a Javascript piece of code in the notebook

Param

the Javascript code to execute

Type

str

orion_notebook.utils.filesize_entry_formatter(filesize: Union[None, int])

Function to safely get the ‘FileSize’ entry from a dict. Returning a user legible value

Parameters

filesize (Union[None, int]) – variable containing the size of a file

Returns

If fiesize is not None and greater than 0, the filesize is returned. Otherwise, ‘Unknown’

Return type

str

orion_notebook.utils.get_event_label(action_id: int)str

Gets the label corresponding to an action id

Parameters

action_id (int) – Id of the action to get the label

Returns

The label of the action with the provided id

Return type

str

orion_notebook.utils.get_source_code_of_method()str

Gets the filename and method name from of the method invoking this function and returns it

Returns

A formatted string including the filename and method name invoking the function

Return type

str

orion_notebook.utils.is_valid_md5(md5: str)bool

Check if a string is a valid md5 hash

Parameters

md5 (str) – Md5 hash string to check

Returns

Whether if the hash is valid or not (all zeroes md5 hash is not considered valid)

Return type

bool

orion_notebook.utils.limit_max_query_result(nodes: List[Any], edges: List[Any], parent_id: Optional[str] = None, max_nodes_length: int = 25, skip_nodes: int = 0)Tuple[List[Any], List[Any], int]

Limits the results of nodes and edges by a fixed number and skipping a provided number of nodes

Parameters
  • nodes (List[Any]) – Nodes to potentially limit and filter

  • edges – Edges to potentially limit and filter

  • parent_id (str) – Id of the top parent node

  • max_nodes_length (int) – Length to limit the nodes to (default 25)

  • skip_nodes (int) – Number to nodes to skip

Returns

A tuple of filtered nodes, edges and the total number of filtered nodes

Return type

Tuple[List[Any], List[Any], int]

orion_notebook.utils.normalize_query(query: str)

Normalize a ClickHouse query string escaping all backslashes

Parameters

query (str) – ClickHouse query

Returns

ClickHouse query with backslashes escaped

orion_notebook.utils.parse_domain_list(domain_list: str, char_to_replace: str = '#')str

Parses a string by replacing the given character with the new line character in the given domain list

Parameters
  • domain_list (str) – Domain list to parse

  • char_to_replace (str) – Character to replace

Returns

Parsed string

Return type

str

orion_notebook.utils.set_edge_timestamp(edge, edge_timestamp: orion_notebook.date.OrionDate)

Set the min or max datetime in a edge.

Parameters
  • edge (Edge) – Any type of Edge

  • edge_timestamp (OrionDate) – Timestamp when the event was fired