A wrapper to run and monitor absl app.
Project description
ABSL-Extra
A collection of utils I commonly use for running my experiments. It will:
- Notify on execution start, finish or failed.
- By default, Notifier will just log those out to
stdout
. - I prefer receiving those in Slack, though (see example below).
- By default, Notifier will just log those out to
- Log parsed CLI flags from
absl.flags.FLAGS
and config values fromconfig_file:get_config()
- Inject
pymongo.collection.Collection
ifmongo_config
kwarg provided. - Select registered task to run based on --task= CLI argument.
Minimal example
import os
from pymongo.collection import Collection
from ml_collections import ConfigDict
from absl import logging
import tensorflow as tf
from absl_extra import tf_utils, tasks, notifier
@tasks.register_task(
mongo_config=dict(uri=os.environ["MONGO_URI"], db_name="my_project", collection="experiment_1"),
notifier=notifier.SlackNotifier(slack_token=os.environ["SLACK_BOT_TOKEN"], channel_id=os.environ["CHANNEL_ID"])
)
@tf_utils.requires_gpu
def main(config: ConfigDict, db: Collection) -> None:
if tf_utils.supports_mixed_precision():
tf.keras.mixed_precision.set_global_policy("mixed_float16")
with tf_utils.make_gpu_strategy().scope():
logging.info("Doing some heavy lifting...")
if __name__ == "__main__":
tasks.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
absl_extra-0.0.3.dev34.tar.gz
(13.1 kB
view hashes)
Built Distribution
Close
Hashes for absl_extra-0.0.3.dev34-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a1612d6d5917b90fb258c226a43dc4fc0a62b0009b8a96dae51fcc3d368f3ce |
|
MD5 | ba9a605a9e8c9f9a303eb6de63fc8175 |
|
BLAKE2b-256 | 245c8682046fb3b38f52b3c05cab4a3102ddee42aa41bb6cc94ce1ae680d6cd5 |