worker: skip incomplete TESS sectors, free disk while packing
Browse files
tools/colab_scidata_worker.py
CHANGED
|
@@ -175,7 +175,11 @@ def tess(first=1, last=200):
|
|
| 175 |
fn = t[t.index("-o") + 1]
|
| 176 |
if re.fullmatch(r"[\w.-]+\.fits", fn):
|
| 177 |
pairs.append((fn, t[-1]))
|
| 178 |
-
fetch_all(pairs, d)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
files = sorted(p for p in d.iterdir() if p.suffix == ".fits")
|
| 180 |
k, cur, tf, rows = 0, 0, None, []
|
| 181 |
for p in files:
|
|
@@ -186,8 +190,10 @@ def tess(first=1, last=200):
|
|
| 186 |
k += 1
|
| 187 |
nm = p.name
|
| 188 |
tf.add(p, arcname=f"sector_{s:04d}/{nm}")
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
| 191 |
if tf:
|
| 192 |
tf.close()
|
| 193 |
shutil.rmtree(d)
|
|
|
|
| 175 |
fn = t[t.index("-o") + 1]
|
| 176 |
if re.fullmatch(r"[\w.-]+\.fits", fn):
|
| 177 |
pairs.append((fn, t[-1]))
|
| 178 |
+
ok = fetch_all(pairs, d)
|
| 179 |
+
if ok < 0.98 * len(pairs): # incomplete sector: never publish a manifest that marks it done
|
| 180 |
+
say("tess sector", s, "INCOMPLETE", ok, "of", len(pairs), "- skipped, will retry on the next run")
|
| 181 |
+
shutil.rmtree(d, ignore_errors=True)
|
| 182 |
+
continue
|
| 183 |
files = sorted(p for p in d.iterdir() if p.suffix == ".fits")
|
| 184 |
k, cur, tf, rows = 0, 0, None, []
|
| 185 |
for p in files:
|
|
|
|
| 190 |
k += 1
|
| 191 |
nm = p.name
|
| 192 |
tf.add(p, arcname=f"sector_{s:04d}/{nm}")
|
| 193 |
+
sz = p.stat().st_size
|
| 194 |
+
cur += sz
|
| 195 |
+
rows.append({"file": nm, "bytes": sz, "shard": f"s{s:04d}_part_{k - 1:03d}.tar"})
|
| 196 |
+
p.unlink() # keep the disk peak at one copy of the sector
|
| 197 |
if tf:
|
| 198 |
tf.close()
|
| 199 |
shutil.rmtree(d)
|