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
34878f67
Commit
34878f67
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Insert default settings into config file after cml installation.
parent
0da16623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setup.py
+35
-16
35 additions, 16 deletions
setup.py
with
35 additions
and
16 deletions
setup.py
+
35
−
16
View file @
34878f67
from
os
import
mkdir
from
os.path
import
expanduser
,
exists
,
join
from
configparser
import
ConfigParser
from
distutils.core
import
setup
USER_HOME_FOLDER
=
expanduser
(
"
~
"
)
CML_FOLDER_NAME
=
"
.cml
"
DEFAULT_LEARN_DIRECTORY
=
"
data
"
USER_HOME_DIR
=
expanduser
(
"
~
"
)
CML_DIR_NAME
=
"
.cml
"
DEFAULT_LEARN_DIR
=
"
data
"
CONFIG_FILE_NAME
=
"
settings.ini
"
DEFAULT_TRAINING_SET
=
"
c_iris.csv
"
KNOWLEDGE_DIR
=
"
knowledge
"
CML_CONFIG_FOLDER
=
join
(
USER_HOME_FOLDER
,
CML_FOLDER_NAME
)
CML_DEFAULT_LEARN_DIRECTORY
=
join
(
CML_CONFIG_FOLDER
,
DEFAULT_LEARN_DIRECTORY
)
CML_CONFIG_DIR
=
join
(
USER_HOME_DIR
,
CML_DIR_NAME
)
CML_DEFAULT_LEARN_DIR
=
join
(
CML_CONFIG_DIR
,
DEFAULT_LEARN_DIR
)
CONFIG_FILE_PATH
=
join
(
CML_CONFIG_DIR
,
CONFIG_FILE_NAME
)
DEFAULT_TRAINING_SET_PATH
=
join
(
CML_DEFAULT_LEARN_DIR
,
DEFAULT_TRAINING_SET
)
KNOWLEDGE_DIR_PATH
=
join
(
CML_CONFIG_DIR
,
KNOWLEDGE_DIR
)
def
create_cml_config_
folde
r
():
mkdir
(
CML_CONFIG_
FOLDE
R
)
def
create_cml_config_
di
r
():
mkdir
(
CML_CONFIG_
DI
R
)
# TODO (dmt): Insert it!
def
insert_input_file_path_into_settings
():
pass
def
create_data_dir
():
mkdir
(
CML_DEFAULT_LEARN_DIR
)
# TODO (dmt): Insert it!
def
insert_learn_directory_path_into_settings
():
pass
def
insert_default_settings_into_config_file
():
config
=
ConfigParser
()
config
.
read
(
CONFIG_FILE_PATH
)
config
[
"
GENERAL
"
][
"
input_file
"
]
=
DEFAULT_TRAINING_SET_PATH
config
[
"
GENERAL
"
][
"
learn_dir
"
]
=
CML_DEFAULT_LEARN_DIR
config
[
"
GENERAL
"
][
"
knowledge_dir
"
]
=
KNOWLEDGE_DIR_PATH
write_configs
(
config
)
if
not
exists
(
CML_CONFIG_FOLDER
):
create_cml_config_folder
()
def
write_configs
(
config
):
with
open
(
CONFIG_FILE_PATH
,
'
w
'
)
as
configfile
:
config
.
write
(
configfile
)
if
not
exists
(
CML_CONFIG_DIR
):
create_cml_config_dir
()
setup
(
name
=
"
cml
"
,
version
=
"
0.1dev
"
,
packages
=
[
"
cml
"
,
],
data_files
=
[(
CML_CONFIG_FOLDER
,
[
"
cml/static/settings.ini
"
])]
data_files
=
[(
CML_CONFIG_DIR
,
[
"
cml/static/settings.ini
"
]),
(
CML_DEFAULT_LEARN_DIR
,
[
"
cml/static/iris.csv
"
]),
(
CML_DEFAULT_LEARN_DIR
,
[
"
cml/static/c_iris.csv
"
])]
)
insert_default_settings_into_config_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