Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
710625a2
Commit
710625a2
authored
6 months ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
fix: remove directory
parent
60bcba05
No related branches found
No related tags found
1 merge request
!1059
[webservice] Intoduce Global Logger for xfel-calibrate
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/slurm_calibrate.sh
+0
-1
0 additions, 1 deletion
bin/slurm_calibrate.sh
src/xfel_calibrate/setup_logging.py
+1
-7
1 addition, 7 deletions
src/xfel_calibrate/setup_logging.py
with
1 addition
and
8 deletions
bin/slurm_calibrate.sh
+
0
−
1
View file @
710625a2
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/xfel_calibrate/setup_logging.py
+
1
−
7
View file @
710625a2
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment