Skip to main content

Manage the heck out of long-running processes in streamlit

Project description

Streamlit Process Manager

Streamlit Process Monitor Animation

Let's be honest, trying to manage external processes or subprocesses from a Streamlit app is tricky. The execution model makes it difficult to keep track of which processes are supposed to be running and which ones aren't. Half the time you end up spawning twenty different processes all trying to access the same file and stomping all over one another.

Streamlit Process Manager attempts to make a that a bit easier. It looks something like this:

import streamlit_process_manager as spm

# Get the global ProcessManager
pm = spm.get_manager()

# Configure the Process and start it
my_program = ["python", "my_program.py"]
output_file = "program_output.txt"
process = pm.single(spm.Process(my_program, output_file))
process.start_safe()

# Run the process and monitor it in streamlit!
spm.st_process_monitor(process).loop_until_finished()

⚠️ DISCLAIMER ⚠️

Runing processes on your machine from a public-facing application like a Streamlit app can be incredibly risky and comes with all sorts of security considerations. Use this project on public apps at your own risk, and never inject user-provided values or arguments into your processes without serious consideration of all the possible injection attacks you might be opening your server up to.

Installation

pip install streamlit-process-monitor

Requires

  • Python 3.8.* or above
  • Streamlit 1.30.* or above
  • psutil 5.9.8 or above

Development

This project uses pdm for most of its development tooling. Ensure you have python3.8 installed, then run

pip install pdm
pdm venv create 3.8
pdm install --dev --group test --group lint

to get started, then run

pdm check

to verify that everything is set up and ready to go.

If you must use Python 3.12 or greater, you may have issues with numpy 1.24 needing to be built from source since it only supports python versions up to 3.11.

Testing with tox

If you have multiple versions of Python available on your system you can use tox to run tests on all of them at once. tox should be installed when you install the --dev dependencies so you can just run it. Any Python's not available on your system will be skipped.

pdm run tox

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

streamlit-process-manager-0.0.1a0.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file streamlit-process-manager-0.0.1a0.tar.gz.

File metadata

File hashes

Hashes for streamlit-process-manager-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 770ec1633c142f21fe588057d1d09d50484b6fe8b813be15894e5da1fe89564e
MD5 2bcb9584b7051b29b9ae355e3dc2dda8
BLAKE2b-256 53923ea488ed89bd9a5628ea847d9823fe667bbf29e06bbfca5b569ee8a60120

See more details on using hashes here.

File details

Details for the file streamlit_process_manager-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_process_manager-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 125ec97a3f19410f18e37b9926d2b44a27dd9a14c2ac6a8c3101622b1effa0dc
MD5 dbf66f3bd031caf18cc55d9e22a900dc
BLAKE2b-256 cb098e350fb2d7625739a6edd1cc27518140c1eae7f334c2c82f20ab809273fb

See more details on using hashes here.

Supported by

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