sammo.utils

sammo.utils#

Small number of utility functions that are used across SAMMO.

Module Contents#

Classes#

CodeTimer

Time code with this context manager.

Functions#

sync

Execute and return result of an async function. Take special care of already running async loops.

serialize_json

Serialize json with orjson to invariant byte string.

Data#

MAIN_PATH

Path of the main script if not interactive, otherwise working dir.

MAIN_NAME

Name of the main script file if not interactive, otherwise ‘tmp’.

DEFAULT_SAVE_PATH

Default save path is folder with the same name as main script.

API#

class sammo.utils.CodeTimer#

Time code with this context manager.

Initialization

property interval: float#

Timed interval in s.

sammo.utils.MAIN_PATH = 'get_main_script_path(...)'#

Path of the main script if not interactive, otherwise working dir.

sammo.utils.MAIN_NAME = 'get_main_script_name(...)'#

Name of the main script file if not interactive, otherwise ‘tmp’.

sammo.utils.DEFAULT_SAVE_PATH = 'get_default_save_path(...)'#

Default save path is folder with the same name as main script.

sammo.utils.sync(f: collections.abc.Coroutine)#

Execute and return result of an async function. Take special care of already running async loops.

sammo.utils.serialize_json(key) bytes#

Serialize json with orjson to invariant byte string.