Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CFA Analysis
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
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
JOSSOUD Olivier
CFA Analysis
Commits
61fe55b8
You need to sign in or sign up before continuing.
Commit
61fe55b8
authored
5 years ago
by
JOSSOUD Olivier
Browse files
Options
Downloads
Patches
Plain Diff
ConductCalibProvider. Comments and style.
parent
3d64fd68
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dataprovider/conductcalibprovider.py
+54
-12
54 additions, 12 deletions
src/dataprovider/conductcalibprovider.py
with
54 additions
and
12 deletions
src/dataprovider/conductcalibprovider.py
+
54
−
12
View file @
61fe55b8
...
@@ -115,21 +115,21 @@ class CalibRun:
...
@@ -115,21 +115,21 @@ class CalibRun:
periodic_file
=
self
.
__find_single_file_in_file_list__
(
periodic_file
=
self
.
__find_single_file_in_file_list__
(
files_list
=
files
,
files_list
=
files
,
file_pattern
=
r
"
[0-9]{8}_[0-9]{6}_conduct-calib_(EDAQ|CONDUCTI)_periodic.log
"
,
file_pattern
=
r
"
[0-9]{8}_[0-9]{6}_conduct-calib_(EDAQ|CONDUCTI)_periodic.log
"
,
file_identif
y
er
=
"
Periodic
"
)
file_identif
i
er
=
"
Periodic
"
)
self
.
periodic_df
=
self
.
get_periodic_file_content
(
directory
+
periodic_file
)
self
.
periodic_df
=
self
.
get_periodic_file_content
(
directory
+
periodic_file
)
# Instant configuration changes
# Instant configuration changes
instant_config_file
=
self
.
__find_single_file_in_file_list__
(
instant_config_file
=
self
.
__find_single_file_in_file_list__
(
files_list
=
files
,
files_list
=
files
,
file_pattern
=
r
"
[0-9]{8}_[0-9]{6}_conduct-calib_(EDAQ|CONDUCTI)_instant.log
"
,
file_pattern
=
r
"
[0-9]{8}_[0-9]{6}_conduct-calib_(EDAQ|CONDUCTI)_instant.log
"
,
file_identif
y
er
=
"
Instant config
"
)
file_identif
i
er
=
"
Instant config
"
)
self
.
instant_config_df
=
self
.
get_instant_config_file_content
(
directory
+
instant_config_file
)
self
.
instant_config_df
=
self
.
get_instant_config_file_content
(
directory
+
instant_config_file
)
# User-defined) configuration changes
# User-defined) configuration changes
user_config_file
=
self
.
__find_single_file_in_file_list__
(
user_config_file
=
self
.
__find_single_file_in_file_list__
(
files_list
=
files
,
files_list
=
files
,
file_pattern
=
r
"
conduct_calib.csv
"
,
file_pattern
=
r
"
conduct_calib.csv
"
,
file_identif
y
er
=
"
User config
"
)
file_identif
i
er
=
"
User config
"
)
self
.
user_config_df
=
self
.
get_user_config_file_content
(
directory
+
user_config_file
)
self
.
user_config_df
=
self
.
get_user_config_file_content
(
directory
+
user_config_file
)
# Compare expected and real configuration changes.
# Compare expected and real configuration changes.
...
@@ -141,30 +141,71 @@ class CalibRun:
...
@@ -141,30 +141,71 @@ class CalibRun:
standard_cond_file
=
self
.
__find_single_file_in_file_list__
(
standard_cond_file
=
self
.
__find_single_file_in_file_list__
(
files_list
=
files
,
files_list
=
files
,
file_pattern
=
r
"
standard_conductivity.txt
"
,
file_pattern
=
r
"
standard_conductivity.txt
"
,
file_identif
y
er
=
"
Standard conductivity
"
)
file_identif
i
er
=
"
Standard conductivity
"
)
with
open
(
directory
+
standard_cond_file
,
"
r
"
)
as
file
:
with
open
(
directory
+
standard_cond_file
,
"
r
"
)
as
file
:
self
.
standard_cond
=
float
(
file
.
readline
())
self
.
standard_cond
=
float
(
file
.
readline
())
def
__check_real_config__
(
self
,
real_config_df
:
pd
.
DataFrame
,
user_config_df
:
pd
.
DataFrame
)
->
bool
:
@staticmethod
def
__check_real_config__
(
real_config_df
:
pd
.
DataFrame
,
user_config_df
:
pd
.
DataFrame
)
->
bool
:
"""
Check that the real and user-defined configuration are the same.
Parameters
----------
real_config_df: pd.Dataframe
Dataframe containing the really-applied configuration changes, i.e. the orders which have been send to the
instrument.
user_config_df: pd.Dataframe
Dataframe containing the user-defined configuration, as defined in the conduct_calib.csv file
Returns
-------
bool
True if the real config matches the user-defined one, False if there are discrepancies.
"""
"""
Compare the user-defined configuration file with the instant recording of the configuration changes.
"""
Compare the user-defined configuration file with the instant recording of the configuration changes.
Note: Currently only check steps number
"""
Note: Currently only check steps number
"""
return
real_config_df
[
"
step
"
].
max
()
==
user_config_df
[
"
step
"
].
max
()
return
real_config_df
[
"
step
"
].
max
()
==
user_config_df
[
"
step
"
].
max
()
def
__find_single_file_in_file_list__
(
self
,
files_list
:
list
,
file_pattern
:
str
,
file_identifyer
:
str
)
->
str
:
@staticmethod
def
__find_single_file_in_file_list__
(
files_list
:
list
,
file_pattern
:
str
,
file_identifier
:
str
)
->
str
:
"""
Get the file name matching the ``file_pattern``, from the files list.
Parameters
----------
files_list: list
List of file names.
file_pattern: str
Regex used to find the desired single file.
file_identifier: str
Human-readable string used to identify the file type which is searched. This string is used to inform the
user when there is an error.
Returns
-------
str:
File name matching the ``file_pattern``
Raises
-------
ValueError
If no file or more than one file is found.
"""
found_files
=
[
f
for
f
in
files_list
if
re
.
search
(
file_pattern
,
f
)]
found_files
=
[
f
for
f
in
files_list
if
re
.
search
(
file_pattern
,
f
)]
if
len
(
found_files
)
>
1
:
if
len
(
found_files
)
>
1
:
raise
ValueError
(
"
More than one file of type [
"
+
file_identif
y
er
+
"
] found.
"
)
raise
ValueError
(
"
More than one file of type [
"
+
file_identif
i
er
+
"
] found.
"
)
elif
len
(
found_files
)
==
0
:
elif
len
(
found_files
)
==
0
:
raise
ValueError
(
"
No file found for type [
"
+
file_identif
y
er
+
"
]
"
)
raise
ValueError
(
"
No file found for type [
"
+
file_identif
i
er
+
"
]
"
)
return
found_files
[
0
]
return
found_files
[
0
]
def
get_periodic_file_content
(
self
,
filename
:
str
)
->
pd
.
DataFrame
:
@staticmethod
def
get_periodic_file_content
(
filename
:
str
)
->
pd
.
DataFrame
:
periodic_df
=
pd
.
read_csv
(
filename
,
sep
=
"
\t
"
,
parse_dates
=
[
"
datetime
"
])
periodic_df
=
pd
.
read_csv
(
filename
,
sep
=
"
\t
"
,
parse_dates
=
[
"
datetime
"
])
return
periodic_df
return
periodic_df
def
get_instant_config_file_content
(
self
,
filename
:
str
)
->
pd
.
DataFrame
:
@staticmethod
def
get_instant_config_file_content
(
filename
:
str
)
->
pd
.
DataFrame
:
config_df
=
pd
.
read_csv
(
filename
,
sep
=
"
,
"
,
parse_dates
=
[
"
datetime
"
])
config_df
=
pd
.
read_csv
(
filename
,
sep
=
"
,
"
,
parse_dates
=
[
"
datetime
"
])
# Identify steps.
# Identify steps.
...
@@ -177,6 +218,7 @@ class CalibRun:
...
@@ -177,6 +218,7 @@ class CalibRun:
return
config_df
return
config_df
def
get_user_config_file_content
(
self
,
filename
:
str
)
->
pd
.
DataFrame
:
@staticmethod
def
get_user_config_file_content
(
filename
:
str
)
->
pd
.
DataFrame
:
config_df
=
pd
.
read_csv
(
filename
,
sep
=
"
,
"
)
config_df
=
pd
.
read_csv
(
filename
,
sep
=
"
,
"
)
return
config_df
return
config_df
\ No newline at end of file
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