Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/issue-branch-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Link Branch to Issue
# Point this to your centralized repository
uses: recursivezero/action-club/.github/actions/branch-notify@v0.2.57
with:
issue_prefix: ${{ vars.PROJECT_PREFIX || 'SAM'}}
branch_name: ${{ github.event.ref }}
dry_run: false
8 changes: 0 additions & 8 deletions .github/workflows/lint.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: true
Expand Down Expand Up @@ -52,6 +52,8 @@ jobs:
if: steps.deps.outputs.changed == 'true'
run: poetry install

- uses: lgeiger/pyflakes-action@master

- name: Export requirements
if: steps.deps.outputs.changed == 'true'
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ All notable changes to this repository will be documented in this file.
## [1.5.0] Mar 08, 2026

- Move templates inside src

## [1.5.2] Mar 14, 2026

- port priority from cli to env to fallback
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rz-sample"
version = "1.5.0"
version = "1.5.2"
description = "A python boilerplate for fastapi and streamlit projects."
authors = ["recursivezero <recursivezero@outlook.com>"]
license = "MIT"
Expand Down
8 changes: 6 additions & 2 deletions src/sample/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
from sample.utils.constants import PORT, PORT_API

from . import __version__

Expand All @@ -23,7 +24,10 @@ def cli(ctx, version):

@cli.command(help="Run the Sample Streamlit app.")
@click.option(
"--port", default=8501, show_default=True, help="Port to run the Streamlit app on."
"--port",
default=int(PORT),
show_default=True,
help="Port to run the Streamlit app on.",
)
def dev(port: int):
from sample.__main__ import main
Expand All @@ -34,7 +38,7 @@ def dev(port: int):
@cli.command(help="Run the Sample FastAPI backend.")
@click.option(
"--port",
default=5000,
default=int(PORT_API),
show_default=True,
help="Port to run the FastAPI backend on.",
)
Expand Down
15 changes: 10 additions & 5 deletions src/sample/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
load_env()
APP_TITLE = ":blue[Greeting Feature]"
DEFAULT_GREETING = "Hello"
DEFAULT_PORT = 8501
FAQ_TITLE = "FAQs"

logging.basicConfig(
Expand All @@ -22,7 +23,7 @@
COMPANY_LOGO = ASSETS_DIR / "logo.png"


def safe_get(secret_path: str, env_key: str = "", default: str = "") -> str:
def safe_get(env_key: str = "", default: str = "") -> str:
"""
Safely retrieve a configuration value from:
1. Streamlit secrets (if secrets.toml exists)
Expand All @@ -42,21 +43,25 @@ def safe_get(secret_path: str, env_key: str = "", default: str = "") -> str:
source = "env"

logging.info(
f"Loaded config for '{env_key or secret_path}' from [{source}]",
f"Loaded config for '{env_key}' from [{source}]",
extra={"color": "yellow"},
)
return value


def get_mongo_config():
return {
"MONGODB_URI": safe_get("mongodb.MONGODB_URI", "MONGODB_URI"),
"DATABASE_NAME": safe_get("mongodb.DATABASE_NAME", "DATABASE_NAME"),
"MONGODB_URI": safe_get("MONGODB_URI"),
"DATABASE_NAME": safe_get("DATABASE_NAME"),
}


PORT = safe_get("PORT", DEFAULT_PORT)
PORT_API = safe_get("API_PORT", int(PORT) + 1)


MONGO_CONFIG = get_mongo_config()
# === Environment Selection ===
ENVIRONMENT = safe_get("env.ENVIRONMENT", "ENVIRONMENT", "development").lower()
ENVIRONMENT = safe_get("ENVIRONMENT", "development").lower()
logging.info(f"Environment: {ENVIRONMENT}", extra={"color": "yellow"})
logging.info(f"Project root: {PROJECT_ROOT}", extra={"color": "yellow"})
Loading