Skip to content

Commit ebaefc7

Browse files
authored
Migrated package manager from pipenv to poetry (#26)
Migrated package manager from pipenv to poetry
1 parent 926b5ec commit ebaefc7

File tree

14 files changed

+1228
-909
lines changed

14 files changed

+1228
-909
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.git
2+
dist
3+
.pytest_cache
24
volumes
35
.env*

.env.localhost.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# COMMONS
2-
MONGODB_URL=mongodb://localhost:27017/winds_mobi
2+
MONGODB_URL=mongodb://localhost:27017/winds
33
REDIS_URL=redis://localhost:6380/0
44
GOOGLE_API_KEY=
55

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# COMMONS
2-
MONGODB_URL=mongodb://mongodb:27017/winds_mobi
2+
MONGODB_URL=mongodb://mongodb:27017/winds
33
REDIS_URL=redis://host.docker.internal:6380/0
44
GOOGLE_API_KEY=
55

.github/workflows/test-python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
with:
2121
python-version: ${{ env.PYTHON_VERSION }}
2222

23-
- name: Install python dependencies with pipenv
23+
- name: Install python dependencies with poetry
2424
run: |
25-
pip install pipenv
26-
pipenv install --deploy --dev
25+
pip install poetry
26+
poetry install
2727
2828
- name: Check python code format
29-
run: pipenv run black --check .
29+
run: poetry run black --check .
3030

3131
- name: Run python linter
32-
run: pipenv run flake8 .
32+
run: poetry run flake8 .
3333

3434
- name: Run python tests
35-
run: pipenv run pytest
35+
run: poetry run pytest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*.pyc
2+
dist/
3+
.pytest_cache
24
.idea/
35
/volumes/
46
.env

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ FROM base AS python
1010

1111
RUN apt update; \
1212
apt --yes --no-install-recommends install build-essential libpq-dev libmariadb-dev
13-
RUN pip install pipenv
13+
RUN pip install poetry
1414

1515
COPY . .
16-
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
16+
RUN POETRY_VIRTUALENVS_IN_PROJECT=true poetry install --no-dev
1717

1818
FROM base AS runtime
1919

Pipfile

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

Pipfile.lock

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

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Google Cloud API results are cached with redis.
1616

1717
### Requirements
1818

19-
- python 3.9
19+
- python 3.9 and poetry
2020
- mongodb 4.4
2121
- redis
2222
- Google Cloud API key
@@ -25,6 +25,9 @@ See [settings.py](https://github.com/winds-mobi/winds-mobi-providers/blob/master
2525

2626
#### macOS 11
2727

28+
- `brew install openssl`
29+
- `export LDFLAGS=-L/usr/local/opt/openssl/lib`
30+
2831
- `brew install mysql-client`
2932
- `export PATH=/usr/local/opt/mysql-client/bin:$PATH`
3033

@@ -36,8 +39,8 @@ See [settings.py](https://github.com/winds-mobi/winds-mobi-providers/blob/master
3639

3740
### Python environment
3841

39-
- `pipenv install`
40-
- `pipenv shell`
42+
- `poetry install`
43+
- `poetry shell`
4144

4245
### Run the project with docker compose
4346

admin_clusters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from winds_mobi_provider.logging import configure_logging
1212

1313
configure_logging()
14-
log = logging.getLogger(__file__)
14+
log = logging.getLogger(__name__)
1515

1616

1717
def save_clusters(nb_clusters):
@@ -68,6 +68,7 @@ def save_clusters(nb_clusters):
6868
mongo_bulk.find({"_id": ids[index]}).update({"$addToSet": {"clusters": int(n_clusters)}})
6969

7070
mongo_bulk.execute()
71+
log.info(f"Done, created {nb_clusters} clusters")
7172
except Exception as e:
7273
log.exception(f"Error while creating clusters: {e}")
7374

admin_stations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from winds_mobi_provider.logging import configure_logging
1010

1111
configure_logging()
12-
log = logging.getLogger(__file__)
12+
log = logging.getLogger(__name__)
1313

1414

1515
def delete_stations(days: int, provider: Optional[str]):
@@ -20,13 +20,16 @@ def delete_stations(days: int, provider: Optional[str]):
2020
query = {"seen": {"$lt": now - days * 3600 * 24}}
2121
if provider:
2222
query["pv-code"] = provider
23+
nb = 0
2324
for station in mongo_db.stations.find(query):
2425
seen = arrow.Arrow.fromtimestamp(station["seen"])
2526
log.info(
2627
f"Deleting {station['_id']} ['{station['short']}'], last seen at {seen.format('YYYY-MM-DD HH:mm:ssZZ')}"
2728
)
2829
mongo_db[station["_id"]].drop()
2930
mongo_db.stations.remove({"_id": station["_id"]})
31+
nb += 1
32+
log.info(f"Done, deleted {nb} stations")
3033

3134

3235
if __name__ == "__main__":

0 commit comments

Comments
 (0)