Skip to content

Commit b80ab76

Browse files
committed
test pipeline with catalog
1 parent 6334f51 commit b80ab76

File tree

4 files changed

+81
-3
lines changed

4 files changed

+81
-3
lines changed

argo-pipeline/pipeline.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ spec:
8787
- name: year
8888
value: "{{item}}"
8989
withParam: "{{tasks.operationnal-selection-of-vintages-to-generate.outputs.parameters.years}}"
90+
91+
# TASK 6 : GENERATE CATALOG
92+
- name: make-catalog
93+
template: make-catalog
94+
dependencies: [generate-downstream-datasets]
9095

9196
# --------------------------
9297
# TEMPLATES DEFINITION
@@ -132,8 +137,8 @@ spec:
132137
- name: PATH_WRITING_S3
133138
value: "test"
134139
- name: ENVIRONMENT
135-
# set value to "dev" to simplify pipeline execution (2 years, only topojson, etc.)
136-
value: preprod
140+
# set value to "dev" to simplify pipeline execution (2 years, only topojson, etc.), use "preprod" or "prod" else
141+
value: test
137142

138143
- name: download-all-sources
139144
outputs:
@@ -299,3 +304,18 @@ spec:
299304
- name: volume-workflow-tmp
300305
mountPath: /mnt
301306
env: *env_parameters
307+
308+
- name: make-catalog
309+
outputs:
310+
parameters:
311+
- name: result
312+
valueFrom:
313+
path: "catalog/result.json"
314+
container:
315+
image: inseefrlab/cartiflette:latest
316+
command: ["sh", "-c"]
317+
args: ["python /mnt/bin/src/catalog.py"]
318+
volumeMounts:
319+
- name: volume-workflow-tmp
320+
mountPath: /mnt
321+
env: *env_parameters

argo-pipeline/src/catalog.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Create cartiflette's catalog
6+
"""
7+
8+
import json
9+
import logging
10+
11+
from s3fs import S3FileSystem
12+
13+
from cartiflette.config import (
14+
BUCKET,
15+
PATH_WITHIN_BUCKET,
16+
FS,
17+
)
18+
from cartiflette.s3 import make_s3_inventory
19+
20+
logger = logging.getLogger(__name__)
21+
logging.basicConfig(level=logging.INFO)
22+
23+
logger.info("=" * 50)
24+
logger.info("\n%s", __doc__)
25+
logger.info("=" * 50)
26+
27+
# Nota : no parsed needed for this command
28+
29+
30+
def main(
31+
bucket: str = BUCKET,
32+
path_within_bucket: str = PATH_WITHIN_BUCKET,
33+
fs: S3FileSystem = FS,
34+
):
35+
36+
success = True
37+
try:
38+
make_s3_inventory(
39+
fs=fs, bucket=bucket, path_within_bucket=path_within_bucket
40+
)
41+
except Exception:
42+
success = False
43+
44+
out_path = "catalog/result.json"
45+
with open(out_path, "w", encoding="utf8") as out:
46+
json.dump(success, out)
47+
48+
logger.info("Success!")
49+
50+
51+
if __name__ == "__main__":
52+
main(
53+
bucket=BUCKET,
54+
path_within_bucket=PATH_WITHIN_BUCKET,
55+
fs=FS,
56+
)

cartiflette/s3/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from .download_vectorfile import download_vectorfile_url_all
22
from .geodataset import S3GeoDataset, concat_s3geodataset
33
from .dataset import S3Dataset
4+
from .inventory import make_s3_inventory
45

56
__all__ = [
67
"download_vectorfile_url_all",
78
"S3GeoDataset",
89
"S3Dataset",
910
"concat_s3geodataset",
11+
"make_s3_inventory",
1012
]

python-package/cartiflette/cartiflette/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DIR_CACHE = platformdirs.user_cache_dir(APP_NAME, ensure_exists=True)
1010
CACHE_NAME = "cartiflette_http_cache.sqlite"
1111
BUCKET = "projet-cartiflette"
12-
PATH_WITHIN_BUCKET = "production"
12+
PATH_WITHIN_BUCKET = "test"
1313

1414
CATALOG = url = (
1515
"https://minio.lab.sspcloud.fr/"

0 commit comments

Comments
 (0)