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.FLAGSand config values fromconfig_file:get_config() - Inject
ml_collections.ConfigDictfromconfig_file, if kwarg provided. - Inject
pymongo.collection.Collectionifmongo_configkwarg provided.
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 MongoConfig, register_task, run
from absl_extra.notifier import SlackNotifier
from absl_extra.tf_utils import requires_gpu, supports_mixed_precision, make_gpu_strategy
@register_task
@requires_gpu
def main(cmd: str, config: ConfigDict, db: Collection) -> None:
if supports_mixed_precision():
tf.keras.mixed_precision.set_global_policy("mixed_float16")
with make_gpu_strategy().scope():
logging.info("Doing some heavy lifting...")
if __name__ == "__main__":
run(
config_file="config.py",
mongo_config=MongoConfig(uri=os.environ["MONGO_URI"], db_name="my_project", collection="experiment_1"),
notifier=SlackNotifier(slack_token=os.environ["SLACK_BOT_TOKEN"], channel_id=os.environ["CHANNEL_ID"]),
)
Planned for:
- global app state for different tasks
- list of pre/post hooks
- keras callback with notifier
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.2.dev7.tar.gz
(6.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file absl_extra-0.0.2.dev7.tar.gz.
File metadata
- Download URL: absl_extra-0.0.2.dev7.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17892e6d3ef7c780fb9b4ffc92740dd323cde12f02630ef08359d03e1554a1b2
|
|
| MD5 |
1434277c6e3d614cd71fe413f4e991a9
|
|
| BLAKE2b-256 |
3e3870913b80496a8a56a89f18cdf7d336daf69201e419ebb6fdd33bf2309250
|
File details
Details for the file absl_extra-0.0.2.dev7-py3-none-any.whl.
File metadata
- Download URL: absl_extra-0.0.2.dev7-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6853e1886cf435bea328dd229d53bdaa6bf87285a9b894483c28bbd399536d1b
|
|
| MD5 |
dffcc0a86c0258e0e4dc8a62341bcfb2
|
|
| BLAKE2b-256 |
4cf19c43d31349df5ccd2c4ef46075683d8e5c9cd683c9f8d14d2771b6a1d36a
|