Skip to content

Commit

Permalink
rename root -> project root, dataset_name -> project_name
Browse files Browse the repository at this point in the history
  • Loading branch information
funkchaser committed May 1, 2024
1 parent 6f770c6 commit a6bb511
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/aixd_grasshopper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def project_setup():
sc = SessionController.create(session_id)

sc.reset() # Reset the session
root = data["root"]
dataset_name = data["dataset_name"]
result = sc.project_setup(root, dataset_name)
project_root = data["project_root"]
project_name = data["project_name"]
result = sc.project_setup(project_root, project_name)
response = json.dumps(result, cls=DataEncoder)
return response

Expand Down
2 changes: 1 addition & 1 deletion src/aixd_grasshopper/components/aixd_ModelTrain/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if wb:
import webbrowser

projectname = project_setup_info(session_id())["dataset_name"] # project name == dataset name
projectname = project_setup_info(session_id())["project_name"] # project name == dataset name

if run:
url = "https://wandb.ai/{}/{}".format(wb, projectname)
Expand Down
36 changes: 18 additions & 18 deletions src/aixd_grasshopper/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class SessionController(object):
instances = {}

def __init__(self):
self.root_path = None
self.dataset_name = None
self.project_root = None
self.project_name = None
self.dataset = None
self.model = None
self.datamodule = None
self.samples_per_file = None
self.model_is_trained = False

def reset(self):
self.root_path = None
self.dataset_name = None
self.project_root = None
self.project_name = None
self.dataset = None
self.model = None
self.datamodule = None
Expand All @@ -51,41 +51,41 @@ def reset(self):

@property
def dataset_path(self):
if not self.root_path or not self.dataset_name:
if not self.project_root or not self.project_name:
return None
return os.path.join(self.root_path, self.dataset_name)
return os.path.join(self.project_root, self.project_name)

@classmethod
def create(cls, session_id):
if session_id not in cls.instances:
cls.instances[session_id] = cls()
return cls.instances[session_id]

def project_setup(self, root_path, dataset_name):
if not os.path.exists(root_path):
return {"msg": "Project path {root_path} does not exist!"}
self.root_path = root_path
self.dataset_name = dataset_name
def project_setup(self, project_root, project_name):
if not os.path.exists(project_root):
return {"msg": "Project path {project_root} does not exist!"}
self.project_root = project_root
self.project_name = project_name
return {
"msg": f"Project has been set up in: {os.path.join(self.root_path, self.dataset_name)}",
"path": os.path.join(self.root_path, self.dataset_name),
"msg": f"Project has been set up in: {os.path.join(self.project_root, self.project_name)}",
"path": os.path.join(self.project_root, self.project_name),
}

def project_setup_info(self):
return {"root_path": self.root_path, "dataset_name": self.dataset_name}
return {"project_root": self.project_root, "project_name": self.project_name}

def create_dataset_object(self, design_parameters, performance_attributes):
"""
Creates a dataset object based on given definitions of dataobjects in shallow formatting.
"""

if not self.root_path or not self.dataset_name:
if not self.project_root or not self.project_name:
raise ValueError("You need to first set the project root path and the dataset name.")

dp = DesignParameters(name="DP", dobj_list=dataobjects_from_shallow(design_parameters))
pa = PerformanceAttributes(name="PA", dobj_list=dataobjects_from_shallow(performance_attributes))

dataset = Dataset(name=self.dataset_name, design_par=dp, perf_attributes=pa, root_path=self.root_path)
dataset = Dataset(name=self.project_name, design_par=dp, perf_attributes=pa, root_path=self.project_root)
dataset.save_dataset_obj()

# TODO: overrides an already assigned dataset - what about the datafiles if they exist?
Expand Down Expand Up @@ -139,11 +139,11 @@ def design_parameters_names(self):

def load_dataset(self):
error = ""
if not self.root_path or not self.dataset_name:
if not self.project_root or not self.project_name:
error = "You need to first set the project root path and the dataset name."
raise ValueError(error)
try:
dataset = Dataset(root_path=self.root_path, name=self.dataset_name, overwrite=False)
dataset = Dataset(root_path=self.project_root, name=self.project_name, overwrite=False)
dataset.load_dataset_obj()
dataset.load()
dataset.update_obj_domains(flag_only_perfatt=True)
Expand Down
4 changes: 2 additions & 2 deletions src/aixd_grasshopper/gh_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def reset_session(session_id):
return http_post_request(action="reset_session", data=data)


def project_setup(session_id, root_path, dataset_name):
data = {"session_id": session_id, "root": root_path, "dataset_name": dataset_name}
def project_setup(session_id, project_root, project_name):
data = {"session_id": session_id, "project_root": project_root, "project_name": project_name}
return http_post_request(action="project_setup", data=data)


Expand Down

0 comments on commit a6bb511

Please sign in to comment.