Skip to content

Commit

Permalink
Create light client package (#104)
Browse files Browse the repository at this point in the history
* create directory python-package in order to publish on pypi

* prepare publish.yml

* add readme

* update readme

* update readme

* fix pipeline

* fix pipeline

* fix pipeline to change directory

* rename publish into publish-client

* update readme

* update client version

* create function that opens session automatically

* update readme

* add a test

* update package version

* add geopandas to test

* fix workflow

* fix workflow

* replace carti_dataset by carti_download

* update client version

* add proxies and add test

* update readme

* import cartiflette.client as cartiflette

---------

Co-authored-by: Alica Burlot <[email protected]>
  • Loading branch information
tgrandje and B-Alica authored Dec 14, 2024
1 parent 2e38b5f commit f6b0c5d
Show file tree
Hide file tree
Showing 11 changed files with 1,940 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/publish-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: test_and_publish

on:
push:
tags:
- 'client-*'

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-package/cartiflette
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.9'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction --without dev

#----------------------------------------------
# add only pytest for tests (not the full dev dependencies)
#----------------------------------------------
- name: Add pytest
run: poetry run pip install pytest

#----------------------------------------------
# add only pytest-cov for tests (not the full dev dependencies)
#----------------------------------------------
- name: Add pytest-cov
run: poetry run pip install pytest-cov

#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: poetry run pytest --cov -W error

publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-package/cartiflette
needs: test
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.9'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1

#----------------------------------------------
# config pypi token
#----------------------------------------------
- name: Set pypi token
run: poetry config pypi-token.pypi ${{secrets.PAT_PYPI}}

#----------------------------------------------
# build
#----------------------------------------------
- name: Build
run: poetry build

#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Publish to Pypi
run: poetry publish
68 changes: 68 additions & 0 deletions python-package/cartiflette/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Cartiflette [![](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) ![](https://cdn.simpleicons.org/python/00ccff99?viewbox=auto&size=18)


`cartiflette` est un projet pour faciliter l’association de sources
géographiques en proposant des récupérations facilitées de coutours de
cartes officiels.

Une documentation interactive est disponible [ici](https://inseefrlab.github.io/cartiflette-website/index.html).

L'objectif de `cartiflette` est d'offrir des méthodes fiables,
reproductibles et multi-langages pour récupérer des fonds de carte officiels de l'IGN
enrichis de métadonnées utiles pour la cartographie et la _data science_.

La librairie python `cartiflette` ![](https://cdn.simpleicons.org/python/00ccff99?viewbox=auto&size=18) permet la récupération des fonds de carte de l'IGN.

## Installer la librairie python ![](https://cdn.simpleicons.org/python/00ccff99?viewbox=auto&size=18)
``` python
pip install cartiflette
```


## Exemples

Plus d'exemples sont disponibles dans la [documentation interactive](https://inseefrlab.github.io/cartiflette-website/index.html).

Exemple de récupération du fonds de carte des départements avec les DROM rapprochés de la France métropolitaine
``` python
from cartiflette import carti_download

data = carti_download(
values = ["France"],
crs = 4326,
borders = "DEPARTEMENT",
vectorfile_format="topojson",
simplification=50,
filter_by="FRANCE_ENTIERE_DROM_RAPPROCHES",
source="EXPRESS-COG-CARTO-TERRITOIRE",
year=2022
)
```

Si besoin de passer par un proxy, il faut déclarer http_proxy et https_proxy en variable d'environnement. Par exemple :
``` python
import os

from cartiflette import carti_download

os.environ["http_proxy"] = yourproxy
os.environ["https_proxy"] = yourproxy

data = carti_download(
values = ["France"],
crs = 4326,
borders = "DEPARTEMENT",
vectorfile_format="topojson",
simplification=50,
filter_by="FRANCE_ENTIERE_DROM_RAPPROCHES",
source="EXPRESS-COG-CARTO-TERRITOIRE",
year=2022
)
```

## Contexte

Le projet `cartiflette` est un projet collaboratif lancé par des agents de l'Etat dans le cadre d'un programme interministériel
nommé [Programme 10%](https://www.10pourcent.etalab.gouv.fr/).

__Vous désirez contribuer ?__ Plus d'information sont disponibles dans le fichier [CONTRIBUTING.md](https://github.com/InseeFrLab/cartiflette/blob/main/CONTRIBUTING.md)
8 changes: 8 additions & 0 deletions python-package/cartiflette/cartiflette/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from importlib.metadata import version

from .config import _config
from .client import carti_download

__version__ = version(__package__)

__all__ = ["carti_download"]
Loading

0 comments on commit f6b0c5d

Please sign in to comment.