Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
esde
machine-learning
MLAir
Merge requests
!83
Resolve "logging with counter"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "logging with counter"
lukas_issue085_refac_log-file-counter
into
develop
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Ghost User
requested to merge
lukas_issue085_refac_log-file-counter
into
develop
5 years ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
Closes
#85 (closed)
Edited
5 years ago
by
Ghost User
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
9bc43bf7
1 commit,
5 years ago
1 file
+
15
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/run_modules/run_environment.py
+
15
−
5
Options
@@ -39,11 +39,7 @@ class RunEnvironment(object):
logging
.
info
(
f
"
{
self
.
__class__
.
__name__
}
finished after
{
self
.
time
}
"
)
self
.
del_by_exit
=
True
if
self
.
__class__
.
__name__
==
"
RunEnvironment
"
:
try
:
new_file
=
os
.
path
.
join
(
self
.
data_store
.
get
(
"
experiment_path
"
),
"
logging.log
"
)
shutil
.
copyfile
(
self
.
logger
.
log_file
,
new_file
)
except
(
NameNotFoundInDataStore
,
FileNotFoundError
):
pass
self
.
__copy_log_file
()
self
.
data_store
.
clear_data_store
()
def
__enter__
(
self
):
@@ -52,6 +48,20 @@ class RunEnvironment(object):
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
self
.
__del__
()
def
__copy_log_file
(
self
):
try
:
counter
=
0
filename_pattern
=
os
.
path
.
join
(
self
.
data_store
.
get
(
"
experiment_path
"
),
"
logging_%03i.log
"
)
new_file
=
filename_pattern
%
counter
while
os
.
path
.
exists
(
new_file
):
counter
+=
1
new_file
=
filename_pattern
%
counter
logging
.
info
(
f
"
Copy log file to
{
new_file
}
"
)
shutil
.
copyfile
(
self
.
logger
.
log_file
,
new_file
)
except
(
NameNotFoundInDataStore
,
FileNotFoundError
):
pass
@staticmethod
def
do_stuff
(
length
=
2
):
time
.
sleep
(
length
)
Loading