Commit d14ad2b3 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

fix path problem for jupyter notebook

parent 11ebd697
Pipeline #350519 passed with stage
in 12 seconds
......@@ -321,7 +321,7 @@ def make_feature_config(class_name, identifier="", name="", subFeatures=""):
return config_json
def make_thing_config(dt_id, name, roles, features=[]):
def make_thing_config(dt_id, name, roles, features=[], root=__file__):
config_file = {
"thingId": dt_id,
"policyId": dt_id,
......@@ -333,19 +333,19 @@ def make_thing_config(dt_id, name, roles, features=[]):
path = os.path.join(get_root(), "configs", "{}.json".format(name))
path = os.path.join(get_root(root), "configs", "{}.json".format(name))
with open(path, 'wb') as file:
return "{}.json".format(name)
def load_config(config_file_name):
def load_config(config_file_name, root=__file__):
"""Creates a json object from a json formatted file found at config_filepath.
:param config_filepath: Path to json formatted file.
config_file_path = os.path.join(get_root(), "configs", config_file_name)
config_file_path = os.path.join(get_root(root), "configs", config_file_name)
with open(config_file_path) as config_file:
config = json.load(config_file)
return config
......@@ -2,7 +2,7 @@
import sys
def get_root():
path = sys.modules[__name__].__file__ if __name__ == "__main__" else __file__
def get_root(file_path):
path = sys.modules[__name__].__file__ if __name__ == "__main__" else file_path
return os.path.abspath(os.path.join(os.path.dirname(path), os.path.pardir))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment