Skip to content

Commit a9f6afb

Browse files
Merge pull request #2 from pyronear/rs/add-load-script
ETL Formalization
2 parents 9424ee6 + 9886f6b commit a9f6afb

File tree

14 files changed

+385
-85
lines changed

14 files changed

+385
-85
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
*.pyc
3+
__pycache__
4+
*.log

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
max-line-length = 120
3+
ignore = E203, E402, E265, F403, W503, W504, E731
4+
exclude = .git, venv*, docs, build
5+
per-file-ignores = **/__init__.py:F401

.github/collect_env.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848

4949
def run(command):
5050
"""Returns (return-code, stdout, stderr)"""
51-
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
51+
p = subprocess.Popen(
52+
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
53+
)
5254
output, err = p.communicate()
5355
rc = p.returncode
5456
if PY3:
@@ -99,11 +101,15 @@ def get_windows_version(run_lambda):
99101

100102

101103
def get_lsb_version(run_lambda):
102-
return run_and_parse_first_match(run_lambda, "lsb_release -a", r"Description:\t(.*)")
104+
return run_and_parse_first_match(
105+
run_lambda, "lsb_release -a", r"Description:\t(.*)"
106+
)
103107

104108

105109
def check_release_file(run_lambda):
106-
return run_and_parse_first_match(run_lambda, "cat /etc/*-release", r'PRETTY_NAME="(.*)"')
110+
return run_and_parse_first_match(
111+
run_lambda, "cat /etc/*-release", r'PRETTY_NAME="(.*)"'
112+
)
107113

108114

109115
def get_os(run_lambda):

.github/workflows/style.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ jobs:
6868
run: |
6969
python -m pip install --upgrade pip
7070
pip install -e . --upgrade
71+
pip install -r requirements.txt
7172
pip install mypy
7273
- name: Run mypy
7374
run: |
7475
mypy --version
75-
mypy
76+
mypy --config-file pyproject.toml
7677
7778
pydocstyle:
7879
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ conda-dist/
123123
#project
124124
AWF_scrap*
125125
*.jpg
126-
*.pt
126+
*.pt
127+
128+
cameras.csv
129+
credentials.json
130+
*.github*

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM pyronear/pyro-engine:latest
2+
3+
# set work directory
4+
WORKDIR /usr/src/app
5+
6+
7+
COPY requirements.txt requirements.txt
8+
RUN pip install --default-timeout=500 -r requirements.txt \
9+
&& pip cache purge \
10+
&& rm -rf /root/.cache/pip
11+
12+
# Copy only the necessary application files
13+
COPY src/ /usr/src/app

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# this target runs checks on all files and potentially modifies some of them
22
style:
33
isort .
4-
black .
4+
black --diff .
55

6+
quality:
7+
isort .
8+
flake8
9+
mypy
10+
pydocstyle
11+
12+
build:
13+
docker build . -t pyronear/pyro-etl
14+
15+
run-etl:
16+
docker run pyronear/pyro-etl:latest /bin/sh -c "python /app/dl_images.py && python /app/predict_load.py"

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Pyro-Scrapper is a specialized tool designed for scraping images from [Alert Wil
2020
Certainly! Here's the revised Usage section with the added code snippets:
2121

2222
## Installation and Usage
23+
24+
### Locally
2325
- Clone the repository.
2426
- Ensure you have the required dependencies by installing them from `requirements.txt`.
2527

@@ -40,6 +42,16 @@ python/split_cams.py
4042

4143
These commands will initiate the image scraping and view point splitting.
4244

45+
46+
### Using the docker image
47+
48+
First you will need to generate the credentials.json file according to the source you want to scrapp.
49+
For the alertwildfire , you can use the src/generate_wildfire_config.py script.
50+
51+
Then you have two choices :
52+
1) using the pyro-devops dev env, copying the credentials.json file in the data/ folder and launching the 'make-etl' command
53+
2) filling your .env locally (API_URL) in order to use an external Pyro-API , filling the token part of the credentials.json and launching the command 'make run-etl' from this repo.
54+
4355
## Contributing
4456

4557
Please refer to [`CONTRIBUTING`](CONTRIBUTING.md) if you wish to contribute to this project.
@@ -51,5 +63,3 @@ This project is developed and maintained by the repo owner and volunteers from [
5163
## License
5264

5365
Distributed under the Apache 2 License. See [`LICENSE`](LICENSE) for more information.
54-
55-

pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
[tool.mypy]
3+
files = "src/"
4+
show_error_codes = true
5+
pretty = true
6+
warn_unused_ignores = true
7+
warn_redundant_casts = true
8+
no_implicit_optional = true
9+
check_untyped_defs = true
10+
implicit_reexport = false
11+
12+
[[tool.mypy.overrides]]
13+
module = [
14+
"onnxruntime.*",
15+
"requests.*",
16+
"PIL.*",
17+
"pyroclient.*",
18+
"urllib3.*",
19+
"pyroengine.*",
20+
]
21+
ignore_missing_imports = true
22+
23+
[tool.isort]
24+
line_length = 120
25+
src_paths = ["src", ".github"]
26+
skip_glob = "**/__init__.py"
27+
28+
[tool.pydocstyle]
29+
select = "D300,D301,D417"
30+
match = ".*\\.py"
31+
32+
[tool.coverage.run]
33+
source = ["src"]
34+
35+
[tool.black]
36+
line-length = 120
37+
target-version = ['py38']

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
opencv-python
22
tqdm
3+
types-tqdm
34
requests
45
python-dotenv
56
pytz
7+
types-pytz
8+
Pillow
69

710
#Style
811
black

0 commit comments

Comments
 (0)