Skip to content

Commit

Permalink
Merge pull request #111 from graphistry/dev/additional-python-path
Browse files Browse the repository at this point in the history
Add env var ADDITIONAL_PYTHON_PATH to load custom python packages
  • Loading branch information
aucahuasi committed Apr 5, 2024
2 parents dafb61f + fc09a3d commit 205125c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -166,6 +166,7 @@ For non-minimal installs, if GPUs are present, `graph-app-kit` leverages GPU clo

* [Caddy](https://caddyserver.com/): Reverse proxy for custom URLs, [automatic LetsEncrypt TLS certificates](http://letsencrypt.org/), multiple sites on the same domain, pluggable authentication (see [integrations guide](docs/extend.md))

* Also you can install your [custom Python Packages](docs/additional-packages.md).

## Contribute

Expand All @@ -176,4 +177,4 @@ We welcome all sorts of help!
* Connectors: Examples for common databases and how to get a lot of data out
* Demos!

See [develop.md](develop.md) for more contributor information
See [DEVELOP.md](DEVELOP.md) for more contributor information
33 changes: 33 additions & 0 deletions docs/additional-packages.md
@@ -0,0 +1,33 @@
# Adding Custom Python Packages to graph-app-kit

## Install Custom Python Packages Locally

Install the desired custom Python packages on your localhost. For example, if you want to include a different version of `PyGraphistry` and an additional dependency like `faker`, run the following commands in your terminal:

```bash
mamba create --yes -n myenv python=3.8
pip install pip install graphistry[all]
pip install faker
```

If the environment is airgapped, copy the packages into your local directory (e.g. `/home/user/additional-python-packages`). Ensure that you use the same system architecture and Python version.

## Mount the Volume in Docker Compose

Update your Docker Compose file to mount the volume to the GAK container. Specify the path to your local directory and the desired mount point inside the container in the environment variable `ADDITIONAL_PYTHON_PATH` (`/mnt` in this example):

```yaml
services:
streamlit:
...
volumes:
...
- /home/user/additional-python-packages:/mnt:ro
environment:
ADDITIONAL_PYTHON_PATH: "/mnt"
...
```

If using conda, replace `/home/user/additional-python-packages` with the full path of `$CONDA_PREFIX/lib/python3.8/site-packages`.

That's it! You've successfully added custom Python packages to the graph-app-kit container. You can now use these packages in your GAK environment for graph analytics and visualizations.
5 changes: 4 additions & 1 deletion src/docker/entrypoint.sh
Expand Up @@ -20,7 +20,10 @@ echo "Log level (LOG_LEVEL): $LOG_LEVEL"
echo "Graphistry user (GRAPHISTRY_USERNAME): $GRAPHISTRY_USERNAME"
echo ""


if [ -n "$ADDITIONAL_PYTHON_PATH" ]; then
export PYTHONPATH=$ADDITIONAL_PYTHON_PATH:$PYTHONPATH
echo "Using ADDITIONAL_PYTHON_PATH=$ADDITIONAL_PYTHON_PATH"
fi

mkdir -p /root/.streamlit

Expand Down

0 comments on commit 205125c

Please sign in to comment.