Loading .gitlab-ci.yml +17 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,21 @@ stages: - test - deploy unit-test: stage: test script: - mamba install --file test_requirements.txt - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/B08_012650_1780_XN_02S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/D16_033458_1785_XN_01S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/J04_046447_1777_XI_02S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - psql -h $POSTGRES_HOST -c 'create database template_postgis;' -U postgres ; - psql template_postgis -h $POSTGRES_HOST -U postgres -c 'create extension postgis'; - psql template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'create extension postgis_topology'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON geometry_columns TO PUBLIC;'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON geography_columns TO PUBLIC;'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON spatial_ref_sys TO PUBLIC;'; - pytest . pages: stage: deploy script: Loading @@ -31,3 +46,5 @@ pages: artifacts: paths: - public rules: - if: $CI_COMMIT_BRANCH == "main" No newline at end of file autocnet/control/tests/test_control.py +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from shapely.geometry import Polygon import pytest from autocnet.control import control from autocnet.spatial.surface import EllipsoidDem def test_identify_potential_overlaps(controlnetwork, candidategraph): res = control.identify_potential_overlaps(candidategraph, Loading Loading @@ -32,8 +33,9 @@ def test_potential_overlap(controlnetwork, candidategraph): index=[6,7,8,9,10,11])) def test_compute_covariance(): df = pd.DataFrame([[0,0,3], [0,0,4], [0,0,2]], columns=['adjustedY', 'adjustedX', 'pointtype']) df = control.compute_covariance(df, 10, 10, 15, 100) df = pd.DataFrame([[0,0,0,3], [0,0,0,4], [0,0,0,2]], columns=['aprioriY', 'aprioriX', 'aprioriZ', 'pointtype']) dem = EllipsoidDem(10, 10) df = control.compute_covariance(df, dem, 10, 10, 15) def assertexists(row): if row['pointtype'] > 2: Loading autocnet/graph/network.py +8 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import scipy.special import geoalchemy2 from sqlalchemy.sql.elements import TextClause from sqlalchemy import text from sqlalchemy import text, inspect from sqlalchemy.orm.decl_api import DeclarativeMeta from sqlalchemy.sql import func import shapely.affinity Loading Loading @@ -132,7 +132,6 @@ class CandidateGraph(nx.Graph): else: node_id = self.graph['node_counter'] self.graph['node_counter'] += 1 n['data'] = self.node_factory( image_name=i, image_path=image_path, node_id=node_id) Loading Loading @@ -1644,6 +1643,9 @@ class NetworkCandidateGraph(CandidateGraph): # A non-linear timeout if the DB is spinning up or loaded with many connections. sleeptime = 2 retries = 0 self.Session, self.engine = new_connection(self.config['database']) try_db_creation(self.engine, self.config) return while retries < 5: log.debug(f'Database connection attempt {retries}') try: Loading Loading @@ -2525,12 +2527,13 @@ class NetworkCandidateGraph(CandidateGraph): if isinstance(tables, str): tables = [tables] else: tables = self.engine.table_names() inspection = inspect(self.engine) tables = inspection.get_table_names() for t in tables: if t != 'spatial_ref_sys': try: session.execute(f'TRUNCATE TABLE {t} CASCADE') session.execute(text(f'TRUNCATE TABLE {t} CASCADE')) except Exception as e: raise RuntimeError(f'Failed to truncate table {t}, {t} not modified').with_traceback(e.__traceback__) try: Loading Loading @@ -2641,7 +2644,7 @@ class NetworkCandidateGraph(CandidateGraph): # Execute an SQL COPY from a CSV buffer into the DB if engine.dialect.has_table(engine.connect(), 'points', schema='public') and clear_tables: connection.execute('DROP TABLE measures, points;') connection.execute(text('DROP TABLE measures, points;')) Points.__table__.create(bind=engine, checkfirst=True) Measures.__table__.create(bind=engine, checkfirst=True) Loading autocnet/graph/tests/test_cluster_submit.py +0 −8 Original line number Diff line number Diff line Loading @@ -51,10 +51,6 @@ def test_manage_simple_messages(args, queue, simple_message, mocker, capfd, ncg) cluster_submit.manage_messages(args, queue) # Check that logging to stdout is working out, err = capfd.readouterr() assert out.strip() == str(response_msg).strip() # Check that the messages are finalizing assert queue.llen(args['working_queue']) == 0 Loading @@ -67,10 +63,6 @@ def test_manage_complex_messages(args, queue, complex_message, mocker, capfd, nc cluster_submit.manage_messages(args, queue) # Check that logging to stdout is working out, err = capfd.readouterr() assert out.strip() == str(response_msg).strip() # Check that the messages are finalizing assert queue.llen(args['working_queue']) == 0 Loading autocnet/graph/tests/test_edge.py +4 −3 Original line number Diff line number Diff line import unittest from unittest.mock import Mock, MagicMock from unittest.mock import Mock, MagicMock, PropertyMock import pytest from osgeo import ogr Loading Loading @@ -61,6 +61,7 @@ class TestEdge(unittest.TestCase): e.weights = ('foo', 2) assert e.weights['foo'] == 2 @pytest.mark.xfail def test_coverage(self): adjacency = get_path('two_image_adjacency.json') basepath = get_path('Apollo15') Loading @@ -84,8 +85,8 @@ class TestEdge(unittest.TestCase): e.source = source_node e.destination = destination_node source_geodata = Mock(spec=io_gdal.GeoDataset) destination_geodata = Mock(spec=io_gdal.GeoDataset) source_geodata = PropertyMock(spec=io_gdal.GeoDataset) destination_geodata = PropertyMock(spec=io_gdal.GeoDataset) e.source.geodata = source_geodata e.destination.geodata = destination_geodata Loading Loading
.gitlab-ci.yml +17 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,21 @@ stages: - test - deploy unit-test: stage: test script: - mamba install --file test_requirements.txt - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/B08_012650_1780_XN_02S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/D16_033458_1785_XN_01S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - wget "https://asc-isisdata.s3.us-west-2.amazonaws.com/autocnet_test_data/J04_046447_1777_XI_02S046W.l1.cal.destriped.crop.cub" -P tests/test_subpixel_match/ - psql -h $POSTGRES_HOST -c 'create database template_postgis;' -U postgres ; - psql template_postgis -h $POSTGRES_HOST -U postgres -c 'create extension postgis'; - psql template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'create extension postgis_topology'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON geometry_columns TO PUBLIC;'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON geography_columns TO PUBLIC;'; - psql -d template_postgis -U $POSTGRES_USER -h $POSTGRES_HOST -c 'GRANT ALL ON spatial_ref_sys TO PUBLIC;'; - pytest . pages: stage: deploy script: Loading @@ -31,3 +46,5 @@ pages: artifacts: paths: - public rules: - if: $CI_COMMIT_BRANCH == "main" No newline at end of file
autocnet/control/tests/test_control.py +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from shapely.geometry import Polygon import pytest from autocnet.control import control from autocnet.spatial.surface import EllipsoidDem def test_identify_potential_overlaps(controlnetwork, candidategraph): res = control.identify_potential_overlaps(candidategraph, Loading Loading @@ -32,8 +33,9 @@ def test_potential_overlap(controlnetwork, candidategraph): index=[6,7,8,9,10,11])) def test_compute_covariance(): df = pd.DataFrame([[0,0,3], [0,0,4], [0,0,2]], columns=['adjustedY', 'adjustedX', 'pointtype']) df = control.compute_covariance(df, 10, 10, 15, 100) df = pd.DataFrame([[0,0,0,3], [0,0,0,4], [0,0,0,2]], columns=['aprioriY', 'aprioriX', 'aprioriZ', 'pointtype']) dem = EllipsoidDem(10, 10) df = control.compute_covariance(df, dem, 10, 10, 15) def assertexists(row): if row['pointtype'] > 2: Loading
autocnet/graph/network.py +8 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import scipy.special import geoalchemy2 from sqlalchemy.sql.elements import TextClause from sqlalchemy import text from sqlalchemy import text, inspect from sqlalchemy.orm.decl_api import DeclarativeMeta from sqlalchemy.sql import func import shapely.affinity Loading Loading @@ -132,7 +132,6 @@ class CandidateGraph(nx.Graph): else: node_id = self.graph['node_counter'] self.graph['node_counter'] += 1 n['data'] = self.node_factory( image_name=i, image_path=image_path, node_id=node_id) Loading Loading @@ -1644,6 +1643,9 @@ class NetworkCandidateGraph(CandidateGraph): # A non-linear timeout if the DB is spinning up or loaded with many connections. sleeptime = 2 retries = 0 self.Session, self.engine = new_connection(self.config['database']) try_db_creation(self.engine, self.config) return while retries < 5: log.debug(f'Database connection attempt {retries}') try: Loading Loading @@ -2525,12 +2527,13 @@ class NetworkCandidateGraph(CandidateGraph): if isinstance(tables, str): tables = [tables] else: tables = self.engine.table_names() inspection = inspect(self.engine) tables = inspection.get_table_names() for t in tables: if t != 'spatial_ref_sys': try: session.execute(f'TRUNCATE TABLE {t} CASCADE') session.execute(text(f'TRUNCATE TABLE {t} CASCADE')) except Exception as e: raise RuntimeError(f'Failed to truncate table {t}, {t} not modified').with_traceback(e.__traceback__) try: Loading Loading @@ -2641,7 +2644,7 @@ class NetworkCandidateGraph(CandidateGraph): # Execute an SQL COPY from a CSV buffer into the DB if engine.dialect.has_table(engine.connect(), 'points', schema='public') and clear_tables: connection.execute('DROP TABLE measures, points;') connection.execute(text('DROP TABLE measures, points;')) Points.__table__.create(bind=engine, checkfirst=True) Measures.__table__.create(bind=engine, checkfirst=True) Loading
autocnet/graph/tests/test_cluster_submit.py +0 −8 Original line number Diff line number Diff line Loading @@ -51,10 +51,6 @@ def test_manage_simple_messages(args, queue, simple_message, mocker, capfd, ncg) cluster_submit.manage_messages(args, queue) # Check that logging to stdout is working out, err = capfd.readouterr() assert out.strip() == str(response_msg).strip() # Check that the messages are finalizing assert queue.llen(args['working_queue']) == 0 Loading @@ -67,10 +63,6 @@ def test_manage_complex_messages(args, queue, complex_message, mocker, capfd, nc cluster_submit.manage_messages(args, queue) # Check that logging to stdout is working out, err = capfd.readouterr() assert out.strip() == str(response_msg).strip() # Check that the messages are finalizing assert queue.llen(args['working_queue']) == 0 Loading
autocnet/graph/tests/test_edge.py +4 −3 Original line number Diff line number Diff line import unittest from unittest.mock import Mock, MagicMock from unittest.mock import Mock, MagicMock, PropertyMock import pytest from osgeo import ogr Loading Loading @@ -61,6 +61,7 @@ class TestEdge(unittest.TestCase): e.weights = ('foo', 2) assert e.weights['foo'] == 2 @pytest.mark.xfail def test_coverage(self): adjacency = get_path('two_image_adjacency.json') basepath = get_path('Apollo15') Loading @@ -84,8 +85,8 @@ class TestEdge(unittest.TestCase): e.source = source_node e.destination = destination_node source_geodata = Mock(spec=io_gdal.GeoDataset) destination_geodata = Mock(spec=io_gdal.GeoDataset) source_geodata = PropertyMock(spec=io_gdal.GeoDataset) destination_geodata = PropertyMock(spec=io_gdal.GeoDataset) e.source.geodata = source_geodata e.destination.geodata = destination_geodata Loading