This guide shows how to compile and test this project. Anyone who want to contribute to these codes can follow this guide and submit the pull request. Section 2 🔖 and Section 3 🔖 suggests how to work with Docker or Conda, respectively. Please choose either of these tools to deploy the environment and develop this project.
Caution
We strongly suggest users to prepare the environment by Docker (see 2.1. 🔖). Docker is supported by both Linux and Windows. Using Docker can save a lot of steps and mitigate issues caused by the path.
-
Review our code of conduct 📝 before contributing to this project.
-
The metadata of the project is defined in
pyproject.tomlandpackage.json. Modifyingpackage.jsonwill not automatically updatepyproject.toml. Therefore, users need to ensure changes for both files if any part of the metadata needs to be changed. -
The React source files are in the
src/lib/folder. These codes are formatted bypretteir🔨. -
The Python codes are in the package
dash_file_cache/folder. These codes are formatted byblack🔨. -
The Python Compoenent codes are in the sub-package
dash_file_cache/components/folder. Note that the automatically generated files like_imports_.pyandDownloader.pywill not be formatted. -
Currently, we do not provide the React demo application. Therefore, please do not use
yarn start. -
The Dash demo apps are stored in
examples/. These demos show the usages this package in different cases. -
The unit tests are defined in the
tests/folder. -
The
version/folder is only used for helpingpyproject.tomlfetch the current version. -
The tool configurations for
pytest,black, andpyrightare defined inpyproject.toml. However, the configurations forflake8,pylint, andprettierare still kept in their corresponding configurations files. -
If any custom styles are defined but not imported as a part of the react codes, please add these custom CSS files into the distribution folder (
dash_json_grid).- Make sure that they are referenced in
MANIFEST.inso that they get properly included when you're ready to publish your component. - Make sure the stylesheets are added to the
_css_distdict indash_json_grid/__init__.pyso dash will serve them automatically when the component suite is requested.
- Make sure that they are referenced in
-
Remember to use
black🔨 andpretteir🔨 to format any modified Python and React codes, respectively. Review your code 📝 before sending the pull request.
If you choose to use Docker. The only software you need to install is docker itself. Check the following guide to install Docker on your device:
https://docs.docker.com/get-started/get-docker/
After installing docker, test whether it works or not by
docker run -it --rm hello-worldYou should be able to see the message like this, which shows that docker is working well:
Then, build the docker image by
docker build -t dash-file-cache:latest https://github.com/cainmagi/dash-file-cache.gitThis step may take a little bit long. After successfully building the image, you can start working on this project.
Run the following command to start the tests.
docker run -it --rm dash-file-cache:latest --with-dashIf the codes have not been modified, you suppose to see the the messages like this:
It shows that all unit tests get passed.
We have prepared several Dash demos. Run this command to launch the default demo (./examples/change_image.py):
docker run -it --rm -p 8080:8080 dash-file-cache:latest --demoThe following command is used for launching a different demo. The available demo names are the .py file names in ./examples
docker run -it --rm -p 8080:8080 dash-file-cache:latest --demo demo=change_image| Demo Name | Description |
|---|---|
change_image |
A simple demo allowing users to change the displayed image from two options. |
single_process |
Serving the same example image by three kinds of data resources within the same process. |
background_callback |
Serving the same example image by three kinds of data resources using the background callback and the queue-based process synchronization. |
tempfile_cache |
Serving the same example image by three kinds of data resources using the background callback and the temporary file cache. |
download_file |
A simple demo for the downloader component, allowing users to fetch a streamed file in the cache. |
flask_services |
A pure Flask demo for the APIs of the file cache. |
When the demo is running, you should be able to access the demo by
To modify the scripts, you may want to clone an Git repository by yourself:
git clone https://github.com/cainmagi/dash-file-cacheThen, you can run the docker container and mount the newly cloned Git folder to the container:
docker run -it --rm -v <path-to-the-project>:/workdir -p 8080:8080 dash-file-cache:latest --bashWhen the container is running, you should be able to see that your are in the container's console.
Please leave the container open, and follow this guide to attach your vscode to the running container:
https://code.visualstudio.com/docs/devcontainers/attach-container
At the bottom left corner, you should be able to see the name of the current container. When you open a new workspace, you should be able to find the the project in /workdir.
Now you will be able to start the development. You can do the following things to test the codes.
-
Build the component
yarn install yarn build
-
Run the
pytest:python -m pytest --headless --with-dash
-
Run the demo:
python examples/change_image.py
-
Format the python codes
black . -
Build the python pacakge
python -m build
Before submitting a pull request, please ensure that all unit tests (pytest) get passed and the codes are formatted by black.
Caution
This method is not recommended because conda may take redundant space to install unnecessary pacakges. Users need to maintain the dependencies by themselves.
Before start the installation, you need to ensure the following things are installed:
-
Conda or Mamba
Either MiniConda or MicroMamba is a good option. MicroMamba is even faster than MiniConda. If you choose to use micromamba, you simply need to replace
condabymicromambain any command. -
A browser
You need to ensure that either one of the Chromium-based browser is installed.
- Get Edge: https://www.microsoft.com/en-us/edge/download
- Get Chrome: https://www.google.com/chrome/dr/download
- Get Chromium: https://www.chromium.org/getting-involved/download-chromium/
-
Git
You need to ensure that Git command is available:
- Get Git: https://git-scm.com/downloads
Use Git to clone the latest source codes:
git clone https://github.com/cainmagi/dash-file-cacheThe following steps will help you configure the environment with conda:
-
Create the environment
conda create -c conda-forge -n dashdev-dfc python=3.12 wheel setuptools nodejs yarn
-
Enter the environment
conda activate dashdev-dfc
-
Install the Python dependencies
pip install -r requirements.txt -r requirements-dev.txt -r tests/requirements.txt
-
Install the Node.js dependencies and build the first version.
yarn install yarn build
To verify whether you have correctly prepared the environment or not, you can run the following command:
python -m pytest --headless --with-dashYou can do the following things to test the codes.
-
Build the component
yarn install yarn build
-
Run the
pytest:python -m pytest --headless --with-dash
-
Run the demo:
python examples/change_image.py
-
Format the python codes
black . -
Build the python pacakge
python -m build
Before submitting a pull request, please ensure that all unit tests (pytest) get passed and the codes are formatted by black.


