utils
stick_ray.utils
Module Contents
- get_or_create_event_loop()[source]
Get a running async event loop if one exists, otherwise create one.
This function serves as a proxy for the deprecating get_event_loop(). It tries to get the running loop first, and if no running loop could be retrieved: - For python version <3.10: it falls back to the get_event_loop
call.
- For python version >= 3.10: it uses the same python implementation
of _get_event_loop() at asyncio/events.py.
Ideally, one should use high level APIs like asyncio.run() with python version >= 3.7, if not possible, one should create and manage the event loops explicitly.
- Return type:
- class SerialisableBaseModel[source]
Bases:
pydantic.BaseModelA pydantic BaseModel that can be serialised and deserialised using pickle, working well with Ray.
- set_datetime_timezone(dt, offset)[source]
Replaces the datetime object’s timezone with one from an offset.
- Parameters:
dt (datetime.datetime) – datetime, with out without a timezone set. If set, will be replaced.
offset (Union[str, datetime.tzinfo]) – tzinfo, or str offset like ‘-04:00’ (which means EST)
- Returns:
datetime with timezone set
- Return type:
- current_utc()[source]
Get the current datetime in UTC, with timezone set to UTC.
- Returns:
datetime
- Return type:
- is_key_after_star(func, key)[source]
Checks if a function has a keyword-only argument after a star argument.
- Parameters:
func (Callable) – Callable to check for keyword-only argument after star argument.
key (str) – keyword-only argument to check for.
- Returns:
True if key is a keyword-only argument after star argument.