How to: run backend locally
This is if you'd like to replicate the pipeline action the_od_bods
repo on a local machine.
It will gather fresh data from API calls and web scrapers, process them, then write prepared listings to the local JKAN repo.
Prerequisites
To get started, you should have the following installed:
- Git
- Python 3.x
- Python Package Manager (Pip)
- Docker
Getting started
- Have
the_od_bods
andjkan
repos on local in the same directory- `git clone if it's the first time, or
git pull
to update repos - you must have the
jkan
repo in local, even if you don't intend to use it, or the pipeline action will fail.
- `git clone if it's the first time, or
- Run pipeline
- Run natively
- Set up or update Python environment
the_od_bods
repo runs exclusively in python- python packages needed are specified in
the_od_bods/requirements.txt
- you may use any environment manager of your choice: conda, venv, poetry or other.
- Run
run.sh
- In terminal, in
the_od_bods
execute the shell scriptsh run.sh
- Wait for confirmation message “Scraping complete”
- Whole action can take ~15 minutes to complete
- In terminal, in
- Run
merge_data.py
andexport2.jkan.py
- In terminal, in the
the_ods_bods
execute the shell scriptpython merge_data.py
- In terminal, in
the_od_bods
execute the shell scriptpython export2jkan.py
- In terminal, in the
- Set up or update Python environment
- Run using Docker
- Run image build
- In terminal, in
the_od_bods
execute the shell scriptdocker build -t open_data_scotland_pipeline .
- In terminal, in
- Run image in container
- In terminal, in
the_od_bods
execute the shell scriptdocker run -t --name ods_pipeline open_data_scotland_pipeline
- In terminal, in
- Extract container contents
- To delete previous files in the JKAN directory, in terminal, from
jkan
, execute the shell scriptrm -r _datasets/*
- In terminal, in
jkan
to copy the JKAN files, execute the shell scriptdocker cp ods_pipeline:./usr/src/app/jkan/_datasets/ ./_datasets
- In terminal, in
the_od_bods
to copy the pipeline files, execute the shell scriptdocker cp ods_pipeline:./usr/src/app/the_od_bods/ .
- To delete previous files in the JKAN directory, in terminal, from
- Run image build
- To see changes in frontend see How to: Run frontend locally
- Run natively