Skip to main content

Wicked fast hot reloading

Project description

Firehot

Firehot

A package to quickly hot reload large Python projects. Currently in development.

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 mypackage and external-package library in this repo.

make
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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

firehot-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

firehot-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

firehot-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

firehot-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

firehot-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

firehot-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

firehot-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

firehot-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file firehot-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 fa674bae5da92007d9fd886e714a3860c5f71c4ff1dbc1788c901c982b8d0ae1
MD5 c20a12d5d9b6f74095a072d37047367e
BLAKE2b-256 c1505a0c2d08788a99686c06482c560159a0a28aa101dfd3668094347ba53587

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-cp313-cp313-manylinux_2_39_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.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d7e79decda21acbf1816571a119b1044eabc1f3ec5deea23bee264dc5ed09ed
MD5 2be5cdc8f83821325ea5aceaf8b1ae63
BLAKE2b-256 6e65f873f69e0de660e9d75bf3fa7953926c81ce52c0593fe1b4a4243f7fb46a

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-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.1.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 9a6fcf91aa11e3932d752955c80c641cb31aecc6c88ede853286c33fb6da7115
MD5 7d43e424a1ff79d7dbcc914dad744e84
BLAKE2b-256 577bd5febb90b0b78d93338b00cde2fcdef9635417857edc2a3ada9dfb097355

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-cp312-cp312-manylinux_2_39_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.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ba49bff9740f97c97c93b2d99c82a3f88615b2e5a4adad6916c778c090894388
MD5 0f8b4daeb0fa4bdb5764792035b7d68a
BLAKE2b-256 354d0798fabe8c870a5d5f226ec9ab41bf4e00c44029f7510c06e1894da6f4ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-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.1.1-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 42d425b777b3b19824ee559a621ca3d4aff055cdacde802d17fbe77a2f93e409
MD5 8cddb83c5ebde04993f1a514979a6f55
BLAKE2b-256 7053ffff939f41c40841b5eaa6aa4a06c60268fd87cbacf6bbf83a4205b9dddc

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-cp311-cp311-manylinux_2_39_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.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f4b978191af98588c7ed2df961c48b8e6fd76525e8570cf07589f094b2c1c90
MD5 5c026b5363256badfd6522e437465dc9
BLAKE2b-256 b6028c2e499d59b9e8cb45b314939fbd3f6a0ec18e96960f4b2e9d30f5d1613f

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-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.1.1-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5a30f00727822a7b331e7ef04b52e5e453c2fa6d0e5f013384f298f71d26440a
MD5 4c8e41841d2eb89c6e7fcde2eac16d7f
BLAKE2b-256 71541914104d1ea03dee0a6ae2b8922d22cc14636f542ba5057bf5f9715382dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-cp310-cp310-manylinux_2_39_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.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59de41f4d1f01cd04cf8fc5526d2c6c4c38686a0804495c934a790e074017f8f
MD5 5355319523870247a5e113461489091d
BLAKE2b-256 6a2f984aadc56d484f3594549e58b78403e2ad4a28a513ad48d99be6145bdfc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.1-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.

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