Skip to content

new catalog module using Melodi API #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
60b8623
first commit for catalog module
hadrilec Sep 7, 2024
94137fb
Bugfix/clean tmpfiles (#206)
tgrandje Sep 9, 2024
5e31d72
Fix geodata ign test url (#220)
tfardet Oct 14, 2024
9f78949
Restore _wait_api_query_limit (#222)
tgrandje Oct 14, 2024
dcb0c57
new portal modifications (#227)
hadrilec Dec 30, 2024
8b9533d
newportal typo fix in tests
hadrilec Dec 30, 2024
1a0beb1
drop pkg_resources as py>=3.12 does not support it anymore
hadrilec Dec 30, 2024
e234b1a
tests with py-3.12 instead of 3.8
hadrilec Dec 30, 2024
205cf17
bug fix in _request_insee in utils module
hadrilec Dec 30, 2024
8b66db5
get_included_area is removed after deprecation
hadrilec Dec 31, 2024
4a806a8
find_latest_dataset in localdata module with hidden print
hadrilec Dec 31, 2024
8d572d3
local data API fix
hadrilec Dec 31, 2024
27675d2
shorter and improved tests
hadrilec Dec 31, 2024
de7da03
split tests across different py versions
hadrilec Dec 31, 2024
6a904d2
utils tests fix
hadrilec Dec 31, 2024
dad0524
bug fix latest local dataset
hadrilec Dec 31, 2024
a9942ca
option to test all modules locally in an easy way
hadrilec Dec 31, 2024
9df5e2a
minor - hidden print in a back function
hadrilec Dec 31, 2024
10b7c34
test fix
hadrilec Dec 31, 2024
526e918
pkg_resources used as backup of importlib
hadrilec Dec 31, 2024
f2de775
hiddenprints located in separate file and reused across the board
hadrilec Jan 1, 2025
831a695
sirene_key could be in upper case whenever the code is run on GitHub
hadrilec Jan 1, 2025
202e9c1
SIRENE_KEY secret env var should be explicitly passed on to the py en…
hadrilec Jan 1, 2025
13e18b7
improved tests for download module
hadrilec Jan 1, 2025
539e441
doc update + cleaning
hadrilec Jan 1, 2025
5859550
try catch remove for better debugging of download module
hadrilec Jan 1, 2025
00f5a35
requests should be installed with security mode to try to avoid conne…
hadrilec Jan 1, 2025
3033ab5
tentative to stabilise the request connection with a dedicated sessio…
hadrilec Jan 1, 2025
180d1b3
bugfix in get_file_list from download module + readme cleaning
hadrilec Jan 2, 2025
8649cbd
Merge branch 'catalog' of https://github.com/InseeFrLab/pynsee into c…
hadrilec Jan 2, 2025
57a2270
function to get a list of files from melodi catalog
hadrilec Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:

- name: Test all examples
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pip install jupytext
pip install .[full]
Expand All @@ -48,8 +47,7 @@ jobs:

- name: Test idbank list download
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pip install .
python -c "from pynsee.macrodata._dwn_idbank_files import _dwn_idbank_files;_dwn_idbank_files()"
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pkgTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -22,7 +22,7 @@ jobs:
run: |
#sudo apt-get install libgeos-dev
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov geopandas nbconvert matplotlib descartes
pip install flake8 pytest pytest-cov geopandas nbconvert matplotlib descartes parameterized
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-extra.txt ]; then pip install -r requirements-extra.txt; fi
- name: Lint with flake8
Expand All @@ -33,8 +33,7 @@ jobs:
flake8 . --count --ignore=E722,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test examples
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pip install jupytext
pip install -r requirements.txt
Expand All @@ -48,8 +47,7 @@ jobs:
cd ../..
- name: Test with pytest
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pytest -v --cov
- name: "Upload coverage to Codecov"
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pkgTests_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -24,7 +24,7 @@ jobs:
run: |
#sudo apt-get install libgeos-dev
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov geopandas nbconvert matplotlib descartes
pip install flake8 pytest pytest-cov geopandas nbconvert matplotlib descartes parameterized
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-extra.txt ]; then pip install -r requirements-extra.txt; fi
- name: Lint with flake8
Expand All @@ -35,8 +35,7 @@ jobs:
flake8 . --count --ignore=E722,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test examples
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pip install jupytext
pip install -r requirements.txt
Expand All @@ -50,8 +49,7 @@ jobs:
cd ../..
- name: Test with pytest
env:
insee_key: ${{ secrets.INSEE_KEY }}
insee_secret: ${{ secrets.INSEE_SECRET }}
sirene_key: ${{ secrets.SIRENE_KEY }}
run: |
pytest -v --cov
- name: "Upload coverage to Codecov"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
os: [ubuntu-20.04]
#[ubuntu-20.04, windows-2019, macOS-10.15]
python-version: ["3.8"]
python-version: ["3.12"]
#["3.7", "3.8", "3.9", "3.10"]

steps:
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

# pynsee 0.1.9
* new API portal: portail-api.insee.fr
* no token generation is needed anymore, only a key is needed to use SIRENE API
* backend function update in the utils module + sirene functions update
* subsequent doc and test update

# pynsee 0.1.8

* sirene module compatible with SIRENE API v3.11
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
a dozen datasets of local data, numerous sources available on [insee.fr](https://www.insee.fr),
geographical limits of administrative areas taken from IGN
as well as key metadata and SIRENE database containing data on all French companies.
Have a look at the detailed API page [api.insee.fr](https://api.insee.fr/catalogue/).
Have a look at the detailed API page [portail-api.insee.fr](https://portail-api.insee.fr/).

This package is a contribution to reproducible research and public data transparency.
It benefits from the developments made by teams working on APIs at INSEE and IGN.

## Installation & API subscription

The files available on [insee.fr](https://www.insee.fr) and IGN data, i.e. the use of `download` and `geodata` modules, do not require authentication.
Credentials are necessary to access some of the INSEE APIs available through `pynsee` by the modules `macrodata`, `localdata`, `metadata` and `sirene`.
API credentials can be created here : [api.insee.fr](https://api.insee.fr/catalogue/)
Credentials are necessary to access SIRENE API available through `pynsee` by the module `sirene`. API credentials can be created here : [portail-api.insee.fr](https://portail-api.insee.fr/). All other modules are freely accessible.

```python

Expand All @@ -34,10 +32,10 @@ pip install pynsee[full]
# cd pynsee
# pip install .[full]

# Subscribe to api.insee.fr and get your credentials!
# Subscribe to portail-api.insee.fr and get your credentials!
# Save your credentials with init_conn function :
from pynsee.utils.init_conn import init_conn
init_conn(insee_key="my_insee_key", insee_secret="my_insee_secret")
init_conn(sirene_key="my_sirene_key")

# Beware : any change to the keys should be tested after having cleared the cache
# Please do : from pynsee.utils import clear_all_cache; clear_all_cache()
Expand All @@ -61,7 +59,7 @@ For further advice, have a look at the documentation and gallery of the [example
## Example - Population Map

<h1 align="center">
<img src="https://raw.githubusercontent.com/InseeFrLab/pynsee/master/docs/_static/popfrance.png?token=AP32AXOVNXK5LWKM4OJ5THDAZRHZK">
<img src="https://raw.githubusercontent.com/InseeFrLab/pynsee/master/docs/_static/popfrance.png">
</h1>

```python
Expand Down Expand Up @@ -145,8 +143,7 @@ fig.savefig('pop_france.svg',

# Use the proxy_server argument of the init_conn function to change the proxy server address
from pynsee.utils.init_conn import init_conn
init_conn(insee_key="my_insee_key",
insee_secret="my_insee_secret",
init_conn(sirene_key="my_sirene_key",
http_proxy="http://my_proxy_server:port",
https_proxy="http://my_proxy_server:port")

Expand All @@ -156,8 +153,7 @@ init_conn(insee_key="my_insee_key",
# Alternativety you can use directly environment variables as follows.
# Beware not to commit your credentials!
import os
os.environ['insee_key'] = 'my_insee_key'
os.environ['insee_secret'] = 'my_insee_secret'
os.environ['sirene_key'] = 'my_sirene_key'
os.environ['http_proxy'] = "http://my_proxy_server:port"
os.environ['https_proxy'] = "http://my_proxy_server:port"

Expand Down
6 changes: 3 additions & 3 deletions docs/api_subscription.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.. role:: raw-html(raw)
:format: html

Have a look at the official tutorial on `api.insee.fr <https://api.insee.fr/catalogue/site/themes/wso2/subthemes/insee/pages/help.jag>`_
Have a look at the official tutorial on `portail-api.insee.fr <https://api.insee.fr/catalogue/site/themes/wso2/subthemes/insee/pages/help.jag>`_


API Subscription Tutorial
=========================

#. Create an account on api.insee.fr
#. Create an account on portail-api.insee.fr

#. Create an application

Expand Down Expand Up @@ -52,7 +52,7 @@ API Subscription Tutorial
# Subscribe to api.insee.fr and get your credentials!
# Save your credentials with init_conn function :
from pynsee.utils.init_conn import init_conn
init_conn(insee_key="my_insee_key", insee_secret="my_insee_secret")
init_conn(sirene_key="my_sirene_key")

# Beware : any change to the keys should be tested after having cleared the cache
# Please do : from pynsee.utils import clear_all_cache; clear_all_cache()
46 changes: 22 additions & 24 deletions docs/examples/example_cadre_iris_idf.ipynb

Large diffs are not rendered by default.

153 changes: 54 additions & 99 deletions docs/examples/example_deaths_births.ipynb

Large diffs are not rendered by default.

Loading
Loading