Skip to main content

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).
  • Log parsed CLI flags from absl.flags.FLAGS and config values from config_file:get_config()
  • Inject pymongo.collection.Collection if mongo_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.dev31.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

absl_extra-0.0.3.dev31-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file absl_extra-0.0.3.dev31.tar.gz.

File metadata

  • Download URL: absl_extra-0.0.3.dev31.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for absl_extra-0.0.3.dev31.tar.gz
Algorithm Hash digest
SHA256 007b6d54f3b8dcfa0af3cce52879cab8ddd2eb6b559d2c8e05c8814cebadd2b5
MD5 cbcc5f25dd793e18ba593603f5d50c80
BLAKE2b-256 9240eee20be3654a387c5bbc7181fdbb25df9115bc887aa7da04f8a25c0066df

See more details on using hashes here.

File details

Details for the file absl_extra-0.0.3.dev31-py3-none-any.whl.

File metadata

File hashes

Hashes for absl_extra-0.0.3.dev31-py3-none-any.whl
Algorithm Hash digest
SHA256 775bb5cb66f7daf3f35e98160d521e2373d7c9c27383035ef3fbc6b5315a30d2
MD5 1b1e8419bf25ca3e3714785a388c98ed
BLAKE2b-256 4adeef101864f1845de1ab5e8244004a598e26aa75a1d5d6f821fa6a618fde29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page