A project for handling the European Pollutant Release and Transfer Register (i.e. E-PRTR) data and publishing it as a national web service (API & user interface). The project is funded by the Ministry of the Environment and implemented by the Finnish Environment Institute.
The development version of the UI is published at syke-prtr-d-web.azurewebsites.net.
The development version of the API (serving only Finnish PRTR data) is published at syke-prtr-fastapi-d-cont.azurewebsites.net.
A prototype of the user interface (or portal) is published at prtr.fi.
This project was bootstrapped with Create React App. See the autogenerated documentation in the other README.md
$ cd ui
$ npm install
npm start
To open the interactive dashboard (Cypress) for running and debugging tests, run:
npm run cypress
By default the app uses the PRTR API at the address defined in .env.development. To use local backend instead, you can add a new file .env.development.local and add the same environment variable there as REACT_APP_PRTR_SERVER=http://localhost:8000
.
To disable query caching (with React Query) on local development, you can also add the environment variable REACT_APP_PRTR_DATA_CACHE_TIME=0
.
To keep the external translation source and the translation files of the project in sync, it is recommended to make the additions or edits first in the external translation source and only then update the project translation files as instructed below:
- Download and save the external translation table(s) as utf-8 encoded CSV file(s).
- In directory ui/translation_source, replace one or more of the current CSV files with (an) updated table(s).
- Check with git diff that the changes/additions seem as intended.
cd ui
(if not already there)python import_translations.py
(with any Python 3.x)- Check with git diff that the changes/additions to translation (JSON) files seem appropriate.
- Optional step: run
npm start
ornpm run build
to check that the project still compiles (if there were changes in the translation keys, there may be TS/compile errors now). - Commit & push the changes and enjoy your new localized content.
The project is currently formatted with Prettier. In VSCode, the easiest way to format is to use the plugin prettier-vscode and the following settings:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
Miniconda or Anaconda package manager for Python.
$ git clone https://github.com/sykefi/PRTR.git
$ cd PRTR/api
$ conda env create -f dev-env.yml
$ conda activate prtr
- E-PRTR data is available for download at industry.eea.europa.eu/download / eea.europa.eu/data-and-maps/data (e.g. Industrial_Reporting_Database_v4_March_2021.accdb)
- Previously imported PRTR dataset for Finland is already included as CSV files in api/api/assets
- The data import script requires installation of driver for MS for Access files
- Prior to running the script, add a new file .env to
api/data_import/
containing at least the following environment variable: PRTR_DB_FILE_PATH=path\to\your\prtr\data\*.accdb - Other settings (such as country code) can be adjusted in data_import/conf.py
To execute the data import, run:
$ python data_import_main.py
$ uvicorn main:app --reload
API should now be accessible at localhost:8000.
$ python -m pytest tests/
Changes for the air-pollutant-map (tab Hajapäästöt in the application) are made in the directory air-pollutant-map. Air-pollutant-map is originally implemented with Vue, therefore it's code is maintained separately from UI. Build of air-pollutant-map is placed inside the public-directory of UI so that the build runs on the same server as the main app. Running air-pollutant-map is embedded in to the UI with an iframe.
Whenever new changes are made to the air-pollutant-map, new build needs to be made and copied in ui/public/air-pollutant-map. Dev-environment of air-pollutant-map can be used in local testing, but prod-environment needs to be used when changes are published. More information about updating the changes in the other README.md