Skip to content

Commit

Permalink
tweak cache removal in purge_tn
Browse files Browse the repository at this point in the history
  • Loading branch information
akremin committed Dec 4, 2024
1 parent 1f01fc6 commit ced6029
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions py/desispec/scripts/purge_tilenight.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def purge_tilenight(tiles, night, dry_run=True):
future_cumulatives[thrunight_int] = [tile]

## Finally, remove any dashboard caches for the impacted nights
allnights = sorted([night] + list(future_cumulatives.keys()))
for dashnight in allnights:
for cachefiletype in ['expinfo', 'zinfo']:
dashcache = findfile(cachefiletype, night=dashnight)
futurenights = sorted(list(future_cumulatives.keys()))
## Remove expinfo and zinfo for the present night
for cachefiletype in ['expinfo', 'zinfo']:
dashcache = findfile(cachefiletype, night=night)
if os.path.exists(dashcache):
if dry_run:
print(f"Dry_run set, so not removing {dashcache}.")
Expand All @@ -139,9 +139,20 @@ def purge_tilenight(tiles, night, dry_run=True):
os.remove(dashcache)
else:
print(f"Couldn't find {cachefiletype} file: {dashcache}")
## Remove just zinfo for futurenights since we only purge cumulative zs
for dashnight in futurenights:
dashcache = findfile('zinfo', night=dashnight)
if os.path.exists(dashcache):
if dry_run:
print(f"Dry_run set, so not removing {dashcache}.")
else:
print(f"Removing: {dashcache}.")
os.remove(dashcache)
else:
print(f"Couldn't find {cachefiletype} file: {dashcache}")

## Load old processing table
timestamp = time.strftime('%Y%m%d_%Hh%Mm')
timestamp = time.strftime('%Y%m%d_%Hh%Mm%Ss')
ppathname = findfile('processing_table', night=night)
ptable = load_table(tablename=ppathname, tabletype='proctable')

Expand All @@ -167,7 +178,7 @@ def purge_tilenight(tiles, night, dry_run=True):
ptable = load_table(tablename=ppathname, tabletype='proctable')

## Now let's remove the tiles from the processing table
nokeep = ptable['JOBNAME'] == 'cumulative'
nokeep = ptable['JOBDESC'] == 'cumulative'
nokeep &= np.isin(ptable['TILEID'], futuretiles)
keep = np.bitwise_not(nokeep)
print(f'Removing {len(keep) - np.sum(keep)}/{len(keep)} processing '
Expand All @@ -182,4 +193,4 @@ def purge_tilenight(tiles, night, dry_run=True):
## move old processing table out of the way
os.rename(ppathname, ppathname.replace('.csv', f".csv.{timestamp}"))
## save new trimmed processing table
write_table(ptable, tablename=ppathname)
write_table(ptable, tablename=ppathname)

0 comments on commit ced6029

Please sign in to comment.