Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating local_state directory, and saving state to it #1271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 model with score {agg_results:f}"
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
Loading