From 89064087acacb6953003ce2ecd01f96d70e54239 Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Sat, 2 May 2020 16:44:03 +0200
Subject: [PATCH] Used the ScoreWriter to do the score concatenation

---
 bob/bio/base/script/vanilla_biometrics.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/bob/bio/base/script/vanilla_biometrics.py b/bob/bio/base/script/vanilla_biometrics.py
index b5d76595..d6821620 100644
--- a/bob/bio/base/script/vanilla_biometrics.py
+++ b/bob/bio/base/script/vanilla_biometrics.py
@@ -158,7 +158,6 @@ def vanilla_biometrics(pipeline, database, dask_client, groups, output, **kwargs
         biometric_references = database.references(group=group)
 
         logger.info(f"Running vanilla biometrics for group {group}")
-
         allow_scoring_with_all_biometric_references = (
             database.allow_scoring_with_all_biometric_references
             if hasattr(database, "allow_scoring_with_all_biometric_references")
@@ -182,14 +181,15 @@ def vanilla_biometrics(pipeline, database, dask_client, groups, output, **kwargs
                 result = result.compute(scheduler="single-threaded")
 
         # Check if there's a score writer hooked in
-        if isinstance(pipeline.biometric_algorithm, BioAlgorithmCheckpointWrapper):
+        if hasattr(pipeline.biometric_algorithm, "score_writer"):
             pipeline.biometric_algorithm.score_writer.concatenate_write_scores(result, score_file_name)
         else:
-            # Flatting out the list
-            result = itertools.chain(*result)
-            for probe in result:
-                for sample in probe.samples:
-                    f.write(sample.data)
+            with open(score_file_name, "w") as f:
+                # Flatting out the list
+                result = itertools.chain(*result)
+                for probe in result:
+                    for sample in probe.samples:
+                        f.writelines(sample.data)
 
     if dask_client is not None:
         dask_client.shutdown()
-- 
GitLab