Commit 212b25cf authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

include csv in package

parent b6484603
include rules/gem_occupancy/data/*.csv
include LICENSE
......@@ -24,7 +24,7 @@ import argparse
from rabotnik import Rabotnik, Assembly
from rabotnik.bus import MessageBus
from rabotnikobm.rules.gem_occupancy.mapping import OccupancyMapper
from rabotnikobm.rules.gem_occupancy.get_building_occupancy import GetBuildingOccupancy
from .rules import GetBuilding
from .rules import GetFloorspace
......@@ -62,15 +62,10 @@ async def start_rabotnik_obm(message_bus):
await message_bus.subscribe("building", rules.run)
async def start_rabotnik_gem_occupancy(
message_bus, storage_consumer, storage_contributor, n_processes_max
):
fn_mapping = "building_and_PoIs_tags.csv"
occupancy_mapper = OccupancyMapper.from_csv(fn=fn_mapping)
async def start_rabotnik_gem_occupancy(message_bus, storage_consumer, _, n_processes_max):
rules = [
GetBuildingOccupancy(storage_consumer, occupancy_mapper=occupancy_mapper),
GetBuildingOccupancy(storage_consumer),
]
rules = Assembly(rules=rules, n_processes_max=n_processes_max)
......@@ -82,9 +77,13 @@ async def start_rabotnik(args):
message_bus = await connected_message_bus(args.config_message_bus)
# await start_rabotnik_obm(
# message_bus, storage_consumer, storage_contributor, args.n_processes_max
# )
rabotnik_args = (message_bus, storage_consumer, storage_contributor, args.n_processes_max)
if args.target in ("all", "obm"):
asyncio.create_task(start_rabotnik_obm(*rabotnik_args))
if args.target in ("all", "gem"):
asyncio.create_task(start_rabotnik_gem_occupancy(*rabotnik_args))
def main():
......@@ -108,6 +107,15 @@ def main():
"--start-celery-worker",
action="store_true",
)
parser.add_argument(
"-t",
"--target",
default="all",
type=str,
help="Process to start (defaults to 'all')",
)
args = parser.parse_args()
default_log_level = logging.WARNING
......
......@@ -109,12 +109,12 @@ class RulesOneUniqueSubGroup:
class GetBuildingOccupancy(Rule):
"""A rule to map OSM tags to building occupancies."""
def __init__(self, storage: StorageBase, occupancy_mapper: OccupancyMapper):
def __init__(self, storage: StorageBase):
self.storage = storage
self.mappers = [
occupancy_mapper.landuse_mapper(),
occupancy_mapper.building_poi_mapper(),
OccupancyMapper.landuse_mapper(),
OccupancyMapper.building_poi_mapper(),
]
self.candidates = [
......@@ -130,14 +130,15 @@ class GetBuildingOccupancy(Rule):
f"SELECT tags FROM osm_building_relations WHERE osm_id={building_id} AND index=0"
)
# Mapping to GEM taxonomies
# Mapping to GEM taxonomy strings
occupancies = []
for mapper in self.mappers:
occupancies.extend(mapper.apply(tags))
# Convert derived occupancies to GEMTags
occupancies = TagStatistics.from_strings(occupancies)
# Apply rules to find ultimate taxonomy
# Apply rules to find final taxonomy
occupancy = apply_rules(self.candidates, occupancies)
logger.debug("occupancies %s: %s", building_id, occupancy)
......
......@@ -33,7 +33,8 @@ setup(
"tests": tests_require,
"linters": linters_require,
},
packages=find_packages(),
entry_points={"console_scripts": ["rabotnikobm = rabotnikobm.instance:main"]},
python_requires=">=3.6",
packages=find_packages(),
include_package_data=True,
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment