Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
MPSD Computational Science
mpsd-software-manager
Commits
464b60e1
Commit
464b60e1
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
breakdown the line to allow for char lim
parent
07ffb8b7
No related branches found
Branches containing commit
No related tags found
1 merge request
!28
improve machine readable logging
Pipeline
#369761
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mpsd-software-environment.py
+1
-1
1 addition, 1 deletion
mpsd-software-environment.py
tests.py
+9
-7
9 additions, 7 deletions
tests.py
with
10 additions
and
8 deletions
mpsd-software-environment.py
+
1
−
1
View file @
464b60e1
...
...
@@ -91,7 +91,7 @@ def read_metadata_from_logfile(logfile: Union[str, Path]) -> dict:
}
def
set_up_logging
(
loglevel
=
"
warning
"
,
filename
=
'
gol.log
'
):
def
set_up_logging
(
loglevel
=
"
warning
"
,
filename
=
"
gol.log
"
):
"""
Set up logging.
This function sets up the logging configuration for the script.
...
...
This diff is collapsed.
Click to expand it.
tests.py
+
9
−
7
View file @
464b60e1
"""
Tests for mpsd-software-environment.py.
"""
import
importlib
import
logging
import
os
import
shutil
import
subprocess
from
pathlib
import
Path
import
pytest
import
logging
mod
=
importlib
.
import_module
(
"
mpsd-software-environment
"
)
...
...
@@ -315,20 +313,24 @@ def test_install_environment_zlib():
lines
=
f
.
read
()
assert
"
zlib
"
in
lines
def
test_metadata_logging
(
tmp_path
):
"""
Test that metadata is logged and read correctly.
"""
# Test that the metadata is logged correctly
mod
.
set_up_logging
(
loglevel
=
"
debug
"
,
filename
=
tmp_path
/
"
test-metadata.log
"
)
mod
.
set_up_logging
(
loglevel
=
"
debug
"
,
filename
=
tmp_path
/
"
test-metadata.log
"
)
key
=
"
important_key
"
value
=
"
important_value
"
mod
.
log_metadata
(
key
,
value
)
expected_log
=
f
"
{
mod
.
config_vars
[
'
metadata_tag_open
'
]
}{
key
}
:
{
value
}{
mod
.
config_vars
[
'
metadata_tag_close
'
]
}
"
with
open
(
tmp_path
/
"
test-metadata.log
"
,
"
r
"
)
as
f
:
mod
.
log_metadata
(
key
,
value
)
open_tag
=
mod
.
config_vars
[
"
metadata_tag_open
"
]
close_tag
=
mod
.
config_vars
[
"
metadata_tag_close
"
]
expected_log
=
f
"
{
open_tag
}{
key
}
:
{
value
}{
close_tag
}
"
with
open
(
tmp_path
/
"
test-metadata.log
"
,
"
r
"
)
as
f
:
assert
expected_log
in
f
.
read
()
# Test that the metadata is read correctly
read_dict
=
mod
.
read_metadata_from_logfile
(
tmp_path
/
"
test-metadata.log
"
)
read_dict
=
mod
.
read_metadata_from_logfile
(
tmp_path
/
"
test-metadata.log
"
)
assert
read_dict
[
key
]
==
value
def
test_interface
(
tmp_path
):
"""
Test other things (not implemented yet).
"""
pass
...
...
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