Skip to content

Commit 6cd1816

Browse files
Update cc provision (#3719)
Fix several bugs and add enhancements. ### Description Changes: - Remove using of pre-install and just build a docker image workload with custom code inside - Move startup_kit outside of CVM image and then use @IsaacYangSLA 's verify_startup_kit method - Undo changes to pre-install tool - Move the update of logging config (to /applog) from Packager to Builder so it can be signed by "SignatureBuilder" - Move "SignatureBuilder" to the last item of "project.yml" to sign all contents ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Quick tests passed locally by running `./runtest.sh`. - [ ] In-line docstrings updated. - [ ] Documentation updated.
1 parent 26ea200 commit 6cd1816

File tree

17 files changed

+71
-72
lines changed

17 files changed

+71
-72
lines changed

examples/advanced/cc_provision/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ builders:
6565
- path: nvflare.lighter.cc_provision.impl.cc.CCBuilder
6666
```
6767

68+
Note that this CCBuilder needs to be placed **after** the "StaticFileBuilder" and
69+
**before** the "SignatureBuilder".
6870
This builder sets up all CC-related configurations and assets.
6971

7072
## 4. Add the OnPremPackager

examples/advanced/cc_provision/cc_server1.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ cc_issuers:
2121
- id: snp_authorizer
2222
path: nvflare.app_opt.confidential_computing.snp_authorizer.SNPAuthorizer
2323
token_expiration: 100 # seconds, needs to be less than check_frequency
24-
snpguest_binary: "/host/bin/snpguest"
24+
args:
25+
snpguest_binary: "/host/bin/snpguest"
2526

2627
cc_attestation:
2728
check_frequency: 120 # seconds

examples/advanced/cc_provision/cc_site-1.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ cc_issuers:
2424
- id: snp_authorizer
2525
path: nvflare.app_opt.confidential_computing.snp_authorizer.SNPAuthorizer
2626
token_expiration: 100 # seconds, needs to be less than check_frequency
27-
snpguest_binary: "/host/bin/snpguest"
27+
args:
28+
snpguest_binary: "/host/bin/snpguest"
2829
- id: gpu_authorizer
2930
path: nvflare.app_opt.confidential_computing.gpu_authorizer.GPUAuthorizer
3031
token_expiration: 100 # seconds, needs to be less than check_frequency

examples/advanced/cc_provision/docker/Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ FROM ${BASE_IMAGE}
44

55
ENV PYTHONDONTWRITEBYTECODE=1
66
ENV PIP_NO_CACHE_DIR=1
7-
ENV PATH="/host/bin:${PATH}"
87

9-
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install zip
10-
RUN pip install -U pip
11-
RUN pip install git+https://github.com/NVIDIA/NVFlare.git@main
12-
COPY application_code.zip application_code.zip
13-
RUN nvflare pre-install install -a application_code.zip
8+
RUN pip install -U pip &&\
9+
pip install nvflare~=2.7.0rc
10+
COPY requirements.txt .
11+
RUN pip install -r requirements.txt
12+
COPY code/ /local/custom
1413

1514
ENTRYPOINT ["/user_config/nvflare/startup/sub_start.sh", "--verify"]
1615

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
This is a simple example to show how to build NVFlare docker image.
1+
## Overview
22

3+
This is a simple example to show how to build an application Docker image for NVFlare.
34

4-
# NVFlare application code package
5-
We can pre-install custom codes inside each docker image.
6-
We utilize our nvflare pre-install command to do that.
5+
### Prerequisites
76

8-
First, we need to prepare the `application_code.zip` folder structure:
7+
Before proceeding, ensure you have Docker installed and running on your machine. Additionally, make sure you have access to the required NVFlare code and resources.
98

10-
```bash
11-
application_code_folder
12-
├── application/ # optional
13-
│ └── <job_name>/
14-
│ ├── meta.json # job metadata
15-
│ ├── app_<site>/ # Site custom code
16-
│ └── custom/ # Site custom code
17-
├── application-share/ # Shared resources
18-
| └── simple_network.py # Shared model definition
19-
└── requirements.txt # Python dependencies (optional)
20-
```
9+
### Build the Docker Image
10+
11+
We have provided a `Dockerfile` to build the NVFlare Docker image.
2112

22-
We have already prepared application-share folder and requirements.txt in this example.
23-
We run the following command to create a zip folder so we can use that to build the CVM:
13+
To build the NVFlare Docker image, run the following command in your terminal:
2414

2515
```bash
26-
python -m zipfile -c application_code.zip application_code/*
16+
./docker_build.sh Dockerfile nvflare-site
2717
```
2818

29-
# NVFlare docker file
19+
Important notes:
20+
- Code directory: The local ``code`` folder is copied into the Docker image under ``/local/custom``
21+
- Job configuration: In the [job configuration](../jobs/hello-pt_cifar10_fedavg/app_site-1/config/config_fed_client.json) we configure the task script to be ``/local/custom/hello-pt_cifar10_fl.py``
3022

31-
We have prepared a `Dockerfile`.
32-
Please run the following command to build the NVFlare docker image:
33-
34-
```bash
35-
./docker_build.sh Dockerfile nvflare-site
36-
```
23+
Make sure to adjust the paths and filenames in your configurations accordingly.

examples/advanced/cc_provision/jobs/hello-pt_cifar10_fedavg/app_site-1/config/config_fed_client.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executor": {
99
"path": "nvflare.app_opt.pt.in_process_client_api_executor.PTInProcessClientAPIExecutor",
1010
"args": {
11-
"task_script_path": "/vault/packages/share/hello-pt_cifar10_fl.py"
11+
"task_script_path": "/local/custom/hello-pt_cifar10_fl.py"
1212
}
1313
}
1414
}

examples/advanced/cc_provision/project.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ builders:
5656
sp_end_point: server1:8002:8003
5757

5858
- path: nvflare.lighter.impl.cert.CertBuilder
59-
- path: nvflare.lighter.impl.signature.SignatureBuilder
6059
- path: nvflare.lighter.cc_provision.impl.cc.CCBuilder
61-
- path: nvflare.lighter.impl.docker_image_builder.DockerImageBuilder
62-
args:
63-
base_dockerfile: Dockerfile.base
64-
requirement: git+https://github.com/NVIDIA/NVFlare.git@main
60+
- path: nvflare.lighter.impl.signature.SignatureBuilder
6561
packager:
6662
path: nvflare.lighter.cc_provision.impl.onprem_packager.OnPremPackager
6763
args:

0 commit comments

Comments
 (0)