Skip to content

Commit

Permalink
Created testing option for match_parcels to avoid trying to save matc…
Browse files Browse the repository at this point in the history
…h report for CI
  • Loading branch information
mikejcorey committed Dec 20, 2023
1 parent 84a2906 commit d97c8f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions apps/parcel/management/commands/match_parcels.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def add_arguments(self, parser):
help='Name of Zooniverse workflow to process, e.g. "Ramsey County"')
parser.add_argument('-l', '--local', action='store_true',
help='Save to local CSV in "analysis" dir, rather than Django object/S3')
parser.add_argument('-t', '--test', action='store_true',
help="Don't save match report, this is only a test")

def match_parcel(self, parcel_lookup, target_obj, subject_obj):
''' Separate subject necessary because you also have to run this on the ExtraParcelCandidate objects and then link the result to its subject'''
Expand Down Expand Up @@ -88,7 +90,7 @@ def tag_matched_parcels(self, workflow):
# Now do ManualCovenant records
Parcel.objects.filter(workflow=workflow, manualcovenant__isnull=False).update(bool_covenant=True)

def write_match_report(self, workflow, bool_local=False):
def write_match_report(self, workflow, bool_local=False, bool_test=False):
fieldnames = ['join_string', 'match', 'subject_id',
'metadata', 'parcel_metadata', 'num_parcels']

Expand All @@ -112,7 +114,9 @@ def write_match_report(self, workflow, bool_local=False):

filename_tail = f'{workflow.slug}_match_report_{timestamp}.csv'

if bool_local:
if bool_test:
pass
elif bool_local:

outfile_path = os.path.join(
settings.BASE_DIR, 'data', 'analysis', filename_tail)
Expand Down Expand Up @@ -173,4 +177,5 @@ def handle(self, *args, **kwargs):
self.tag_matched_parcels(workflow)

bool_local = kwargs['local']
self.write_match_report(workflow, bool_local)
bool_test = kwargs['test']
self.write_match_report(workflow, bool_local, bool_test)
2 changes: 1 addition & 1 deletion apps/plat/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_subdivision_parcel_match(self):
with self.settings(ZOONIVERSE_QUESTION_LOOKUP=TEST_ZOON_SETTINGS):
call_command("rebuild_parcel_spatial_lookups", workflow='Ramsey County')
call_command("rebuild_covenant_spatial_lookups", workflow='Ramsey County')
call_command("match_parcels", workflow='Ramsey County')
call_command("match_parcels", '--test', workflow='Ramsey County')

parcels_to_match = Parcel.objects.filter(workflow=1, plat_name='LYNDALE BEACH 2ND ADDN')
parcels_count = parcels_to_match.count()
Expand Down

0 comments on commit d97c8f4

Please sign in to comment.