Skip to content

Commit

Permalink
Merge pull request #106 from Michele-Alberti/development
Browse files Browse the repository at this point in the history
🗄️ Add option to skip database creation
  • Loading branch information
Michele-Alberti authored Feb 23, 2024
2 parents fe4cfc8 + d42b653 commit 2281323
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 100 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
target-branch: development
open-pull-requests-limit: 25

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: development
open-pull-requests-limit: 25
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
language_version: python3
Expand All @@ -9,12 +9,12 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
rev: v3.15.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
default_install_hook_types: [pre-commit, commit-msg]
Expand Down
213 changes: 132 additions & 81 deletions README.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dlunch/conf/db/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ shared_data_folder: ${oc.env:PANEL_SHARED_DATA_FOLDER, /app/shared_data}
engine:
_target_: sqlalchemy.create_engine
url: ${db.url}
# CREATE DATABASE RETRIES
# CREATE DATABASE
# Set attempt_creation to false to stop panel from creating database tables
# Table shall exist on first run if false
attempt_creation: true
# Retries:
# Stop after delay in seconds or max attempts
# Wait time in seconds before retrying
create_retries:
Expand Down
12 changes: 7 additions & 5 deletions dlunch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,14 @@ def create_database_with_retries(config: DictConfig) -> None:
Data.metadata.create_all(engine)

# Create tables
create_database_with_retries(config)
log.debug(f"attempt database creation: {config.db.attempt_creation}")
if config.db.attempt_creation:
create_database_with_retries(config)

# Retries stats
log.debug(
f"create database attempts: {create_database_with_retries.retry.statistics}"
)
# Retries stats
log.debug(
f"create database attempts: {create_database_with_retries.retry.statistics}"
)

# If requested add users for basic auth (admin and guest)
if add_basic_auth_users:
Expand Down
4 changes: 2 additions & 2 deletions docker/web/Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See makefile for docker commands

# PYTHON 3.10.8
FROM python:3.11.4-slim-bookworm
FROM python:3.11.8-slim-bookworm

# Tell the docker runtime process to use the default shell
SHELL ["/bin/sh", "-c"]
Expand Down Expand Up @@ -37,7 +37,7 @@ RUN pip install --no-cache-dir -e .
ENV PANEL_APP=data-lunch-app

# Expose port 5000
EXPOSE 5000
EXPOSE ${PORT}

# Set command
ENTRYPOINT ["python", "-m", "dlunch"]
10 changes: 5 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ help:
@echo -e " ${WHITE} package-test-publish:${NC} publish python package to TestPyPI"
@echo -e " ${WHITE} package-test-install:${NC} install package with pip from TestPyPI (use only in a test env)"
@echo -e " ${WHITE} pre-commit-run :${NC} runs pre-commit hooks"
@echo -e " ${WHITE} commitizen-bump :${NC} runs commitizen for releasing a new version on master branch"
@echo -e " ${WHITE} commitizen-push :${NC} use git to push commits on 'development' and 'master' branches"
@echo -e " ${WHITE} commitizen-bump :${NC} runs commitizen for releasing a new version on 'main' branch"
@echo -e " ${WHITE} commitizen-push :${NC} use git to push commits on 'development' and 'main' branches"
@echo -e "${RED}=======================|=========================================================================${NC}"
@echo ""

Expand Down Expand Up @@ -334,12 +334,12 @@ commitizen-bump:
conda activate ci-cd && \
git checkout development && \
git pull --ff-only && \
git checkout master && \
git checkout main && \
git pull --ff-only && \
git merge development --no-ff && \
cz bump --no-verify && \
git checkout development && \
git merge master --no-ff
git merge main --no-ff
@echo -e "${GREEN}done${NC}"

commitizen-push:
Expand All @@ -348,7 +348,7 @@ commitizen-push:
conda activate ci-cd && \
git checkout development && \
git pull --ff-only && \
git checkout master && \
git checkout main && \
git pull --ff-only && \
git push &&\
git push --tags &&\
Expand Down
4 changes: 2 additions & 2 deletions requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ channels:
- conda-forge
- pyviz
dependencies:
- python=3.11.4
- python=3.11.7
- setuptools=67.8.0
- click=8.0.4
- cryptography=39.0.1
- cryptography=42.0.4
- ipykernel=6.19.2
- ipywidgets=8.0.4
- openpyxl=3.0.10
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
setuptools==67.8.0
click==8.0.4
cryptography==39.0.1
cryptography==42.0.4
ipykernel==6.19.2
ipywidgets==8.0.4
openpyxl==3.0.10
Expand Down

0 comments on commit 2281323

Please sign in to comment.