Skip to content

Commit e433aaf

Browse files
author
John Dutchover
committed
Merge branch 'pip-refactor' into 'main'
Pip refactor See merge request johndutchover/insight-ai-api!21
2 parents 6039b45 + 99c8878 commit e433aaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+452
-1778
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,4 @@ $RECYCLE.BIN/
226226
*.msm
227227
*.msp
228228
*.lnk
229-
230-
### Custom ###
231-
venv-fe/**
232-
secrets.toml
233229
# End of file

.gitlab-ci.yml

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ workflow:
66
- when: never
77

88
default:
9-
image: python:3.11.6
9+
image: python:3.11.7
1010
before_script:
1111
- apt-get update -qq && apt-get install -y curl
1212
- curl -L https://fly.io/install.sh | sh
1313
- export FLYCTL_INSTALL="/root/.fly"
1414
- export PATH="$FLYCTL_INSTALL/bin:$PATH"
1515
- python --version
16-
- pip install virtualenv
16+
- python -m pip install virtualenv
1717
- python -m venv .venv
1818

1919
variables:
@@ -29,12 +29,14 @@ install_dependencies:
2929
stage: install
3030
script:
3131
- source .venv/bin/activate
32-
- pip install -r app/requirements_dev.txt
33-
- pip install -r app/requirements.txt
34-
- pip install pre-commit
32+
- python -m pip install -r app/requirements/requirements-dev.txt
33+
- python -m pip install -r app/requirements/requirements.txt
34+
- python -m pip install pre-commit
3535
rules:
3636
- changes:
3737
- Makefile
38+
- base.in
39+
- requirements-requirements-test.in
3840
- requirements-dev.in
3941
- requirements.in
4042
- pyproject.toml
@@ -43,7 +45,7 @@ install_dependencies:
4345

4446
config_changes:
4547
stage: test
46-
image: python:3.11.6
48+
image: python:3.11.7
4749
script:
4850
- source .venv/bin/activate
4951
rules:
@@ -55,53 +57,16 @@ config_changes:
5557
when: never
5658
- when: always
5759

58-
#mega-linter:
59-
# stage: code_quality
60-
# # You can override MegaLinter flavor used to have faster performances
61-
# # More info at https://megalinter.io/flavors/
62-
# image: oxsecurity/megalinter-python:v7.5.0
63-
# script: ["true"]
64-
# variables:
65-
# # All available variables are described in documentation
66-
# # https://megalinter.io/configuration/
67-
# DEFAULT_WORKSPACE: $CI_PROJECT_DIR
68-
# # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
69-
# ENABLE_LINTERS: MAKEFILE_CHECKMAKE,PYTHON_BLACK,PYTHON_FLAKE8
70-
# artifacts:
71-
# when: always
72-
# paths:
73-
# - megalinter-reports
74-
# expire_in: 1 week
75-
# rules:
76-
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"'
77-
# - when: always
78-
# - if: $CI_MERGE_REQUEST_TITLE =~ /^Draft:/
79-
# when: never
80-
8160
bandit:
8261
stage: code_quality
8362
script:
8463
- source .venv/bin/activate
85-
- pip install pre-commit
64+
- python -m pip install pre-commit
8665
- pre-commit run bandit --all-files
8766
rules:
8867
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"'
8968
- when: always
9069

91-
# Add a new deploy-backend-staging job
92-
deploy-backend-staging:
93-
stage: deploy
94-
script:
95-
- echo "Deploy backend app to staging from $CI_COMMIT_BRANCH branch"
96-
- flyctl auth token $FLY_API_TOKEN
97-
- flyctl deploy --ha=false --config app/fly.staging.toml
98-
environment: staging
99-
rules:
100-
- if: '$CI_COMMIT_BRANCH =~ /^(dev|feature-.*)$/'
101-
- when: manual
102-
- if: $CI_MERGE_REQUEST_TITLE =~ /^Draft:/
103-
when: never
104-
10570
deploy-backend:
10671
stage: deploy
10772
script:
@@ -114,17 +79,3 @@ deploy-backend:
11479
- when: manual
11580
- if: $CI_MERGE_REQUEST_TITLE =~ /^Draft:/
11681
when: never
117-
118-
deploy-frontend:
119-
stage: deploy
120-
script:
121-
- echo "Deploy frontend app from $CI_COMMIT_BRANCH branch"
122-
- export PYTHONPATH="client/"
123-
- flyctl auth token $FLY_API_TOKEN
124-
- flyctl deploy --ha=false --config frontend/fly.production.toml
125-
environment: production
126-
rules:
127-
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
128-
- when: manual
129-
- if: $CI_MERGE_REQUEST_TITLE =~ /^Draft:/
130-
when: never

.idea/inspectionProfiles/python_inspect.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/login__frontend_.xml

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

.idea/runConfigurations/main__api_.xml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/main__cli_.xml

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

.idea/runConfigurations/poethepoet_tests.xml

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

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.5.0
55
hooks:
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99

1010
- repo: https://github.com/psf/black
11-
rev: 23.7.0
11+
rev: 24.1.1
1212
hooks:
1313
- id: black
1414
types:
1515
- python
16-
args: ["--config=pyproject.toml"]
1716

1817
- repo: https://github.com/PyCQA/flake8
19-
rev: 6.0.0
18+
rev: 7.0.0
2019
hooks:
2120
- id: flake8
2221
types:
2322
- python
2423

2524
- repo: https://github.com/pycqa/bandit
26-
rev: 1.7.5
25+
rev: 1.7.7
2726
hooks:
2827
- id: bandit
2928
args: ["-c", "pyproject.toml", "-ll"]

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11.6
1+
3.11.7

Makefile

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

README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,29 @@ This is a simplistic FastAPI app that uses AI features to enhance api service.
2121

2222
Set Python version using pyenv
2323

24-
`pyenv local 3.11.6`
24+
`pyenv local 3.11.7`
2525

2626
- writes to `.python-version`
2727

28-
### Initialize virtualenv
28+
### Initialize for development
2929

3030
From repository root:
3131

32-
1. `make venv`
32+
1. `python -m venv .venv`
3333
2. `source .venv/bin/activate`
34+
3. `python -m pip install -Ur local.in`
3435

3536
### Dependency management
3637

3738
#### Makefile
3839

3940
Makefile command table
4041

41-
| Command | Purpose |
42-
|---------------------------------|------------------------------------------------------------------------------------|
43-
| `make venv` | Target to create and activate the app virtual environment |
44-
| `make venv-fe` | Target to create and activate the frontend virtual environment |
45-
| `make app/requirements` | Generate "app/requirements.txt" by compiling "requirements.in" |
46-
| `make app/requirements_dev` | Generate "app/requirements_dev.txt" by compiling "requirements-dev.in" |
47-
| `make app-requirements` | Generate "app/requirements.txt" and "app/requirements_dev.txt" |
48-
| `make frontend-requirements` | Generate "frontend/requirements_fe.txt" by compiling "requirements-fe.in" |
49-
| `make cli-requirements` | Generate "cli/requirements_fe.txt" by compiling "requirements-cli.in" |
50-
| `make compile-requirements` | Regenerate both "app/requirements.txt" and "app/requirements_dev.txt" |
51-
| `make compile-requirements-dev` | Regenerate "app/requirements_dev.txt" using "pip-compile" |
52-
| `make deploy-api` | Deploy app (api) using flyctl |
53-
| `make deploy-fe` | Deploy frontend using flyctl |
54-
| `make sync-requirements-app` | Synchronize .venv/ with the packages in requirements.txt and requirements_dev.txt |
55-
| `make sync-requirements-cli` | Synchronize cli/venv-cli/ with the packages in requirements_cli.txt |
56-
| `make sync-requirements-fe` | Synchronize frontend/venv-fe/ with the packages in requirements_frontend.txt |
42+
| Command | Purpose |
43+
|--------------------|------------------------------------------|
44+
| `make init` | Initialize Python environment |
45+
| `make update` | Update and Initialize Python environment |
46+
| `make update-deps` | Update Python dependencies |
5747

5848
### GitLab CI
5949

@@ -96,4 +86,8 @@ Makefile command table
9686

9787
### Fly
9888

99-
- app/fly.toml
89+
#### Production
90+
- app/fly.production.toml
91+
92+
#### Staging
93+
- app/fly.staging.toml

0 commit comments

Comments
 (0)