Skip to content

Commit

Permalink
implemented subprocesses as functions of ghsci to provide more flexib…
Browse files Browse the repository at this point in the history
…ility for test running (ie. without having to run these as subprocesses, in case this helps address #340)
  • Loading branch information
carlhiggs committed Jul 4, 2023
1 parent b7e31be commit b7dbfc0
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
88 changes: 88 additions & 0 deletions process/subprocesses/ghsci.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,94 @@ def drop(self):

drop_resources(self)

def _create_database(self):
"""Create database for this study region."""
from _00_create_database import create_database

create_database(self.codename)
return f"Database {self.config['db']} created."

def _create_study_region(self):
"""Create study region boundaries for this study region."""
from _01_create_study_region import create_study_region

create_study_region(self.codename)
return 'Study region boundaries created.'

def _create_osm_resources(self):
"""Create OSM resources for this study region."""
from _02_create_osm_resources import create_osm_resources

create_osm_resources(self.codename)
return 'OSM resources created.'

def _create_network_resources(self):
"""Create network resources for this study region."""
from _03_create_network_resources import create_network_resources

create_network_resources(self.codename)
return 'Network resources created.'

def _create_population_grid(self):
"""Create population grid for this study region."""
from _04_create_population_grid import create_population_grid

create_population_grid(self.codename)
return 'Population grid created.'

def _create_destinations(self):
"""Compile destinations for this study region."""
from _05_compile_destinations import compile_destinations

compile_destinations(self.codename)
return 'Destinations compiled.'

def _create_open_space_areas(self):
"""Create open space areas for this study region."""
from _06_open_space_areas_setup import open_space_areas_setup

open_space_areas_setup(self.codename)
return 'Open space areas created.'

def _create_neighbourhoods(self):
"""Create neighbourhood relations between nodes for this study region."""
from _07_locate_origins_destinations import nearest_node_locations

nearest_node_locations(self.codename)
return 'Neighbourhoods created.'

def _create_destination_summary_tables(self):
"""Create destination summary tables for this study region."""
from _08_destination_summary import destination_summary

destination_summary(self.codename)
return 'Destination summary tables created.'

def _link_urban_covariates(self):
"""Link urban covariates to nodes for this study region."""
from _09_urban_covariates import link_urban_covariates

link_urban_covariates(self.codename)
return 'Urban covariates linked.'

def _gtfs_analysis(self):
from _10_gtfs_analysis import gtfs_analysis

gtfs_analysis(self.codename)
return 'GTFS analysis completed.'

def _neighbourhood_analysis(self):
from _11_neighbourhood_analysis import neighbourhood_analysis

neighbourhood_analysis(self.codename)
return 'Neighbourhood analysis completed.'

def _area_analysis(self):
from _12_aggregation import aggregate_study_region_indicators

aggregate_study_region_indicators(self.codename)
return 'Area analysis completed.'

def get_engine(self):
"""Given configuration details, create a database engine."""
engine = create_engine(
Expand Down
14 changes: 13 additions & 1 deletion process/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ def test_example_analysis(self):
"""Analyse example region."""
codename = 'example_ES_Las_Palmas_2023'
r = ghsci.Region(codename)
r.analysis()
r._create_database()
r._create_study_region()
r._create_osm_resources()
r._create_network_resources()
r._create_population_grid()
r._create_destinations()
r._create_open_space_areas()
r._create_neighbourhoods()
r._create_destination_summary_tables()
r._link_urban_covariates()
r._gtfs_analysis()
r._neighbourhood_analysis()
r._area_analysis()

def test_example_generate(self):
"""Generate resources for example region."""
Expand Down

0 comments on commit b7dbfc0

Please sign in to comment.