Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme file updated along with other validations #42

Merged

Conversation

anasnadeemws
Copy link
Collaborator

@anasnadeemws anasnadeemws commented Apr 8, 2024

Ticket Link


Related Links


Description

Readme file has been updated as more user-beginner friendly to get started with the template.
Environment variables check added on server startup
Removed unnecessary requirement in requirements.txt for faster setup for end user.
Fixed opentelemetry warning while running server

Steps to Reproduce / Test



Checklist

  • PR description included
  • pytest passes
  • Tests are [changed or added]
  • Relevant documentation is changed or added (and PR referenced)

GIF's


Copy link

github-actions bot commented Apr 8, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   app.py38380%1–70
app/config
   __init__.py3167%6
   base.py38879%29–36, 54–55
   celery_config.py17170%1–27
   celery_utils.py21210%1–30
   redis_config.py5260%8–9
app/constants
   jwt_utils.py161131%11–23
app/daos
   home.py10550%11–18
   users.py726411%12–136
app/middlewares
   cache_middleware.py51510%1–67
   rate_limiter_middleware.py25250%1–35
   request_id_injection.py17170%1–25
app/models
   __init__.py330%1–5
   users.py27270%1–38
app/routes
   __init__.py12120%1–15
app/routes/cache_router
   __init__.py330%1–5
   cache_samples.py12120%1–18
app/routes/celery_router
   __init__.py330%1–5
   celery_samples.py12120%1–17
app/routes/home
   __init__.py330%1–5
   home.py33330%1–45
app/routes/users
   __init__.py330%1–5
   users.py38380%1–57
app/schemas/users
   users_request.py42420%1–73
   users_response.py10100%1–14
app/sessions
   db.py53530%1–82
app/tests
   test_basic.py201620%8–34
   test_daos_home.py231057%15–22, 28–37, 41
   test_daos_users.py1109514%19–208
app/utils
   exception_handler.py19190%1–36
   redis_utils.py440%1–7
   slack_notification_utils.py14140%1–32
   user_utils.py25250%1–36
app/wrappers
   cache_wrappers.py19190%1–24
TOTAL81871612% 

Tests Skipped Failures Errors Time
2 0 💤 0 ❌ 2 🔥 0.559s ⏱️

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@@ -11,28 +11,29 @@ class DBSettings(BaseSettings):
DB_PASSWORD: str

class Config:
env_file = ".env"
env_file = ".env.local"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will it behave with .env.docker file Add a comment here please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I researched a bit and found out that each env file is unique.
And so by the previous '.env', your docker wouldn't work cause if you'll check your compose file it is .env.${environment_name} now in any case it will never be .env and docker won't work and so I've standardized it and fixed your docker error too.

Here's you can repro the uniqueness,
change your .env file to .env.local in your current code and run it.

Also there is a hierarchy of it:
Here's the priority of the files for the development build and the production build:
Dev.: (npm start): .env.development.local, .env.local, .env.development, .env
Prod.: (npm run build): .env.production.local, .env.local, .env.production, .env

And so by this .env.local is pretty standard and solves your compose problem too

ALLOWED_HOSTS: list = ["*"]
CACHE_MAX_AGE: int = 60

class Config:
env_file = ".env"
env_file = ".env.local"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

compose.yaml Outdated
@@ -45,14 +45,12 @@ services:
restart: always
container_name: fast-api-app
env_file:
- ./.env.${ENVIRONMENT_NAME}
- ./.env.local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert it as it is dynamically get injected with active environment variable

compose.yaml Outdated
@@ -62,7 +60,7 @@ services:
dockerfile: Dockerfile
command: ['celery', '-A', 'app.app.celery', 'worker', '-l', 'info']
env_file:
- .env.${ENVIRONMENT_NAME}
- .env.local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous

.env.example Outdated
SENTRY_ENABLED=
SLACK_ENABLED=
# Advance Usage - Docker Configuration
DB_ROOT_PASSWORD=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move it to belkow line 7 so that all db config get together

Copy link

sonarqube-ws bot commented Apr 8, 2024

Passed

Analysis Details

0 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 0 Code Smells

Coverage and Duplications

  • Coverage No coverage information (0.00% Estimated after merge)
  • Duplications 0.00% Duplicated Code (0.00% Estimated after merge)

Project ID: wednesday-solutions_python-fastapi_AY434cJSB2n8RRmGoUoD

View in SonarQube

@@ -11,28 +11,29 @@ class DBSettings(BaseSettings):
DB_PASSWORD: str

class Config:
env_file = ".env"
env_file = ".env.local"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont harcode. .env.local keep it .env.${environment_name} i mean to say this

Copy link
Collaborator Author

@anasnadeemws anasnadeemws Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, for it take the environment name it has to go to .env file and for it to go to environment file it has to know the .env file.

It's not gonna work as it's a circular thing. We can have some sort of hack here tho but that's not gonna remain a standard base file

Also please go through the hierarchy pattern I've mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference link please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shamoilattaar-wednesday shamoilattaar-wednesday merged commit f1453be into main Apr 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants