diff --git a/.github/workflows/issue-branch-sync.yml b/.github/workflows/issue-branch-sync.yml index fb6d5a6..2f2fd16 100644 --- a/.github/workflows/issue-branch-sync.yml +++ b/.github/workflows/issue-branch-sync.yml @@ -14,7 +14,7 @@ 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 @@ -22,4 +22,3 @@ jobs: with: issue_prefix: ${{ vars.PROJECT_PREFIX || 'SAM'}} branch_name: ${{ github.event.ref }} - dry_run: false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index d7c0bca..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: Syntax Check -on: push -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: lgeiger/pyflakes-action@master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 153ce57..b18311c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index a414b76..28c8e58 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -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 @@ -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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 572448b..d98c289 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 1e04340..65baad6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" diff --git a/src/sample/cli.py b/src/sample/cli.py index ccf83be..e5492a1 100644 --- a/src/sample/cli.py +++ b/src/sample/cli.py @@ -1,4 +1,5 @@ import click +from sample.utils.constants import PORT, PORT_API from . import __version__ @@ -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 @@ -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.", ) diff --git a/src/sample/utils/constants.py b/src/sample/utils/constants.py index 74d2bd2..60a7813 100644 --- a/src/sample/utils/constants.py +++ b/src/sample/utils/constants.py @@ -7,6 +7,7 @@ load_env() APP_TITLE = ":blue[Greeting Feature]" DEFAULT_GREETING = "Hello" +DEFAULT_PORT = 8501 FAQ_TITLE = "FAQs" logging.basicConfig( @@ -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) @@ -42,7 +43,7 @@ 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 @@ -50,13 +51,17 @@ def safe_get(secret_path: str, env_key: str = "", default: str = "") -> str: 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"})