def add_shape(name: str) -> bool: """Ingest the row information for an approved shapeset. """ logger.info('Begin. (name: "{}")'.format(name)) meta = get_meta(name) logger.debug('Add the shape table.') ShapeETL(meta).add() logger.info('End.') return True
def update_shape(name: str) -> bool: """Update the row information for an approved shapeset. """ logger.info('Begin. (name: "{}")'.format(name)) meta = get_meta(name) logger.debug('Update the shape table.') ShapeETL(meta).update() logger.info('End.') return True
def ingest_fixture(fixture): # Add the fixture to the metadata first shape_meta = ShapeMetadata.add(human_name=fixture.human_name, source_url=None, update_freq=fixture.update_freq, approved_status=False) session.commit() # Bypass the celery task and call on a ShapeETL directly ShapeETL(meta=shape_meta, source_path=fixture.path).add() return shape_meta
def update_shape(self, table_name): # Associate the dataset with this celery task # so we can check on the task's status meta = session.query(ShapeMetadata).get(table_name) meta.celery_task_id = self.request.id session.commit() # Update the shapefile ShapeETL(meta=meta).update() return 'Finished updating shape dataset {} from {}.'.\ format(meta.dataset_name, meta.source_url)
def test_update(self): # Try to ingest slightly changed shape fixture = fixtures['changed_neighborhoods'] # Add the fixture to the registry first shape_meta = session.query(ShapeMetadata).get('chicago_neighborhoods') # Do a ShapeETL update ShapeETL(meta=shape_meta, source_path=fixture.path).update() t = shape_meta.shape_table sel = t.select().where(t.c['sec_neigh'] == 'ENGLEWOOD') res = engine.execute(sel).fetchall() altered_value = res[0]['pri_neigh'] # I changed Englewood to Englerwood :P self.assertEqual(altered_value, 'Englerwood')