Skip to content

Commit

Permalink
class renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
SYangster committed Dec 16, 2024
1 parent 1490704 commit 2a8826f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/programming_guide/fed_job_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ The FedAvgJob automatically adds the FedAvg controller, PTFileModelPersistor and
For more examples of job patterns, see:

* :class:`BaseFedJob<nvflare.job_config.base_fed_job.BaseFedJob>`
* :class:`CommonJob<nvflare.job_config.common_job.CommonJob>`
* :class:`FedAvgJob<nvflare.app_opt.pt.job_config.fed_avg.FedAvgJob>` (pytorch)
* :class:`FedAvgJob<nvflare.app_opt.tf.job_config.fed_avg.FedAvgJob>` (tensorflow)
* :class:`CCWFJob<nvflare.app_common.ccwf.ccwf_job.CCWFJob>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@
"#### 2. Define a FedJob\n",
"The `FedJob` is used to define how controllers and executors are placed within a federated job using the `to(object, target)` routine.\n",
"\n",
"Here we use a PyTorch `PTBaseFedJob`, where we can define the job name and the initial global model.\n",
"The `PTBaseFedJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
"Here we use a PyTorch `PTJob`, where we can define the job name and the initial global model.\n",
"The `PTJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
]
},
{
Expand All @@ -335,10 +335,10 @@
"from src.lit_net import LitNet\n",
"\n",
"from nvflare.app_common.workflows.fedavg import FedAvg\n",
"from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob\n",
"from nvflare.app_opt.pt.job_config.pt_job import PTJob\n",
"from nvflare.job_config.script_runner import ScriptRunner\n",
"\n",
"job = PTBaseFedJob(\n",
"job = PTJob(\n",
" name=\"cifar10_lightning_fedavg\",\n",
" initial_model=LitNet(),\n",
")"
Expand Down
8 changes: 4 additions & 4 deletions examples/getting_started/pt/nvflare_pt_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@
"#### 2. Define a FedJob\n",
"The `FedJob` is used to define how controllers and executors are placed within a federated job using the `to(object, target)` routine.\n",
"\n",
"Here we use a PyTorch `PTBaseFedJob`, where we can define the job name and the initial global model.\n",
"The `PTBaseFedJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
"Here we use a PyTorch `PTJob`, where we can define the job name and the initial global model.\n",
"The `PTJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
]
},
{
Expand All @@ -277,10 +277,10 @@
"from src.net import Net\n",
"\n",
"from nvflare.app_common.workflows.fedavg import FedAvg\n",
"from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob\n",
"from nvflare.app_opt.pt.job_config.pt_job import PTJob\n",
"from nvflare.job_config.script_runner import ScriptRunner\n",
"\n",
"job = PTBaseFedJob(\n",
"job = PTJob(\n",
" name=\"cifar10_pt_fedavg\",\n",
" initial_model=Net(),\n",
")"
Expand Down
8 changes: 4 additions & 4 deletions examples/getting_started/tf/nvflare_tf_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
"#### 2. Define a FedJob\n",
"The `FedJob` is used to define how controllers and executors are placed within a federated job using the `to(object, target)` routine.\n",
"\n",
"Here we use a TensorFlow `TFBaseFedJob`, where we can define the job name and the initial global model.\n",
"The `TFBaseFedJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
"Here we use a TensorFlow `TFJob`, where we can define the job name and the initial global model.\n",
"The `TFJob` automatically configures components for model persistence, model selection, and TensorBoard streaming for convenience."
]
},
{
Expand All @@ -267,10 +267,10 @@
"from src.tf_net import TFNet\n",
"\n",
"from nvflare.app_common.workflows.fedavg import FedAvg\n",
"from nvflare.app_opt.tf.job_config.base_fed_job import TFBaseFedJob\n",
"from nvflare.app_opt.tf.job_config.tf_job import TFJob\n",
"from nvflare.job_config.script_runner import FrameworkType, ScriptRunner\n",
"\n",
"job = TFBaseFedJob(\n",
"job = TFJob(\n",
" name=\"cifar10_tf_fedavg\",\n",
" initial_model=TFNet(),\n",
")"
Expand Down
4 changes: 2 additions & 2 deletions nvflare/app_opt/pt/job_config/fed_avg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import torch.nn as nn

from nvflare.app_common.workflows.fedavg import FedAvg
from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob
from nvflare.app_opt.pt.job_config.pt_job import PTJob


class FedAvgJob(PTBaseFedJob):
class FedAvgJob(PTJob):
def __init__(
self,
initial_model: nn.Module,
Expand Down
4 changes: 2 additions & 2 deletions nvflare/app_opt/pt/job_config/fed_sag_mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from nvflare.app_common.aggregators import InTimeAccumulateWeightedAggregator
from nvflare.app_common.shareablegenerators import FullModelShareableGenerator
from nvflare.app_common.workflows.scatter_and_gather import ScatterAndGather
from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob
from nvflare.app_opt.pt.job_config.pt_job import PTJob
from nvflare.app_opt.tracking.mlflow.mlflow_receiver import MLflowReceiver
from nvflare.app_opt.tracking.mlflow.mlflow_writer import MLflowWriter


class SAGMLFlowJob(PTBaseFedJob):
class SAGMLFlowJob(PTJob):
def __init__(
self,
initial_model: nn.Module,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from nvflare.app_opt.pt.job_config.model import PTModel
from nvflare.app_opt.tracking.tb.tb_receiver import TBAnalyticsReceiver
from nvflare.job_config.api import validate_object_for_job
from nvflare.job_config.base_fed_job import BaseFedJob
from nvflare.job_config.common_job import CommonJob


class PTBaseFedJob(BaseFedJob):
class PTJob(CommonJob):
def __init__(
self,
initial_model: nn.Module = None,
Expand All @@ -43,7 +43,7 @@ def __init__(
model_persistor: Optional[ModelPersistor] = None,
model_locator: Optional[ModelLocator] = None,
):
"""PyTorch BaseFedJob.
"""PyTorch CommonJob.
Configures ValidationJsonGenerator, IntimeModelSelector, AnalyticsReceiver, ConvertToFedEvent.
Expand Down
4 changes: 2 additions & 2 deletions nvflare/app_opt/tf/job_config/fed_avg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import tensorflow as tf

from nvflare.app_common.workflows.fedavg import FedAvg
from nvflare.app_opt.tf.job_config.base_fed_job import TFBaseFedJob
from nvflare.app_opt.tf.job_config.tf_job import TFJob


class FedAvgJob(TFBaseFedJob):
class FedAvgJob(TFJob):
def __init__(
self,
initial_model: tf.keras.Model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from nvflare.app_opt.tf.job_config.model import TFModel
from nvflare.app_opt.tracking.tb.tb_receiver import TBAnalyticsReceiver
from nvflare.job_config.api import validate_object_for_job
from nvflare.job_config.base_fed_job import BaseFedJob
from nvflare.job_config.common_job import CommonJob


class TFBaseFedJob(BaseFedJob):
class TFJob(CommonJob):
def __init__(
self,
initial_model: tf.keras.Model = None,
Expand All @@ -41,7 +41,7 @@ def __init__(
analytics_receiver: Optional[AnalyticsReceiver] = None,
model_persistor: Optional[ModelPersistor] = None,
):
"""TensorFlow BaseFedJob.
"""TensorFlow CommonJob.
Configures ValidationJsonGenerator, IntimeModelSelector, TBAnalyticsReceiver, ConvertToFedEvent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from nvflare.job_config.api import FedJob, validate_object_for_job


class BaseFedJob(FedJob):
class CommonJob(FedJob):
def __init__(
self,
name: str = "fed_job",
Expand All @@ -38,7 +38,7 @@ def __init__(
model_persistor: Optional[ModelPersistor] = None,
model_locator: Optional[ModelLocator] = None,
):
"""BaseFedJob.
"""CommonJob.
By default configures ValidationJsonGenerator, IntimeModelSelector, ConvertToFedEvent.
Expand Down
24 changes: 12 additions & 12 deletions web/src/components/code.astro
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ const jobCode_pt = `
from cifar10_pt_fl import Net
from nvflare.app_common.workflows.fedavg import FedAvg
from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob
from nvflare.app_opt.pt.job_config.pt_job import PTJob
from nvflare.job_config.script_runner import ScriptRunner
if __name__ == "__main__":
n_clients = 2
num_rounds = 2
train_script = "cifar10_pt_fl.py"
# Create PTBaseFedJob with initial model
job = PTBaseFedJob(
# Create PTJob with initial model
job = PTJob(
name="cifar10_pt_fedavg",
initial_model=Net(),
)
Expand Down Expand Up @@ -425,16 +425,16 @@ const jobCode_lt = `
from cifar10_lightning_fl import LitNet
from nvflare.app_common.workflows.fedavg import FedAvg
from nvflare.app_opt.pt.job_config.base_fed_job import PTBaseFedJob
from nvflare.app_opt.pt.job_config.pt_job import PTJob
from nvflare.job_config.script_runner import ScriptRunner
if __name__ == "__main__":
n_clients = 2
num_rounds = 2
train_script = "cifar10_lightning_fl.py"
# Create PTBaseFedJob with initial model
job = PTBaseFedJob(
# Create PTJob with initial model
job = PTJob(
name="cifar10_lightning_fedavg",
initial_model=LitNet(),
)
Expand Down Expand Up @@ -587,16 +587,16 @@ const jobCode_tf = `
from cifar10_tf_fl import TFNet
from nvflare.app_common.workflows.fedavg import FedAvg
from nvflare.app_opt.tf.job_config.base_fed_job import TFBaseFedJob
from nvflare.app_opt.tf.job_config.tf_job import TFJob
from nvflare.job_config.script_runner import FrameworkType, ScriptRunner
if __name__ == "__main__":
n_clients = 2
num_rounds = 2
train_script = "cifar10_tf_fl.py"
# Create TFBaseFedJob with initial model
job = TFBaseFedJob(
# Create TFJob with initial model
job = TFJob(
name="cifar10_tf_fedavg",
initial_model=TFNet(input_shape=(None, 32, 32, 3)),
)
Expand Down Expand Up @@ -665,7 +665,7 @@ const frameworks = [
framework: "pytorch",
title: "Job Code (fedavg_cifar10_pt_job.py)",
description:
"Lastly we construct the job with our 'cifar10_pt_fl.py' client script and 'FedAvg' server controller. The PTBaseFedJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
"Lastly we construct the job with our 'cifar10_pt_fl.py' client script and 'FedAvg' server controller. The PTJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
code: jobCode_pt,
},
{
Expand Down Expand Up @@ -719,7 +719,7 @@ const frameworks = [
framework: "lightning",
title: "Job Code (fedavg_cifar10_lightning_job.py)",
description:
"Lastly we construct the job with our 'cifar10_lightning_fl.py' client script and 'FedAvg' server controller. The PTBaseFedJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
"Lastly we construct the job with our 'cifar10_lightning_fl.py' client script and 'FedAvg' server controller. The PTJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
code: jobCode_lt,
},
{
Expand Down Expand Up @@ -773,7 +773,7 @@ const frameworks = [
framework: "tensorflow",
title: "Job Code (fedavg_cifar10_tf_job.py)",
description:
"Lastly we construct the job with our 'cifar10_tf_fl.py' client script and 'FedAvg' server controller. The TFBaseFedJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
"Lastly we construct the job with our 'cifar10_tf_fl.py' client script and 'FedAvg' server controller. The TFJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
code: jobCode_tf,
},
{
Expand Down

0 comments on commit 2a8826f

Please sign in to comment.