Skip to content

Commit cf80c7c

Browse files
Merge pull request #17 from recursivezero/feature/SAM-260015
[SAM-260015]: feat: update version to 1.5.1 and refactor port handlin…
2 parents 8de0500 + 7cbd65b commit cf80c7c

8 files changed

Lines changed: 27 additions & 21 deletions

File tree

.github/workflows/issue-branch-sync.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout Repo
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
1818

1919
- name: Link Branch to Issue
2020
# Point this to your centralized repository
2121
uses: recursivezero/action-club/.github/actions/branch-notify@v0.2.57
2222
with:
2323
issue_prefix: ${{ vars.PROJECT_PREFIX || 'SAM'}}
2424
branch_name: ${{ github.event.ref }}
25-
dry_run: false

.github/workflows/lint.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
lint:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
- name: Set up Python
1919
uses: actions/setup-python@v5
2020
with:
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Checkout code
32-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
3333

3434
- name: Set up Python
3535
uses: actions/setup-python@v5

.github/workflows/security.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
audit:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616
with:
1717
fetch-depth: 0
1818
persist-credentials: true
@@ -52,6 +52,8 @@ jobs:
5252
if: steps.deps.outputs.changed == 'true'
5353
run: poetry install
5454

55+
- uses: lgeiger/pyflakes-action@master
56+
5557
- name: Export requirements
5658
if: steps.deps.outputs.changed == 'true'
5759
run: |

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ All notable changes to this repository will be documented in this file.
2121
## [1.5.0] Mar 08, 2026
2222

2323
- Move templates inside src
24+
25+
## [1.5.2] Mar 14, 2026
26+
27+
- port priority from cli to env to fallback

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "rz-sample"
3-
version = "1.5.0"
3+
version = "1.5.2"
44
description = "A python boilerplate for fastapi and streamlit projects."
55
authors = ["recursivezero <recursivezero@outlook.com>"]
66
license = "MIT"

src/sample/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import click
2+
from sample.utils.constants import PORT, PORT_API
23

34
from . import __version__
45

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

2425
@cli.command(help="Run the Sample Streamlit app.")
2526
@click.option(
26-
"--port", default=8501, show_default=True, help="Port to run the Streamlit app on."
27+
"--port",
28+
default=int(PORT),
29+
show_default=True,
30+
help="Port to run the Streamlit app on.",
2731
)
2832
def dev(port: int):
2933
from sample.__main__ import main
@@ -34,7 +38,7 @@ def dev(port: int):
3438
@cli.command(help="Run the Sample FastAPI backend.")
3539
@click.option(
3640
"--port",
37-
default=5000,
41+
default=int(PORT_API),
3842
show_default=True,
3943
help="Port to run the FastAPI backend on.",
4044
)

src/sample/utils/constants.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
load_env()
88
APP_TITLE = ":blue[Greeting Feature]"
99
DEFAULT_GREETING = "Hello"
10+
DEFAULT_PORT = 8501
1011
FAQ_TITLE = "FAQs"
1112

1213
logging.basicConfig(
@@ -22,7 +23,7 @@
2223
COMPANY_LOGO = ASSETS_DIR / "logo.png"
2324

2425

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

4445
logging.info(
45-
f"Loaded config for '{env_key or secret_path}' from [{source}]",
46+
f"Loaded config for '{env_key}' from [{source}]",
4647
extra={"color": "yellow"},
4748
)
4849
return value
4950

5051

5152
def get_mongo_config():
5253
return {
53-
"MONGODB_URI": safe_get("mongodb.MONGODB_URI", "MONGODB_URI"),
54-
"DATABASE_NAME": safe_get("mongodb.DATABASE_NAME", "DATABASE_NAME"),
54+
"MONGODB_URI": safe_get("MONGODB_URI"),
55+
"DATABASE_NAME": safe_get("DATABASE_NAME"),
5556
}
5657

5758

59+
PORT = safe_get("PORT", DEFAULT_PORT)
60+
PORT_API = safe_get("API_PORT", int(PORT) + 1)
61+
62+
5863
MONGO_CONFIG = get_mongo_config()
5964
# === Environment Selection ===
60-
ENVIRONMENT = safe_get("env.ENVIRONMENT", "ENVIRONMENT", "development").lower()
65+
ENVIRONMENT = safe_get("ENVIRONMENT", "development").lower()
6166
logging.info(f"Environment: {ENVIRONMENT}", extra={"color": "yellow"})
6267
logging.info(f"Project root: {PROJECT_ROOT}", extra={"color": "yellow"})

0 commit comments

Comments
 (0)