Data Science Streamlit
What files / architecture is generated?
. ├── Jenkinsfile ├── .pre-commit-config.yaml ├── docker_streamlit │ └── Dockerfile ├── docker_oauth │ └── Dockerfile - Dockerfile for the oauth, please don't change this for proper promotion ├── src - Example code structure based on individual python modules │ ├── calculation │ │ │── __init__.py │ │ └── sample.py │ ├── plots │ │ ├── __init__.py │ │ ├── config.py │ │ └── histogram.py │ └── main.py ├── tests │ └── calculation │ └── sample_test.py │── .gitignore │── requirements.txt - requirements for running the application │── test_requirements.txt - adds additional requirements for the test frameworks │── metadata.yml - Component metadata └── release-manager.yml - Configuration file for the Release Manager
Usage - how do you start after you provisioned this quickstarter
The quickstarter sets up in OpenShift a pod with two containers. The main ds-streamlit container is behind and protected by the OpenShift OAuth proxy container (i.e.: it is a sidecar container).
It is strongly recommended when you are developing a Python project to use separated environments. For this purpose usually one can use Python’s venv core package (check how to use it in the next steps).
| since the version of Python is 3.12, ensure your system’s python executable is also in version 3.12 |
# Create virtual environment 'mylocaldevelopment' (will be located in the folder mylocaldevelopment) (run only once)
python -m venv mylocaldevelopment
# Initiate virtual environment for the project (every time)
source mylocaldevelopment/bin/activate
# Runs installation of required modules in the virtual environment (run only once)
pip install -r requirements.txt
# Start your application
PYTHONPATH=src python src/main.py
How this quickstarter is built through Jenkins
The Jenkinsfile is provisioned with this quick starter to ease CI/CD process. In Jenkinsfile, there are various stages:
-
Prepare Test Suite - Prepares the virtual environment for testing and linting:
-
Lint - Runs mypy and flake8 for increasing code quality: In order to be sure that your code passes the linting stage execute or add it as a pre-commit hook to your git.
black src -
Test - Runs pytest and generates xUnit and code coverage reports:
-
Build - Builds the application: copies src folder into docker_streamlit/dist folder.
include::partials$secret-scanning-with-gitleaks.adoc
Builder agent used
This quickstarter uses Python builder agent Jenkins builder agent.