Skip to main content

Wicked fast hot reloading

Project description

Firehot

Firehot

A package to quickly hot reload large Python projects. Currently for Linux & OSX.

Background

Once your project gets to a certain size, the main overhead of application startup is typically the loading of 3rd party packages. Packages can do varying degrees of global initialization when they're imported. They can also require 100s or 1000s of additional files, which the AST parser has to step through one by one. Cached bytecode can help but it's not a silver bullet.

Eventually your bootup can take 5-10s just to load these modules. Fine for a production service that's intended to run continuously, but horrible for a development experience when you have to reboot after changes. Firehot solves this by importing dependencies once, then forking your environment for each exec. Think of it like building a docker image then executing it whenever you make a change.

Python Usage

from firehot import isolate_imports
from os import getpid, getppid

def run_under_environment(value: int):
   parent_pid = getppid()
   print(f"Running with value: {value} (pid: {getpid()}, parent_pid: {parent_pid})")

with isolate_imports("my_package") as environment:
   # Each exec will be run in a new process with the environment isolated, inheriting
   # the package's third party imports without having to re-import them from scratch.
   context1 = environment.exec(run_under_environment, 1)
   context2 = environment.exec(run_under_environment, 2)

   # These can potentially be long running - to wait on the completion status, you can do:
   result1 = environment.communicate_isolated(context1)
   result2 = environment.communicate_isolated(context2)

   # If you change the underlying file on disk to add an import, you can run update_environment.
   # If the files on disk don't add any new imports, it will be a no-op and keep the current
   # environment process running.
   environment.update_environment()

   # Subsequent execs will use the updated environment.
   context3 = environment.exec(run_under_environment, 3)
   result3 = environment.communicate_isolated(context3)

Logging

By default, Firehot logs at the warn level, but you can adjust this by setting the FIREHOT_LOG_LEVEL environment variable. Most of these logs come from the Rust code.

Available log levels (from most to least verbose):

  • trace: Extremely detailed information, useful for debugging specific issues
  • debug: Detailed information useful during development
  • info: General information about what's happening (default)
  • warn: Warning messages for potential issues
  • error: Error messages for actual problems

Example usage:

# Set to debug level for more detailed logs
FIREHOT_LOG_LEVEL=debug python your_script.py

# Set to error level for minimal logs
FIREHOT_LOG_LEVEL=error python your_script.py

Architecture

You launch Firehot by pointing it to your package name, which we resolve internally to a disk path that contains your code. From there, our Rust logic takes over. The pipeline will parse this directory recursively for all Python files, then parse the code's AST to determine which imports are used by your project.

It will then launch a continuously running process that caches only the 3rd party packages/modules. We think of this as the "template" process because it establishes the environment that will be used to run your code. None of your user code is run in this process.

When code changes are made in your project, we will:

  • Determine if your changes affected the imported packages
  • If not, we can fork the parent process and pass in your user code. This will load all modules from scratch, but because importlib caches the modules in global space, it will be a no-op because of the template.
  • If so, we will tear down the current parent process and start a new one with the full 3rd party packages imported. Then we'll fork the environment as normal.

Local Experiments

To test how firehot works with a real project, we bundle a demopackage and external-package library in this repo.

# To do a regular, fast development build
(make build-develop && cd demopackage && uv run test-hotreload)
# To pass the args we use in a release
(make build-develop MATURIN_ARGS="--release --strip" && cd demopackage && uv run test-hotreload)

Unit tests

cargo test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firehot-0.4.1.dev1.tar.gz (35.9 MB view details)

Uploaded Source

Built Distributions

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

firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

firehot-0.4.1.dev1-cp313-cp313-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

firehot-0.4.1.dev1-cp313-cp313-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

firehot-0.4.1.dev1-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

firehot-0.4.1.dev1-cp312-cp312-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

firehot-0.4.1.dev1-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

firehot-0.4.1.dev1-cp311-cp311-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

firehot-0.4.1.dev1-cp310-cp310-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

firehot-0.4.1.dev1-cp310-cp310-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file firehot-0.4.1.dev1.tar.gz.

File metadata

  • Download URL: firehot-0.4.1.dev1.tar.gz
  • Upload date:
  • Size: 35.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for firehot-0.4.1.dev1.tar.gz
Algorithm Hash digest
SHA256 8c2f7d3ff10c50deac330844a5d15a89b8b67526a6cc989dbaa4fd02bd0434d5
MD5 18eb6b83d57e0343696352adf562ef40
BLAKE2b-256 db513a75b14015f82302ca335bdf73094dcc82564d4aaeef1def81dc6fa95bc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1.tar.gz:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0aee699b75fb09600b425332a9224aeb54368dba8cf77022a1ae152d2f808db3
MD5 a4e3414d03c9a0b7485ca30e6c92c565
BLAKE2b-256 c7ee7aa024026033c2f03eef66e6ea50849985bcd444c97e1d9e9a3545fa85ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c4b6f3575495347cdb3bc7e39eb6d3afcab2a42ad444229fe7d19dfd2d738718
MD5 aa9a76998a476902e827a40cac2f4a73
BLAKE2b-256 a7bccd9c13c143f42198a6ec63d7ba5354ebf37ceab6b19716826aa495b48c08

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dfd9c4f48973ddad8ea1f7bf3804c1d23768216ef3a328bee053bad8377c6c14
MD5 7838bc4ba11c42d03eee56729ef027dc
BLAKE2b-256 2f7b3cdbf912f787f5f87acb9bc743f85bc130a172ee23ba8a2af5e17f3ba15f

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3bc1eab130cb5e3ddd767374f15a61a3fff863c5c3d7a498c026e11bc81f522d
MD5 0b0e218bc56244bbac46abbfa539c59d
BLAKE2b-256 129521728f8c289d2d93f6b34d353859c07ae0f38c04817a67929e142f44e282

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21b465890ebe540d7537f9b4519911d7b92068beaee2f474d9f0021a66022362
MD5 4b2245ecf9f9a3c83f18198b298b2631
BLAKE2b-256 6b79658ca7017ea08495244b24e57f9c46f947a54f3b745a004a89055ad9ba91

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6e48aadbc356698b7cd40a4e2e0e957a697a77f2dde4a781b166a94c0a9fb024
MD5 401827c696dea9a7caac25adca5227b0
BLAKE2b-256 fcac4a620a52ef8190517a422283ffc835a172dfebbddca7b9e48be29f176e34

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57d8f4dadec13c53eb0b19dfd3cbca2a566f7a88311e82407e7fa6a13c400497
MD5 31fb845495666c941c31f0f5a7092862
BLAKE2b-256 b084dc761676fd3bd8228f32d45d77d2705a5a15ffcd133f99a7430e4167fb59

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9964988605cfa4ec8ebabd677ff8efd4a59439033ef86538638c37ae972edbd9
MD5 f1eef8fa720c5a2cf522b687cd8c584e
BLAKE2b-256 b91c84fc3067f6accbe7807ce8a91fd80656960f0ed680e59e19b55856f9173d

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52ea5c682551c3bce15a2ce843be8a10d45b35d88749bf6a014e108f2b4a15f3
MD5 e670d849ad76825ee95e0aaf7c0bd67c
BLAKE2b-256 6cd6e6822e783e0d92a83d67beb51ad4546de48ae0dadc7d058fbe4609a9bc7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e159431327c9409284f21e43b0ffa3e9cb4cd96460eb9f3a97adaffcd439babf
MD5 59b89cade7607be8423508726944a9a7
BLAKE2b-256 53f19def1bd643ff9b88931b6f42fdf08d1fe966df6b688cd878486653e81b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37e76a379284ff0c242d32ba01329e14c74086e391300e425ebe48256c81af22
MD5 12b8d12e7309c7864ee9b37c73402ec4
BLAKE2b-256 ec18399bee76126e132785b9772e25aa9afd67e5bb814b7e68af9342c4906f5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 33ce1e8451be7f29276ad26513eed358fbb8969be9f5a1f483572d42cc8ed174
MD5 0bf0a1aceff85c366f15612a012bb9f0
BLAKE2b-256 fa3183feae346197f989f539e7fdf91959c292f96199a86388655751b6878953

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp311-cp311-macosx_10_12_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db5f07a005f91c2328f6771e44de09e58fc4714566c6c9463f54e648635d50fd
MD5 ad3b2905df87b8c3872153a7ccc3aa23
BLAKE2b-256 fafe8bd788da922e4696956f7a1c70fa229d66bd78e04ba1fdb0268306006c7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 211057ad0d5ae7c4c539030f84eebc26fc259e6261ff4f1a986c1035461ecd1c
MD5 db6ccc3be57b9e0d68a9d410294e7068
BLAKE2b-256 a6ca8088f05e2cc09fecaa548120371a58ce1a4e04a37f6711029446bc405c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9420949e6558dac5b9ee3463b4675b9a046919d1fead93d51e479f33f8a7d0fe
MD5 fdc013f5f439f545a5e57064800ba0db
BLAKE2b-256 e093f8a33239945302446845e1724f4a096459fe7b754aae31add21591b79cdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.4.1.dev1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.4.1.dev1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b5d4ff7c7c6ea5b69f60aa11a47977f1f8e99cb402cf49e74f86b5c10e5f75e3
MD5 e28c0126826e59b7ef39dd48bb024982
BLAKE2b-256 a5973758e0dcc35966097d5f69802133ed57e7d30c2ccd21e2a33b4c8da5331d

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.4.1.dev1-cp310-cp310-macosx_10_12_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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