diff --git a/egcg_core/archive_management.py b/egcg_core/archive_management.py
index 3437925..58c5eb9 100644
--- a/egcg_core/archive_management.py
+++ b/egcg_core/archive_management.py
@@ -1,6 +1,8 @@
 import os
 import re
 import subprocess
+from time import sleep
+
 from egcg_core.app_logging import logging_default as log_cfg
 from egcg_core.exceptions import EGCGError
 
@@ -83,13 +85,18 @@ def release_file_from_lustre(file_path):
         return True
 
 
-def register_for_archiving(file_path):
+def register_for_archiving(file_path, strict=False):
     if is_register_for_archiving(file_path):
         return True
     cmd = 'lfs hsm_archive %s' % file_path
     val = _get_stdout(cmd)
     if val is None or not is_register_for_archiving(file_path):
-        raise ArchivingError('Registering %s for archiving to tape failed' % file_path)
+        if strict:
+            raise ArchivingError('Registering %s for archiving to tape failed' % file_path)
+        # Registering for archive can sometime take time so give it a second
+        sleep(1)
+        return register_for_archiving(filter, strict=True)
+
     return True
 
 

Failure to register for archiving cause pipeline crash
We should make the registering for archiving more robust by sleeping trying again to register the file after 1 second.
https://github.com/EdinburghGenomics/EGCG-Core/blob/master/egcg_core/archive_management.py#L92
This raising can cause Analysis Driver to crash at the end of the processing rather randomly.

diff --git a/tests/test_archive_management.py b/tests/test_archive_management.py
index c087706..5d45646 100644
--- a/tests/test_archive_management.py
+++ b/tests/test_archive_management.py
@@ -76,7 +76,7 @@ class TestArchiveManagement(TestEGCG):
                        '',
                        'testfile: (0x00000001)',
                     ]) as get_stdout:
-            self.assertRaises(ArchivingError, register_for_archiving, 'testfile')
+            self.assertRaises(ArchivingError, register_for_archiving, 'testfile', True)
             assert get_stdout.call_count == 3
             assert get_stdout.call_args_list[1][0] == ('lfs hsm_archive testfile',)
 

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
asana==0.6.2
cached-property==2.0.1
-e git+https://github.com/EdinburghGenomics/EGCG-Core.git@5a073c8d79148ed29379e4818e4dcebd5180eb15#egg=EGCG_Core
exceptiongroup==1.2.2
genologics==1.0.0
iniconfig==2.1.0
Jinja2==2.8
MarkupSafe==3.0.2
oauthlib==3.2.2
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
PyYAML==6.0.2
requests==2.9.2
requests-oauthlib==0.6.2
six==1.10.0
tomli==2.2.1

name: EGCG-Core
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - asana==0.6.2
      - cached-property==2.0.1
      - exceptiongroup==1.2.2
      - genologics==1.0.0
      - iniconfig==2.1.0
      - jinja2==2.8
      - markupsafe==3.0.2
      - oauthlib==3.2.2
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pyyaml==6.0.2
      - requests==2.9.2
      - requests-oauthlib==0.6.2
      - six==1.10.0
      - tomli==2.2.1
prefix: /opt/conda/envs/EGCG-Core

tests/test_archive_management.py::TestArchiveManagement::test_register_for_archiving
tests/test_archive_management.py::TestArchiveManagement::test_archive_directory tests/test_archive_management.py::TestArchiveManagement::test_archive_states tests/test_archive_management.py::TestArchiveManagement::test_recall_from_tape tests/test_archive_management.py::TestArchiveManagement::test_release_file_from_lustre
egcg_core/archive_management.py
egcg_core/archive_management.py