From 3f89e843eda520f843b9ae4a8d2bbcb47341606a Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Wed, 25 Sep 2024 17:46:50 +0200
Subject: [PATCH] fix: remove directory

---
 bin/slurm_calibrate.sh              | 1 -
 src/xfel_calibrate/setup_logging.py | 8 +-------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/bin/slurm_calibrate.sh b/bin/slurm_calibrate.sh
index b49b4cb94..6a45fdb24 100755
--- a/bin/slurm_calibrate.sh
+++ b/bin/slurm_calibrate.sh
@@ -24,7 +24,6 @@ echo "cluster_cores: $cluster_cores"
 echo "job ID: ${SLURM_JOB_ID:-none}"
 
 export CAL_NOTEBOOK_NAME="$notebook"
-export CAL_WORKING_DIR="$(pwd)"
 export SLURM_JOB_ID="${SLURM_JOB_ID:-local}"
 
 # This is created by calibrate.py in CAL_WORKING_DIR
diff --git a/src/xfel_calibrate/setup_logging.py b/src/xfel_calibrate/setup_logging.py
index da34494b7..8a233b138 100644
--- a/src/xfel_calibrate/setup_logging.py
+++ b/src/xfel_calibrate/setup_logging.py
@@ -4,19 +4,15 @@ import sys
 import traceback
 import warnings
 import IPython
-import json
 from pythonjsonlogger import jsonlogger
 
 NOTEBOOK_NAME = os.getenv('CAL_NOTEBOOK_NAME', 'Unknown notebook')
-CURRENT_WORKING_DIR = os.getenv(
-    'CAL_WORKING_DIR', 'Unknown directory')
 JOB_ID = os.getenv('SLURM_JOB_ID', 'local')
 
 
 class ContextFilter(logging.Filter):
     def filter(self, record):
         record.notebook = NOTEBOOK_NAME
-        record.directory = CURRENT_WORKING_DIR
         record.job_id = JOB_ID
         return True
 
@@ -41,7 +37,7 @@ logger.setLevel(logging.INFO)
 # Define a custom JSON format
 formatter = CustomJsonFormatter(
     '%(timestamp)s %(level)s %(filename)s %(lineno)d '
-    '%(notebook)s %(directory)s %(job_id)s %(class)s %(message)s')
+    '%(notebook)s %(job_id)s %(class)s %(message)s')
 
 
 # Function to create a file handler with job-specific JSON log file
@@ -90,7 +86,6 @@ def safe_handle_error(exc_type, exc_value, exc_traceback):
             exc_type.__name__, str(exc_value),
             extra={
                 'notebook': NOTEBOOK_NAME,
-                'directory': CURRENT_WORKING_DIR,
                 'job_id': JOB_ID,
                 'class': exc_type.__name__ if exc_type else 'DefaultErrorClass',  # noqa
             },
@@ -111,7 +106,6 @@ def handle_warning(message, category, filename, lineno, file=None, line=None):
             message, filename, lineno,
             extra={
                 'notebook': NOTEBOOK_NAME,
-                'directory': CURRENT_WORKING_DIR,
                 'job_id': JOB_ID,
                 'class': category.__name__ if category else 'DefaultWarningClass',  # noqa
             }
-- 
GitLab