Skip to content

Commit

Permalink
Merge pull request #61 from rediscovery-io/load-config-file
Browse files Browse the repository at this point in the history
Fix load config
  • Loading branch information
vmanilo authored Aug 19, 2020
2 parents 23b4175 + bd1f4de commit 4c6fcc1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions remo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def set_remo_home_from_default_remo_config() -> bool:
return True


class ViewerOptions:
electron = 'electron'
browser = 'browser'
jupyter = 'jupyter'


class CloudPlatformOptions:
colab = 'colab'


class Config:
"""
Remo Config
Expand All @@ -47,16 +57,11 @@ class Config:
'remo_home',
'cloud_platform',
]
_default_port = 8123
_default_server = 'http://localhost'
_default_user_name = 'Admin User'
_default_user_email = '[email protected]'
_default_user_password = 'adminpass'
_default_viewer = 'browser'

def __init__(self, config):
for name in self.__slots__:
setattr(self, name, config.get(name, getattr(self, '_default_{}'.format(name))))
default_value = getattr(DefaultConfig, name)
setattr(self, name, config.get(name, default_value))

def server_url(self):
return '{}:{}'.format(self.server, self.port)
Expand All @@ -82,4 +87,17 @@ def default_path():
def path(dir_path: str = None):
if not dir_path:
dir_path = get_remo_home()
return str(os.path.join(dir_path, Config.name))
return str(os.path.join(dir_path, Config.name))


class DefaultConfig(Config):
port = 8123
server = 'http://localhost'
user_name = 'Admin User'
user_email = '[email protected]'
user_password = 'adminpass'
viewer = ViewerOptions.browser
uuid = 'undefined'
public_url = None
remo_home = None
cloud_platform = None
2 changes: 1 addition & 1 deletion remo/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.8'
__version__ = '0.1.9'

0 comments on commit 4c6fcc1

Please sign in to comment.