Skip to content
Snippets Groups Projects
Commit 710625a2 authored by Karim Ahmed's avatar Karim Ahmed
Browse files

fix: remove directory

parent 60bcba05
No related branches found
No related tags found
1 merge request!1059[webservice] Intoduce Global Logger for xfel-calibrate
......@@ -25,7 +25,6 @@ echo "job ID: ${SLURM_JOB_ID:-none}"
echo "hostname: $(hostname)"
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
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment