Skip to content

Commit

Permalink
Merge pull request #830 from FedML-AI/dev/v0.7.0
Browse files Browse the repository at this point in the history
update to v0.8.0
  • Loading branch information
fedml-alex authored Mar 23, 2023
2 parents fc779bf + b17717b commit 85e3729
Show file tree
Hide file tree
Showing 60 changed files with 1,947 additions and 1,375 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Here `hierarchical` means that inside each FL Client (data silo), there are mult

## **FedML Beehive Examples**

- [Federated Learning on Android Smartphones](./doc/en/cross-device/examples/mqtt_s3_fedavg_mnist_lr_example.md)
- [Federated Learning on Android Smartphones](./doc/en/cross-device/examples/cross_device_android_example.md)


# FedML on Smartphone and IoTs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void registerMessageReceiveHandlers(final long edgeId) {
edgeCommunicator.subscribe(startTrainTopic, (OnTrainStartListener) this::handleTrainStart);
final String stopTrainTopic = "flserver_agent/" + edgeId + "/stop_train";
edgeCommunicator.subscribe(stopTrainTopic, (OnTrainStopListener) this::handleTrainStop);
final String MLOpsQueryStatusTopic = "/mlops/report_device_status";
final String MLOpsQueryStatusTopic = "mlops/report_device_status";
edgeCommunicator.subscribe(MLOpsQueryStatusTopic, (OnMLOpsMsgListener) this::handleMLOpsMsg);

final String exitTrainWithExceptionTopic = "flserver_agent/" + edgeId + "/exit_train_with_exception";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public interface MessageDefine {


// Client Status
String MQTT_LAST_WILL_TOPIC = "/flclient_agent/last_will_msg";
String MQTT_REPORT_ACTIVE_STATUS_TOPIC = "/flclient_agent/active";
String MQTT_LAST_WILL_TOPIC = "flclient_agent/last_will_msg";
String MQTT_REPORT_ACTIVE_STATUS_TOPIC = "flclient_agent/active";

String MSG_MLOPS_CLIENT_STATUS_OFFLINE = "OFFLINE";
String MSG_MLOPS_CLIENT_STATUS_IDLE = "IDLE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ai.fedml.edge.utils.LogHelper;

public class ProfilerEventLogger {
private static final String EVENT_TOPIC = "/mlops/events";
private static final String EVENT_TOPIC = "mlops/events";
private static final int EVENT_TYPE_STARTED = 0;
private static final int EVENT_TYPE_ENDED = 1;

Expand Down
16 changes: 8 additions & 8 deletions devops/k8s/README_MODEL_SERVING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This tutorial will guide you to deploy your models to target computing devices,

The entire workflow is as follows:
1. create a model card by uploading your trained model file and related configuration (YAML)
2. bind (login) computing resource to FedML MLOps model serving platform (https://model.fedml.ai)
2. bind (login) computing resource to FedML MLOps model serving platform (https://open.fedml.ai)
- Kubernetes mode
- CLI mode
3. start the deployment and get the inference API once the deployment is finished
Expand All @@ -14,7 +14,7 @@ When your model deployment is finished, you will get an endpoint URL and inferen

```curl -XPOST https://$YourEndPointIngressDomainName/inference/api/v1/predict -H 'accept: application/json' -d'{ "model_version": "v11-Thu Jan 05 08:20:24 GMT 2023", "model_name": "model_340_18_fedml_test_model_v11-Thu-Jan-05-08-20-24-GMT-2023", "data": "This is our test data. Please fill in here with your real data.", "end_point_id": 336, "model_id": 18, "token": "2e081ef115d04ee8adaffe5c1d0bfbac"}'```

You may run your model deployment flow via the ModelOps(model.fedml.ai) and CLI.
You may run your model deployment flow via the ModelOps(open.fedml.ai) and CLI.

Model Deployment CLI:

Expand All @@ -23,7 +23,7 @@ fedml model deploy -n $model_name --on_premise -d $device_id_list -u $user_id -k
e.g. fedml model deploy -n fedml_sample_model -u 1420 -k c9356b9c4ce44363bb66366b290201 -dt md.on_premise_device -d [178077,178076]
Note: You may find your device id in the Computing Resource page at the ModelOps(model.fedml.ai) platform.
Note: You may find your device id in the Computing Resource page at the ModelOps(open.fedml.ai) platform.
In the $device_id_list, the master device should be the first item.
```

Expand Down Expand Up @@ -62,15 +62,15 @@ Inference end point ingress will be used as your model serving endpoint URL whic
```kubectl get nodes --show-labels```

### 4). Prepare parameters will be used in the next step.
You should fetch $YourAccountId and $YourApiKey from ModelOps(model.fedml.ai) which will be used in the next step.
You should fetch $YourAccountId and $YourApiKey from ModelOps(open.fedml.ai) which will be used in the next step.

### 5). You may run the Helm Charts Installation commands to install FedML model serving packages to the above labeled nodes.

```kubectl create namespace $YourNameSpace```

```helm install --set env.fedmlAccountId="$YourAccountId" --set env.fedmlApiKey="$YourApiKey" --set env.fedmlVersion="release" fedml-model-premise-slave fedml-model-premise-slave-0.7.397.tgz -n $YourNameSpace```
```helm install --set env.fedmlAccountId="$YourAccountId" --set env.fedmlApiKey="$YourApiKey" --set env.fedmlVersion="release" fedml-model-premise-slave fedml-model-premise-slave-latest.tgz -n $YourNameSpace```

```helm install --set env.fedmlAccountId="$YourAccountId" --set env.fedmlApiKey="$YourApiKey" --set env.fedmlVersion="release" --set "inferenceGateway.ingress.host=$YourEndPointIngressDomainName" --set "inferenceGateway.ingress.className=nginx" fedml-model-premise-master fedml-model-premise-master-0.7.397.tgz -n $YourNameSpace```
```helm install --set env.fedmlAccountId="$YourAccountId" --set env.fedmlApiKey="$YourApiKey" --set env.fedmlVersion="release" --set "inferenceGateway.ingress.host=$YourEndPointIngressDomainName" --set "inferenceGateway.ingress.className=nginx" fedml-model-premise-master fedml-model-premise-master-latest.tgz -n $YourNameSpace```

Notes: $YourEndPointIngressDomainName is your model serving end point URL host which will be used in your inference API, e.g.

Expand Down Expand Up @@ -137,7 +137,7 @@ List model in the remote model repository:
Build local model repository as zip model package:
```fedml model package -n $model_name```

Push local model repository to ModelOps(model.fedml.ai):
Push local model repository to ModelOps(open.fedml.ai):
```fedml model push -n $model_name -u $user_id -k $user_api_key```

Pull remote model(ModelOps) to local model repository:
Expand All @@ -158,4 +158,4 @@ A: Yes.


4. Q: During deployment, what if the k8s service does not have a public IP? \
A: During deployment, we don't need to initiate access to your k8s service from model.fedml.ai, only your k8s cluster can initiate access to model.fedml.ai
A: During deployment, we don't need to initiate access to your k8s service from open.fedml.ai, only your k8s cluster can initiate access to open.fedml.ai
4 changes: 2 additions & 2 deletions devops/k8s/fedml-model-inference-ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: fedml-model-inference-ingress
description: A Helm chart for master on-premise device on FedML model serving platform(model.fedml.ai)
description: A Helm chart for master on-premise device on FedML model serving platform(open.fedml.ai)

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.377
version: 0.7.700

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions devops/k8s/fedml-model-inference-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ service:
ingress:
enabled: true
className: ""
annotations: {}
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/cors-allow-headers: '*'
ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS, HEAD, DELETE, PATCH'
Expand All @@ -59,7 +59,7 @@ ingress:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
# kubernetes.io/tls-acme: "true"
hosts:
- host: model.fedml.ai
- host: open.fedml.ai
paths:
- path: /inference
pathType: Prefix
Expand Down
Binary file removed devops/k8s/fedml-model-premise-master-0.7.397.tgz
Binary file not shown.
Binary file added devops/k8s/fedml-model-premise-master-latest.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions devops/k8s/fedml-model-premise-master/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: fedml-model-premise-master
description: A Helm chart for master on-premise device on FedML model serving platform(model.fedml.ai)
description: A Helm chart for master on-premise device on FedML model serving platform(open.fedml.ai)

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.397
version: 0.7.700

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions devops/k8s/fedml-model-premise-master/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ingress:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
# kubernetes.io/tls-acme: "true"
hosts:
- host: model.fedml.ai
- host: open.fedml.ai
paths:
- path: /
pathType: Prefix
Expand Down Expand Up @@ -146,7 +146,7 @@ inferenceGateway:
nginx.ingress.kubernetes.io/proxy-send-timeout: '6000'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
# kubernetes.io/tls-acme: "true"
host: model.fedml.ai
host: open.fedml.ai
protocol: https #http
tls: [ ]
# - secretName: chart-example-tls
Expand Down
Binary file removed devops/k8s/fedml-model-premise-slave-0.7.397.tgz
Binary file not shown.
Binary file added devops/k8s/fedml-model-premise-slave-latest.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions devops/k8s/fedml-model-premise-slave/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: fedml-model-premise-slave
description: A Helm chart for slave on-premise device on FedML model serving platform(model.fedml.ai)
description: A Helm chart for slave on-premise device on FedML model serving platform(open.fedml.ai)

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.397
version: 0.7.700

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ train_args:
client_id_list:
client_num_in_total: 1
client_num_per_round: 1
comm_round: 10
comm_round: 2
epochs: 1
batch_size: 10
client_optimizer: sgd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(self, input_dim, output_dim):
self.linear = torch.nn.Linear(input_dim, output_dim)

def forward(self, x):
import torch
outputs = torch.sigmoid(self.linear(x))
return outputs

Expand Down
2 changes: 1 addition & 1 deletion python/fedml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_global_training_type = None
_global_comm_backend = None

__version__ = "0.7.601"
__version__ = "0.8.0"


def init(args=None):
Expand Down
69 changes: 54 additions & 15 deletions python/fedml/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def device():
pass


@device.command("login", help="Login as model device agent(MDA) on the ModelOps platform (model.fedml.ai).")
@device.command("login", help="Login as model device agent(MDA) on the ModelOps platform (open.fedml.ai).")
@click.argument("userid", nargs=-1)
@click.option(
"--cloud", "-c", default=None, is_flag=True, help="login as fedml cloud device.",
Expand Down Expand Up @@ -834,7 +834,7 @@ def login_as_model_device_agent(
redis_addr, redis_port, redis_password)


@device.command("logout", help="Logout from the ModelOps platform (model.fedml.ai)")
@device.command("logout", help="Logout from the ModelOps platform (open.fedml.ai)")
@click.option(
"--slave", "-s", default=None, is_flag=True, help="logout from slave device.",
)
Expand Down Expand Up @@ -932,12 +932,19 @@ def list_models(name):
default="release",
help="interact with which version of ModelOps platform. It should be dev, test or release",
)
def list_remote_models(name, user, api_key, version):
@click.option(
"--local_server",
"-ls",
type=str,
default="127.0.0.1",
help="local server address.",
)
def list_remote_models(name, user, api_key, version, local_server):
if user is None or api_key is None:
click.echo("You must provide arguments for User Id and Api Key (use -u and -k options).")
return
FedMLModelCards.get_instance().set_config_version(version)
model_query_result = FedMLModelCards.get_instance().list_models(name, user, api_key)
model_query_result = FedMLModelCards.get_instance().list_models(name, user, api_key, local_server)
if model_query_result is None or model_query_result.model_list is None or len(model_query_result.model_list) <= 0:
click.echo("Model list is empty.")
else:
Expand All @@ -962,7 +969,7 @@ def package_model(name):
click.echo("Failed to build model {}.".format(name))


@model.command("push", help="Push local model repository to ModelOps(model.fedml.ai).")
@model.command("push", help="Push local model repository to ModelOps(open.fedml.ai).")
@click.option(
"--name", "-n", type=str, help="model name.",
)
Expand All @@ -985,15 +992,23 @@ def package_model(name):
default="release",
help="interact with which version of ModelOps platform. It should be dev, test or release",
)
def push_model(name, model_storage_url, model_net_url, user, api_key, version):
@click.option(
"--local_server",
"-ls",
type=str,
default="127.0.0.1",
help="local server address.",
)
def push_model(name, model_storage_url, model_net_url, user, api_key, version, local_server):
if user is None or api_key is None:
click.echo("You must provide arguments for User Id and Api Key (use -u and -k options).")
return
FedMLModelCards.get_instance().set_config_version(version)
model_is_from_open = True if model_storage_url is not None and model_storage_url != "" else False
model_storage_url, model_zip = FedMLModelCards.get_instance().push_model(name, user, api_key,
model_storage_url=model_storage_url,
model_net_url=model_net_url)
model_net_url=model_net_url,
local_server=local_server)
if model_is_from_open:
click.echo("Push model {} with model storage url {} successfully.".format(name, model_storage_url))
else:
Expand Down Expand Up @@ -1022,19 +1037,26 @@ def push_model(name, model_storage_url, model_net_url, user, api_key, version):
default="release",
help="interact with which version of ModelOps platform. It should be dev, test or release",
)
def pull_model(name, user, api_key, version):
@click.option(
"--local_server",
"-ls",
type=str,
default="127.0.0.1",
help="local server address.",
)
def pull_model(name, user, api_key, version, local_server):
if user is None or api_key is None:
click.echo("You must provide arguments for User Id and Api Key (use -u and -k options).")
return
FedMLModelCards.get_instance().set_config_version(version)
if FedMLModelCards.get_instance().pull_model(name, user, api_key):
if FedMLModelCards.get_instance().pull_model(name, user, api_key, local_server):
click.echo("Pull model {} successfully.".format(name))
else:
click.echo("Failed to pull model {}.".format(name))


@model.command("deploy",
help="Deploy specific model to ModelOps platform(model.fedml.ai) or just for local debugging deployment.")
help="Deploy specific model to ModelOps platform(open.fedml.ai) or just for local debugging deployment.")
@click.option(
"--name", "-n", type=str, help="model name.",
)
Expand Down Expand Up @@ -1063,11 +1085,19 @@ def pull_model(name, user, api_key, version):
default="release",
help="interact with which version of ModelOps platform. It should be dev, test or release",
)
@click.option(
"--local_server",
"-ls",
type=str,
default="127.0.0.1",
help="local server address.",
)
@click.option(
"--use_local_deployment", "-ld", default=None, is_flag=True,
help="deploy local model repository by sending MQTT message(just use for debugging).",
)
def deploy_model(name, on_premise, cloud, devices, user, api_key, params, version, use_local_deployment):
def deploy_model(name, on_premise, cloud, devices, user, api_key, params, version,
local_server, use_local_deployment):
if user is None or api_key is None:
click.echo("You must provide arguments for User Id and Api Key (use -u and -k options).")
return
Expand All @@ -1079,14 +1109,23 @@ def deploy_model(name, on_premise, cloud, devices, user, api_key, params, versio
if is_cloud and is_on_premise:
is_cloud = False

is_local_dev = use_local_deployment
if use_local_deployment is None:
is_local_dev = False

if is_on_premise:
device_type = "md.on_premise_device"
else:
device_type = "md.fedml_cloud_device"
FedMLModelCards.get_instance().set_config_version(version)
paramsDict = json.loads(params) # load config from Cli

params_dict = {}
if is_local_dev:
params_dict = json.loads(params) # load config from Cli

if FedMLModelCards.get_instance().deploy_model(name, device_type, devices, user, api_key,
paramsDict, use_local_deployment):
params_dict, use_local_deployment,
local_server):
click.echo("Deploy model {} successfully.".format(name))
else:
click.echo("Failed to deploy model {}.".format(name))
Expand All @@ -1100,7 +1139,7 @@ def inference():
pass


@inference.command("query", help="Query inference parameters for specific model from ModelOps platform(model.fedml.ai).")
@inference.command("query", help="Query inference parameters for specific model from ModelOps platform(open.fedml.ai).")
@click.option(
"--name", "-n", type=str, help="model name.",
)
Expand All @@ -1115,7 +1154,7 @@ def query_model_infer(name):
click.echo("Failed to query model {}.".format(name))


@inference.command("run", help="Run inference action for specific model from ModelOps platform(model.fedml.ai).")
@inference.command("run", help="Run inference action for specific model from ModelOps platform(open.fedml.ai).")
@click.option(
"--name", "-n", type=str, help="model name.",
)
Expand Down
Loading

0 comments on commit 85e3729

Please sign in to comment.