Skip to content

Commit 378e4f2

Browse files
authored
chore(CI): fix CI workflows (#214)
* fix(CI): fix CI workflows * run pre-commit * include pre-commit before testing * include pre-commit before commiting * linting pt.1 * linting pt.2 * replace mocked tests by endpoint tests * remove compose-go * linting pt.3 final
1 parent 84f16fa commit 378e4f2

Some content is hidden

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

92 files changed

+1480
-2207
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ jobs:
3535
- name: Run jupyterlab with PySUS
3636
run: |
3737
make run-jupyter-pysus
38+
# make test-jupyter-pysus ## takes too long
3839
39-
- name: Test with pytest
40+
- name: Linting & Tests
4041
run: |
4142
poetry install
43+
pre-commit run --all-files
4244
make test-pysus

.idea/PySUS.iml

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

.idea/misc.xml

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

.pre-commit-config.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
default_stages: [commit, push]
2+
13
repos:
24
- repo: https://github.com/pre-commit/pre-commit-hooks
35
rev: v4.1.0
@@ -16,8 +18,6 @@ repos:
1618
files: ""
1719
language: system
1820
pass_filenames: true
19-
stages:
20-
- commit
2121
types:
2222
- python
2323
- file
@@ -30,8 +30,6 @@ repos:
3030
language: python
3131
name: flake8
3232
pass_filenames: true
33-
stages:
34-
- commit
3533
types:
3634
- python
3735

@@ -42,7 +40,5 @@ repos:
4240
language: python
4341
name: isort
4442
pass_filenames: true
45-
stages:
46-
- commit
4743
types:
4844
- python

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export PRINT_HELP_PYSCRIPT
2222
help:
2323
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
2424

25-
DOCKER = docker-compose -p pysus -f docker/docker-compose.yaml
25+
DOCKER = docker compose -p pysus -f docker/docker-compose.yaml
2626
SERVICE :=
2727
SEMANTIC_RELEASE = npx --yes \
2828
-p semantic-release \
@@ -48,11 +48,10 @@ down-jupyter-pysus: ## stop and remove containers for all services
4848
#* Tests
4949
.PHONY: test-jupyter-pysus
5050
test-jupyter-pysus: ## run pytest for notebooks inside jupyter container
51-
$(DOCKER) exec -T jupyter bash /test_notebooks.sh
51+
$(DOCKER) exec -T jupyter pytest -vv --nbmake
5252

5353
.PHONY: test-pysus
5454
test-pysus: ## run tests quickly with the default Python
55-
cp docs/source/**/*.ipynb pysus/Notebooks
5655
poetry run pytest -vv pysus/tests/
5756

5857
# RELEASE

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ First, clone the Pysus repository:
5555

5656
```bash
5757
git clone https://github.com/fccoelho/PySUS.git
58-
```
58+
```
5959
then from within the PySUS directory build the container
6060

6161
```bash
@@ -72,7 +72,7 @@ Point your browser to [http://127.0.0.1:8888](http://127.0.0.1:8888) and have fu
7272
Once you are done, you can stop the container with a simple `ctrl-c` from the terminal you started it or use the following command:
7373
```bash
7474
# to find the container ID
75-
docker ps
75+
docker ps
7676
docker stop <CONTAINER ID>
7777
```
7878
### Mounting your working directory in the container
@@ -105,7 +105,7 @@ setx PYSUS_CACHEPATH "C:\Users\Me\desired\path\.pysus"
105105
In Docker, just add an extra parameter `-e PYSUS_CACHEPATH="/home/me/desired/path/.pysus"` when starting the container:
106106

107107
```bash
108-
docker run -p 8888:8888 -e PYSUS_CACHEPATH="/home/me/desired/path/.pysus" pysus:latest
108+
docker run -p 8888:8888 -e PYSUS_CACHEPATH="/home/me/desired/path/.pysus" pysus:latest
109109
```
110110

111111
## Examples
@@ -164,7 +164,7 @@ Downloading and reading SINASC data:
164164
In[1]: from pysus.online_data.sinasc import download
165165
In[2]: df = download('SE', 2015)
166166
In[3]: df.head()
167-
Out[3]:
167+
Out[3]:
168168
NUMERODN CODINST ORIGEM ... TPROBSON PARIDADE KOTELCHUCK
169169
0 19533794 MSE2805100001 1 ... 11 1 9
170170
1 52927108 MSE2802700001 1 ... 11 1 9
@@ -180,7 +180,7 @@ Dowloading and reading SIM data:
180180
In[1]: from pysus.online_data.SIM import download
181181
In[2]: df = download('ba', 2007)
182182
In[3]: df.head()
183-
Out[3]:
183+
Out[3]:
184184
NUMERODO TIPOBITO DTOBITO ... UFINFORM CODINST CB_PRE
185185
0 01499664 2 30072007 ... 29 RBA2914800001 C229
186186
1 09798190 2 04072007 ... 29 RBA2914800001 R98
@@ -196,7 +196,7 @@ Dowloading and reading CIHA data:
196196
In[1]: from pysus.online_data.CIHA import download
197197
In[2]: df = download('mg', 2009, 7)
198198
In[3]: df.head()
199-
Out[3]:
199+
Out[3]:
200200
ANO_CMPT MES_CMPT ESPEC CGC_HOSP ... CAR_INT HOMONIMO CNES FONTE
201201
0 2009 07 16505851000126 ... 2126796 1
202202
1 2009 07 16505851000126 ... 2126796 2
@@ -212,7 +212,7 @@ Dowloading and reading SIA data:
212212
In[1]: from pysus.online_data.SIA import download
213213
In[2]: bi, ps = download('AC', 2020, 3, group=["BI", "PS"])
214214
In[3]: bi.head()
215-
Out[3]:
215+
Out[3]:
216216
CODUNI GESTAO CONDIC UFMUN TPUPS ... VL_APROV UFDIF MNDIF ETNIA NAT_JUR
217217
0 2000733 120000 EP 120040 07 ... 24.2 0 0 1023
218218
1 2001063 120000 EP 120040 36 ... 7.3 0 0 1023

conda/dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6+
- docker-compose
67
- python >=3.10,<3.12
78
- numpy>=1.26.2
89
- cffi

condarecipe/pysus/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ about:
4747
home: "https://github.com/fccoelho/PySUS"
4848
license: gpl-v3
4949
license_family: GPL3
50-
license_file:
50+
license_file:
5151
summary: "Tools for dealing with Brazil's Public health data"
52-
doc_url:
53-
dev_url:
52+
doc_url:
53+
dev_url:
5454

5555
extra:
5656
recipe-maintainers:

docker/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ RUN useradd -ms /bin/bash pysus \
3030
&& chmod -R a+rwx /opt/conda /tmp \
3131
&& sudo chown -R pysus:pysus /usr/src
3232

33+
USER pysus
34+
35+
RUN mkdir -p /home/pysus/Notebooks/
36+
3337
COPY --chown=pysus:pysus conda/dev.yaml /tmp/dev.yaml
3438
COPY --chown=pysus:pysus docker/scripts/entrypoint.sh /entrypoint.sh
3539
COPY --chown=pysus:pysus docker/scripts/poetry-install.sh /tmp/poetry-install.sh
@@ -38,8 +42,6 @@ COPY --chown=pysus:pysus pysus /usr/src/pysus
3842
COPY --chown=pysus:pysus docs/source/**/*.ipynb /home/pysus/Notebooks/
3943
COPY --chown=pysus:pysus docs/source/data /home/pysus/Notebooks/
4044

41-
USER pysus
42-
4345
RUN mamba env create -n $ENV_NAME --file /tmp/dev.yaml \
4446
&& mamba clean -afy
4547

docker/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '3.3'
2-
services:
2+
services:
33
jupyter:
44
build:
55
context: ".."

0 commit comments

Comments
 (0)