Skip to content

Commit

Permalink
Creating local_state directory, and saving state to it
Browse files Browse the repository at this point in the history
Signed-off-by: Lerer, Eran <[email protected]>
  • Loading branch information
cloudnoize committed Jan 15, 2025
1 parent fdad4fb commit 336887f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions openfl-docker/gramine_app/fx.manifest.template
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sgx.trusted_files = [
# One should be conservative as to which files are allowed, these can be modified by enclave.
sgx.allowed_files = [
"file:{{ workspace_root }}/save",
"file:{{ workspace_root }}/local_state",
"file:{{ workspace_root }}/logs",
"file:{{ workspace_root }}/cert",
"file:{{ workspace_root }}/data",
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/workspace/plan/defaults/aggregator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ template : openfl.component.Aggregator
settings :
db_store_rounds : 2
persist_checkpoint: True
persistent_db_path: save/tensor.db
persistent_db_path: local_state/tensor.db
2 changes: 1 addition & 1 deletion openfl/component/aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def _compute_validation_related_task_metrics(self, task_name) -> dict:

# FIXME: Configurable logic for min/max criteria in saving best.
if "validate_agg" in tags:
# Compare the accuracy of the model, potentially save it
# Compare the accuracy of the model, potentially save it.
if self.best_model_score is None or self.best_model_score < agg_results:
logger.info(
f"Round {round_number}: saved the best "
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def create_dirs(prefix):
(prefix / "data").mkdir(parents=True, exist_ok=True) # training data
(prefix / "logs").mkdir(parents=True, exist_ok=True) # training logs
(prefix / "save").mkdir(parents=True, exist_ok=True) # model weight saves / initialization
(prefix / "local_state").mkdir(parents=True, exist_ok=True) # persistent state
(prefix / "src").mkdir(parents=True, exist_ok=True) # model code

copyfile(WORKSPACE / "workspace" / ".workspace", prefix / ".workspace")
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/interactive_api/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def _initialize_plan(self):
# Create a folder to store plans
os.makedirs("./plan", exist_ok=True)
os.makedirs("./save", exist_ok=True)
os.makedirs("./local_state", exist_ok=True)
# Load the default plan
base_plan_path = WORKSPACE / "workspace/plan/plans/default/base_plan_interactive_api.yaml"
plan = Plan.parse(base_plan_path, resolve=False)
Expand Down
2 changes: 2 additions & 0 deletions openfl/interface/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def create_dirs(prefix):
(prefix / "data").mkdir(parents=True, exist_ok=True) # training data
(prefix / "logs").mkdir(parents=True, exist_ok=True) # training logs
(prefix / "save").mkdir(parents=True, exist_ok=True) # model weight saves / initialization
(prefix / "local_state").mkdir(parents=True, exist_ok=True) # persistent state
(prefix / "src").mkdir(parents=True, exist_ok=True) # model code

shutil.copyfile(WORKSPACE / "workspace" / ".workspace", prefix / ".workspace")
Expand Down Expand Up @@ -354,6 +355,7 @@ def export_() -> str:
# os.makedirs(os.path.join(tmp_dir, 'save'), exist_ok=True)
os.makedirs(os.path.join(tmp_dir, "logs"), exist_ok=True)
os.makedirs(os.path.join(tmp_dir, "data"), exist_ok=True)
os.makedirs(os.path.join(tmp_dir, "local_state"), exist_ok=True)
shutil.copytree("src", os.path.join(tmp_dir, "src"), ignore=ignore)
shutil.copytree("plan", os.path.join(tmp_dir, "plan"), ignore=ignore)
shutil.copytree("save", os.path.join(tmp_dir, "save"))
Expand Down
1 change: 1 addition & 0 deletions tests/openfl/federated/plan/plan_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ aggregator :
best_state_path : save/best.pbuf
last_state_path : save/last.pbuf
rounds_to_train : 10
persistent_db_path: tensor.db

collaborator :
defaults : plan/defaults/collaborator.yaml
Expand Down

0 comments on commit 336887f

Please sign in to comment.