gigl.src.common.utils.time#
Functions#
|
|
|
|
|
|
|
Validates a datetime string with specified format. ex "%Y%m%d" for "YYYYmmdd" |
|
Returns an ID for naming the resources of one test run. |
|
Module Contents#
- gigl.src.common.utils.time.convert_days_to_ms(days)[source]#
- Parameters:
days (int)
- Return type:
int
- gigl.src.common.utils.time.current_datetime()[source]#
- Returns:
current timezone aware utc datetime.
- Return type:
str
- gigl.src.common.utils.time.current_formatted_datetime(fmt=DEFAULT_DATETIME_FORMAT)[source]#
- Returns:
current timezone aware utc datetime formatted as a string as per provided date format string.
- Return type:
str
- Parameters:
fmt (str)
- gigl.src.common.utils.time.format_datetime(dt, fmt=DEFAULT_DATETIME_FORMAT)[source]#
- Parameters:
dt (datetime.datetime)
fmt (str)
- Return type:
str
- gigl.src.common.utils.time.is_datetime_str_format_valid(datetime_str, datetime_format)[source]#
Validates a datetime string with specified format. ex “%Y%m%d” for “YYYYmmdd” Return True/False so users can decide to raise error or reformat string
- Parameters:
datetime_str (str)
datetime_format (str)
- Returns:
- Return type:
bool
- gigl.src.common.utils.time.new_test_run_id(prefix)[source]#
Returns an ID for naming the resources of one test run.
Each call returns a new ID, so call it once per test run and reuse the result. The ID is
<prefix>_<UTC YYYYmmdd_HHMMSS>_<6 random hex chars>. The random suffix keeps runs that start in the same second from sharing GCS paths, BigQuery tables, or Dataflow job names. Whenprefixis lowercase[a-z0-9_], so is the ID, which makes it valid as:a KFP job name
a BigQuery table name
a GCS path component
a Dataflow job name, after Dataflow’s own sanitizing
- Parameters:
prefix (str) – Leading text that identifies the test.
- Returns:
The unique ID.
- Return type:
str