Skip to content

Commit

Permalink
it's like beating my head against the wall
Browse files Browse the repository at this point in the history
  • Loading branch information
rknop committed Jul 30, 2024
1 parent 2ef5c18 commit 4479b77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 64 deletions.
25 changes: 5 additions & 20 deletions tests/fixtures/decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,8 @@ def decam_datastore(
ImageAligner.cleanup_temp_images()

# Clean up the provenance tag potentially created by the pipeline
tag = p.pars.provenance_tag
with SmartSession() as sess:
tag = 'decam_datastore'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
with SmartSession() as session:
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'decam_datastore' } )
session.commit()


Expand Down Expand Up @@ -467,9 +462,6 @@ def decam_elais_e1_two_refs_datastore( code_version, download_url, decam_cache_d
with SmartSession() as session:
for tag in [ 'decam_elais_e1_two_refs_datastore',
'decam_elais_e1_two_refs_datastore_datastore_factory' ]:
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.commit()

Expand Down Expand Up @@ -522,11 +514,8 @@ def decam_elais_e1_two_references( decam_elais_e1_two_refs_datastore, refmaker_f

# clean out the provenance tag that may have been created by the refmaker_factory
with SmartSession() as session:
tag = 'decam_elais_e1_two_references'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ),
{'tag': 'decam_elais_e1_two_references' } )
session.commit()


Expand Down Expand Up @@ -561,11 +550,7 @@ def decam_refset(refmaker_factory):

# Clean out the provenance tag that may have been created by the refmaker_factory
with SmartSession() as session:
tag = 'decam_refset'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'decam_refset' } )
session.commit()

@pytest.fixture
Expand Down
9 changes: 2 additions & 7 deletions tests/fixtures/pipeline_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,8 @@ def pipeline_for_tests(pipeline_factory):
yield p

# Clean up the provenance tag potentially created by the pipeline
tag = p.pars.provenance_tag
with SmartSession() as sess:
tag = 'pipeline_for_tests'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
with SmartSession() as session:
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'pipeline_for_tests' } )
session.commit()


Expand Down
42 changes: 5 additions & 37 deletions tests/fixtures/ptf.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@ def ptf_datastore(datastore_factory, ptf_exposure, ptf_ref, ptf_cache_dir, ptf_b

# Clean out the provenance tag that may have been created by the datastore_factory
with SmartSession() as session:
tag = 'ptf_datastore'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'ptf_datastore' } )
session.commit()


Expand Down Expand Up @@ -325,11 +321,7 @@ def ptf_reference_images(ptf_images_factory):

# Clean out the provenance tag that may have been created by the datastore_factory
with SmartSession() as session:
tag = 'ptf_reference_images'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'ptf_reference_images' } )
session.commit()


Expand All @@ -352,11 +344,7 @@ def ptf_supernova_images(ptf_images_factory):

# Clean out the provenance tag that may have been created by the datastore_factory
with SmartSession() as session:
tag = 'ptf_supernova_images'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'ptf_supernova_images' } )
session.commit()

# conditionally call the ptf_reference_images fixture if cache is not there:
Expand Down Expand Up @@ -468,18 +456,6 @@ def ptf_aligned_images(request, ptf_cache_dir, data_dir, code_version):
# for image in ptf_reference_images:
# image.exposure.delete_from_disk_and_database( commit=True, remove_downstreams=True )

# ROB REMOVE THIS COMMENT
# with SmartSession() as session, warnings.catch_warnings():
# warnings.filterwarnings(
# action='ignore',
# message=r'.*DELETE statement on table .* expected to delete \d* row\(s\).*',
# )
# for image in ptf_reference_images:
# image = merge( session, image )
# image.exposure.delete_from_disk_and_database(commit=False, session=session, remove_downstreams=True)
# # image.delete_from_disk_and_database(commit=False, session=session, remove_downstreams=True)
# session.commit()


@pytest.fixture
def ptf_ref(
Expand Down Expand Up @@ -613,11 +589,7 @@ def ptf_ref(

# Clean out the provenance tag that may have been created by the refmaker_factory
with SmartSession() as session:
tag = 'ptf_ref'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'ptf_ref' } )
session.commit()

@pytest.fixture
Expand Down Expand Up @@ -674,11 +646,7 @@ def ptf_refset(refmaker_factory):

# Clean out the provenance tag that may have been created by the refmaker_factory
with SmartSession() as session:
tag = 'ptf_refset'
# session.execute( sa.text( "DELETE FROM provenances WHERE id IN "
# "( SELECT provenance_id FROM provenance_tags WHERE tag=:tag )" ),
# { 'tag': tag } );
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': tag } )
session.execute( sa.text( "DELETE FROM provenance_tags WHERE tag=:tag" ), {'tag': 'ptf_refset' } )
session.commit()


Expand Down

0 comments on commit 4479b77

Please sign in to comment.