-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from rediscovery-io/load-config-file
Fix load config
- Loading branch information
Showing
2 changed files
with
27 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.8' | ||
__version__ = '0.1.9' |