Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Leipzig Machine Learning Group
conML
python
Commits
e3a75c0a
Commit
e3a75c0a
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Define general, pre processing and learn block identification settings.
parent
c2ea227a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cml/shared/__init__.py
+0
-0
0 additions, 0 deletions
cml/shared/__init__.py
cml/shared/settings.py
+102
-0
102 additions, 0 deletions
cml/shared/settings.py
with
102 additions
and
0 deletions
cml/shared/__init__.py
0 → 100644
+
0
−
0
View file @
e3a75c0a
This diff is collapsed.
Click to expand it.
cml/shared/settings.py
0 → 100644
+
102
−
0
View file @
e3a75c0a
"""
Settings module.
"""
from
itertools
import
starmap
from
dataclasses
import
dataclass
from
configparser
import
ConfigParser
# TODO (dmt): Set default values
class
Settings
:
INPUT_FILE
:
str
=
""
LEARN_DIR
:
str
=
""
MAX_LEARN_DIR
:
int
=
0
USE_EXISTING_MODELS
:
bool
=
False
SET_FEATURES
:
str
=
""
SET_TARGETS
:
str
=
""
SORT_TIME_STAMP
:
bool
=
False
CUT_TIME_STAMP
:
bool
=
False
BLOCK_SIZE
:
int
=
0
MAX_BLOCKS
:
int
=
0
STACK_ITERATIONS
:
int
=
0
LEARN_BLOCK_MINIMUM
:
int
=
0
SIGMA_ZETA_CUTOFF
:
float
=
0.0
@dataclass
class
GeneralSettings
:
input_file
:
str
learn_dir
:
str
max_learn_dir
:
int
use_existing_models
:
bool
@dataclass
class
PreprocessingSettings
:
set_features
:
str
set_targets
:
str
sort_time_stamp
:
bool
cut_time_stamp
:
bool
@dataclass
class
BlockProcessingSettings
:
block_size
=
int
max_blocks
=
int
stack_iterations
=
int
learn_block_minimum
=
int
sigma_zeta_cutoff
=
float
def
specific_settings_factory
(
settings_type
:
str
):
types
=
{
"
general
"
:
starmap
(
GeneralSettings
,
[(
Settings
.
INPUT_FILE
,
Settings
.
LEARN_DIR
,
Settings
.
MAX_LEARN_DIR
,
Settings
.
USE_EXISTING_MODELS
)]),
"
preprocessing
"
:
starmap
(
PreprocessingSettings
,
[(
Settings
.
SET_FEATURES
,
Settings
.
SET_TARGETS
,
Settings
.
SORT_TIME_STAMP
,
Settings
.
CUT_TIME_STAMP
)]),
"
block_processing
"
:
starmap
(
BlockProcessingSettings
,
[(
Settings
.
BLOCK_SIZE
,
Settings
.
MAX_BLOCKS
,
Settings
.
STACK_ITERATIONS
,
Settings
.
LEARN_BLOCK_MINIMUM
,
Settings
.
SIGMA_ZETA_CUTOFF
)])
}
return
next
(
types
[
settings_type
])
def
read_settings
(
path
:
str
):
try
:
config
=
ConfigParser
(
path
)
configure_main_settings_class
(
config
)
except
AttributeError
as
e
:
# TODO (dmt): Implement proper error handling.
pass
def
configure_main_settings_class
(
config
):
default
=
config
[
"
DEFAULT
"
]
Settings
.
INPUT_FILE
=
default
[
"
input_file
"
]
Settings
.
LEARN_DIR
=
default
[
"
learn_dir
"
]
Settings
.
MAX_LEARN_DIR
=
default
[
"
max_learn_dir
"
]
Settings
.
USE_EXISTING_MODELS
=
default
[
"
use_existing_models
"
]
preprocessing
=
config
[
"
PREPROCESSING
"
]
Settings
.
SET_FEATURES
=
preprocessing
[
"
set_features
"
]
Settings
.
SET_TARGETS
=
preprocessing
[
"
set_targets
"
]
Settings
.
SORT_TIME_STAMP
=
preprocessing
[
"
sort_time_stamp
"
]
Settings
.
CUT_TIME_STAMP
=
preprocessing
[
"
cut_time_stamp
"
]
block_processing
=
config
[
"
BLOCK_PROCESSING
"
]
Settings
.
BLOCK_SIZE
=
block_processing
[
"
block_size
"
]
Settings
.
MAX_BLOCKS
=
block_processing
[
"
max_blocks
"
]
Settings
.
STACK_ITERATIONS
=
block_processing
[
"
stack_iterations
"
]
Settings
.
LEARN_BLOCK_MINIMUM
=
block_processing
[
"
learn_block_minimum
"
]
Settings
.
SIGMA_ZETA_CUTOFF
=
block_processing
[
"
sigma_zeta_cutoff
"
]
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