Skip to content

Commit

Permalink
init: from decenter-streamlit.app v3.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiro committed Oct 22, 2023
1 parent f7ac68d commit c07bb07
Show file tree
Hide file tree
Showing 134 changed files with 50,088 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
venv
.venv
node_modules
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Sure! Here's an example of an ignore file (`.gitignore`) for a Python project, including the `.env` file:

```
# Ignore Python virtual environment files
venv/
ENV/
bin/
lib/
share/
include/
pyvenv.cfg
.venv

# Ignore compiled Python files
*.pyc
*.pyo
__pycache__/

# Ignore environment-specific settings
.env

# Ignore editor files and directories
.vscode/
.idea/
.run/

# Ignore logs
*.log

# Ignore cache and temporary files
*.cache/
*.swp
*.swo
*~

# Ignore package build files
dist/
build/
*.egg-info/

# Ignore database files
*.db

# Ignore compiled extensions
*.so

# Ignore system-specific files
.DS_Store
Thumbs.db

# Jupyter Notebook
.ipynb_checkpoints/
etc/
flagged/

# pdf
*.pdf
You can modify this file as per your specific requirements.

# Audio Buffer obj
<_io.BytesIO object at*
*.mp3

.env.*

*.sav

#*.zip

/samples/sample_v3/linear-regression.ipynb.html
/samples/vehicle_solution/vehicle-dataset.html
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
# - id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
args: [ --py36-plus ]

# - repo: https://github.com/facebook/usort
# rev: v1.0.7
# hooks:
# - id: usort

- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]

# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v2.0.2
# hooks:
# - id: autopep8

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
language_version: python3.10
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
91 changes: 91 additions & 0 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# doc: https://docs.streamlit.io/library/advanced-features/theming

[server]
folderWatchBlacklist = ['.idea', '.run']
runOnSave = true
port = 8501
cookieSecret = "a-random-key-appears-here"
baseUrlPath = ""
enableCORS = true
enableXsrfProtection = true
maxUploadSize = 1024 #mb
maxMessageSize = 200 #mb
enableWebsocketCompression = true

enableStaticServing = true
#served in ./static :=/app/static/filename.jpg
[theme]
primaryColor = "#fff"
backgroundColor = "#000000"
secondaryBackgroundColor = "#252B48"
textColor = "#ffffff"
font = "sans serif"

[browser]

serverAddress = "localhost"
gatherUsageStats = true
serverPort = 8501

[mapbox]
# # https://mapbox.com. It's free (for moderate usage levels)!
# token for elements like st.pydeck_chart and st.map. #TODO:
token = ""

[deprecation]

# Set to false to disable the deprecation warning for the file uploader
# encoding.

# Default: true
showfileUploaderEncoding = true

# Set to false to disable the deprecation warning for using the global pyplot
# instance.
showPyplotGlobalUse = true


[runner]
# Allows you to type a variable or string by itself in a single line of
# Python code to write it to the app.

# Default: true
magicEnabled = true

# Install a Python tracer to allow you to stop or pause your script at
# any point and introspect it. As a side-effect, this slows down your
# script's execution.

# Default: false
installTracer = false

# Sets the MPLBACKEND environment variable to Agg inside Streamlit to
# prevent Python crashing.

# Default: true
fixMatplotlib = true

# Run the Python Garbage Collector after each script execution. This
# can help avoid excess memory use in Streamlit apps, but could
# introduce delay in rerunning the app script for high-memory-use
# applications.

# Default: true
postScriptGC = true

# Handle script rerun requests immediately, rather than waiting for script
# execution to reach a yield point. This makes Streamlit much more
# responsive to user interaction, but it can lead to race conditions in
# apps that mutate session_state data outside of explicit session_state
# assignment statements.

# Default: true
fastReruns = true

# Raise an exception after adding unserializable data to Session State.
# Some execution environments may require serializing all data in Session
# State, so it may be useful to detect incompatibility during development,
# or when the execution environment will stop supporting it in the future.

enforceSerializableSessionState = false
# https://docs.streamlit.io/knowledge-base/using-streamlit/serializable-session-state
59 changes: 59 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned with this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team
at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated and will
result
in a response that is deemed
necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to
the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from
the [Contributor Covenant](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html), version 1.4.
19 changes: 19 additions & 0 deletions Contrib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dev commnds to refer

### [Poetry](https://python-poetry.org/docs/basic-usage/)

`source $(poetry env info --path)/bin/activate`

`poetry add --dev pre-commit`


```bash
source $(poetry env info --path)/bin/activate
```


#### Run scripts

```
poetry run pytest
```
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Stage 1: Install dependencies
FROM python:3.10 AS builder

WORKDIR /app

# Install Poetry
RUN pip install poetry

ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY=true
ENV POETRY_VIRTUALENVS_OPTIONS_NO_PIP=false
ENV POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS=true
# ENV POETRY_VIRTUALENVS_PATH={cache-dir}/virtualenvs not required since virtual env is set in
# fixme: add setup tooools

# Copy only the dependency-related files
COPY pyproject.toml poetry.lock ./

# Install project dependencies using Poetry
RUN poetry install --no-root

# Stage 2: Copy application code and configure Streamlit
FROM python:3.10-slim

ENV mode=production

EXPOSE 8501

WORKDIR /app

# Copy dependencies from the builder stage
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /app/.venv /app/venv

# Activate the virtual environment
RUN . venv/bin/activate

# If you have a separate requirements-test.txt for testing, you can install it here.
# RUN if [ "$mode" = "testing" ]; then pip install -r requirements-test.txt; fi

# Copy the rest of your application code
COPY . .

# Modify Streamlit config if needed
RUN sed -i 's/\(runOnSave =\).*/\1 false/' .streamlit/config.toml

CMD ["python", "-m", "streamlit", "run", "main.py"]
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
setup:
# pip install pre-commit
# pre-commit install
# python -m venv venv
# source venv/bin/activate
@make install
pre-commit autoupdate

activate:
source $(poetry env info --path)/bin/activate

install:
# @ pip install --upgrade pip
# @ pip install -r requirements.txt
@pip install poetry
@poetry install --no-root

install-ml-deps:
poetry add --group ml $(cat requirements-ml.txt)


run:
# @source venv/bin/activate
# @python -m streamlit run app.py
@poetry run streamlit run app.py

install-tests:
# @python -m pip install -r requirements-test.txt
@make install

test:
@pytest -p no:cacheprovider
@echo "testing complete"

clean:
@echo "clean all temp folders"
@find . -type d -name '.pytest_cache' -exec rm -rf {} +
@find . -type d -name 'testcache' -exec rm -rf {} +
@find . -type d -name '.benchmarks' -exec rm -rf {} +
# @find . -type f -name '<_io.BytesIO object at*' -exec rm -f {} +
@find . -type f -name '*.log' -exec rm -f {} +

docker:
docker build -t decenter.streamlit.app .

.PHONY: run install clean setup test activate docker

poetry-export:
poetry export --with dev --format requirements.txt --output requirements-poetry.txt

export:
conda env export --name ml > environment.yml export

zip_examples:
zip -r sample_v2 .
Loading

0 comments on commit c07bb07

Please sign in to comment.