Skip to content

Commit 276390d

Browse files
committed
optional decompression
1 parent 3e0efad commit 276390d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pangolin/command.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main(sysargs = sys.argv[1:]):
3636
parser.add_argument('-n', '--dry-run', action='store_true',help="Go through the motions but don't actually run")
3737
parser.add_argument('--tempdir',action="store",help="Specify where you want the temp stuff to go. Default: $TMPDIR")
3838
parser.add_argument("--no-temp",action="store_true",help="Output all intermediate files, for dev purposes.")
39-
parser.add_argument('--temp-decompress',action="store_true",dest="temp_decompress",help="Don't try to permanently decompress the model file.")
39+
parser.add_argument('--decompress-model',action="store_true",dest="decompress",help="Permanently decompress the model file to save time running pangolin.")
4040
parser.add_argument('--max-ambig', action="store", default=0.5, type=float,help="Maximum proportion of Ns allowed for pangolin to attempt assignment. Default: 0.5",dest="maxambig")
4141
parser.add_argument('--min-length', action="store", default=10000, type=int,help="Minimum query length allowed for pangolin to attempt assignment. Default: 10000",dest="minlen")
4242
parser.add_argument('--panGUIlin', action='store_true',help="Run web-app version of pangolin",dest="panGUIlin")
@@ -247,14 +247,24 @@ def main(sysargs = sys.argv[1:]):
247247
print("""Check your environment, didn't find appropriate files from the pangoLEARN repo.\n Trained model must be installed, please see https://cov-lineages.org/pangolin.html for installation instructions.""")
248248
exit(1)
249249
else:
250-
if not args.temp_decompress:
250+
if args.decompress:
251251
if "compressed_model_size" in config:
252252
if os.path.getsize(trained_model) <= config["compressed_model_size"] + 10:
253253
print("Decompressing model and header files")
254254
model = joblib.load(trained_model)
255255
joblib.dump(model, trained_model, compress=0)
256256
headers = joblib.load(header_file)
257257
joblib.dump(headers, header_file, compress=0)
258+
else:
259+
print(f'Error: model file already decompressed. Exiting\n')
260+
sys.exit(-1)
261+
262+
if os.path.getsize(trained_model) >= config["compressed_model_size"] + 10:
263+
print(f'Success! Decompressed the model file. Exiting\n')
264+
sys.exit(0)
265+
else:
266+
print(f'Error: failed to decompress model. Exiting\n')
267+
sys.exit(-1)
258268

259269
print("\nData files found")
260270
print(f"Trained model:\t{trained_model}")

0 commit comments

Comments
 (0)