Skip to content

Commit

Permalink
Add MLFlow tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh committed Feb 16, 2023
1 parent dbeee50 commit b989d24
Show file tree
Hide file tree
Showing 9 changed files with 1,222 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/tutorial/hello-pt-tb-mlflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Hello PyTorch with MLFlow Experimental Tracking

This example, show that one can using the existing tracker code written for Tensorboard,
but change the metrics tracking with both Tensorflow and MLFLow

The only change compare with hello-pt-tb example is adding the following component in fed_server_config.json

```json
{
"id": "mlflow_receiver",
"path": "nvflare.app_opt.tracking.mlflow.mlflow_receiver.MLFlowReceiver",
"args": {
"kwargs": {"experiment_name": "hello-pt-experiments"},
"artifact_location": "artifacts"
}
}

```
640 changes: 640 additions & 0 deletions examples/tutorial/hello-pt-tb-mlflow/experiment_tracking.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"format_version": 2,

"executors": [
{
"tasks": [
"train",
"submit_model",
"validate"
],
"executor": {
"id": "Executor",
"path": "nvflare.app_common.executors.learner_executor.LearnerExecutor",
"args": {
"learner_id": "pt_learner"
}
}
}
],
"task_result_filters": [
],
"task_data_filters": [
],
"components": [
{
"id": "pt_learner",
"path": "pt_learner.PTLearner",
"args": {
"lr": 0.01,
"epochs": 5,
"analytic_sender_id": "analytic_sender"
}
},
{
"id": "analytic_sender",
"name": "AnalyticsSender",
"args": {"event_type": "analytix_log_stats"}
},
{
"id": "event_to_fed",
"name": "ConvertToFedEvent",
"args": {"events_to_convert": ["analytix_log_stats"], "fed_event_prefix": "fed."}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"format_version": 2,

"server": {
"heart_beat_timeout": 600
},
"task_data_filters": [],
"task_result_filters": [],
"components": [
{
"id": "persistor",
"path": "nvflare.app_opt.pt.file_model_persistor.PTFileModelPersistor",
"args": {
"model": {
"path": "simple_network.SimpleNetwork"
}
}
},
{
"id": "shareable_generator",
"path": "nvflare.app_common.shareablegenerators.full_model_shareable_generator.FullModelShareableGenerator",
"args": {}
},
{
"id": "aggregator",
"path": "nvflare.app_common.aggregators.intime_accumulate_model_aggregator.InTimeAccumulateWeightedAggregator",
"args": {
"expected_data_kind": "WEIGHTS"
}
},
{
"id": "model_locator",
"path": "nvflare.app_opt.pt.file_model_locator.PTFileModelLocator",
"args": {
"pt_persistor_id": "persistor"
}
},
{
"id": "json_generator",
"path": "nvflare.app_common.widgets.validation_json_generator.ValidationJsonGenerator",
"args": {}
},
{
"id": "tb_analytics_receiver",
"name": "TBAnalyticsReceiver",
"args": {"events": ["fed.analytix_log_stats"]}
},
{
"id": "mlflow_receiver",
"path": "nvflare.app_opt.tracking.mlflow.mlflow_receiver.MLFlowReceiver",
"args": {
"kwargs": {"experiment_name": "hello-pt-experiments"},
"artifact_location": "artifacts"
}
}
],
"workflows": [
{
"id": "scatter_and_gather",
"name": "ScatterAndGather",
"args": {
"min_clients" : 2,
"num_rounds" : 1,
"start_round": 0,
"wait_time_after_min_received": 10,
"aggregator_id": "aggregator",
"persistor_id": "persistor",
"shareable_generator_id": "shareable_generator",
"train_task_name": "train",
"train_timeout": 0
}
},
{
"id": "cross_site_validate",
"name": "CrossSiteModelEval",
"args": {
"model_locator_id": "model_locator"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


class PTConstants:
PTServerName = "server"
PTFileModelName = "FL_global_model.pt"
PTLocalModelName = "local_model.pt"

PTModelsDir = "models"
CrossValResultsJsonFilename = "cross_val_results.json"
Loading

0 comments on commit b989d24

Please sign in to comment.