Skip to content

Commit

Permalink
Pass by pickle for spin up
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-chamberlain committed Dec 14, 2023
1 parent 538ec99 commit 7d11740
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion rt_eqcorrscan/reactor/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import signal
import subprocess
import platform
import pickle

from copy import deepcopy
from typing import Callable, Union, List
Expand Down Expand Up @@ -349,7 +350,9 @@ def spin_up(self, triggering_event: Event) -> None:
return
working_dir = _get_triggered_working_dir(
triggering_event_id, exist_ok=True)
tribe.write(os.path.join(working_dir, "tribe.tgz"))
with open(os.path.join(working_dir, "tribe.pkl"), "wb") as f:
pickle.dump(tribe, f)
# tribe.write(os.path.join(working_dir, "tribe.tgz"))
self.config.write(
os.path.join(working_dir, 'rt_eqcorrscan_config.yml'))
triggering_event.write(
Expand Down
7 changes: 4 additions & 3 deletions rt_eqcorrscan/reactor/spin_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
import logging
import pickle

from collections import Counter
from typing import List, Union
Expand All @@ -14,8 +15,6 @@
from obspy.clients.fdsn.client import FDSNNoDataException
from obspy.geodetics import locations2degrees, kilometer2degrees

from obsplus import WaveBank

from eqcorrscan import Tribe

from rt_eqcorrscan import read_config, RealTimeTribe
Expand Down Expand Up @@ -54,7 +53,9 @@ def run(
Logger.debug(f"Triggered by {triggering_event}")
min_stations = config.rt_match_filter.get("min_stations", None)
Logger.info("Reading the Tribe")
tribe = Tribe().read("tribe.tgz")
with open("tribe.pkl", "rb") as f:
tribe = pickle.load(f)
# tribe = Tribe().read("tribe.tgz")
# Remove file to avoid re-reading it
os.remove("tribe.tgz")

Expand Down

0 comments on commit 7d11740

Please sign in to comment.