Skip to content

Commit

Permalink
Multiple updates
Browse files Browse the repository at this point in the history
🌈 style(code): Format by `black`

✨(method): New method: FedFed

🐳 chore(image): Optimize `docker-publish` workflow & Add `tensorboard` port in EXPOSE in Dockerfile

🎈 perf(metrics): Remove try-catch in loss calculation

πŸ“ƒ docs(readme): Optimize README

πŸ¦„ refactor(models): Make `feature_length` for some classes static

πŸ¦„ refactor(func): Refactor `exec()` of `FLBenchTrainer()`
  • Loading branch information
KarhouTam committed May 22, 2024
1 parent 3b7d958 commit 618bf91
Show file tree
Hide file tree
Showing 11 changed files with 709 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ RUN pip install --upgrade pip && \
pip install -r /tmp/requirements.txt


# port for visdom
EXPOSE 8097 8265
# visdom ray-dashboard tensorboard
EXPOSE 8097 8265 6006
110 changes: 82 additions & 28 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,126 @@
name: Docker-Publish
name: Docker Image Publish

on:
push:
paths:
- '.environment/**'
- '.github/workflows/docker-publish.yml'

- ".environment/**"
- ".github/workflows/docker-publish.yml"

env:
IMAGE_LOWERCASE_NAME: fl-bench
IMAGE_LOWERCASE_OWNER: karhoutam
GITHUB_REGISTRY: ghcr.io
ALIYUN_REGISTRY: registry.cn-hangzhou.aliyuncs.com
DOCKERHUB_REGISTRY: docker.io
IMAGE_TAG: master

jobs:
build:
build-image:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .environment/Dockerfile
push: false
tags: |
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.ALIYUN_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
cache-to: type=gha,mode=max

push-ghcr:
name: Push to ghcr
needs: build-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Set Lowercase Variables
run: |
echo "IMAGE_LOWERCASE_OWNER=$(echo ${{ github.actor }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "IMAGE_LOWERCASE_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
# https://github.com/docker/setup-buildx-action

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/docker/login-action

- name: Log into ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into Docker Hub
if: github.event_name != 'pull_request'

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .environment/Dockerfile
push: true
tags: |
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
push-dockerhub:
name: Push to dockerhub
needs: build-image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKERHUB_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log into Aliyun
if: github.event_name != 'pull_request'

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .environment/Dockerfile
push: true
tags: |
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=gha

push-aliyun:
name: Push to aliyun
needs: build-image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.ALIYUN_REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_TOKEN }}
# https://github.com/docker/build-push-action

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .environment/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
build-args: |
REPO_PATH=.
REPO_NAME=${{ github.event.repository.name }}
push: true
tags: |
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.ALIYUN_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_LOWERCASE_OWNER }}/${{ env.IMAGE_LOWERCASE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Having Fun with Federated Learning.
- ***FedOpt*** -- [Adaptive Federated Optimization](https://arxiv.org/abs/2003.00295) (ICLR'21)

- ***Elastic Aggregation*** -- [Elastic Aggregation for Federated Optimization](https://openaccess.thecvf.com/content/CVPR2023/html/Chen_Elastic_Aggregation_for_Federated_Optimization_CVPR_2023_paper.html) (CVPR'23)

- ***FedFed*** -- [FedFed: Feature Distillation against Data Heterogeneity in Federated Learning](http://arxiv.org/abs/2310.05077) (NIPS'23)
</details>

<details>
Expand Down Expand Up @@ -239,22 +241,22 @@ parallel:
```
### Manually Create `Ray` Cluster (Optional)
A `Ray` cluster would be created implicitly everytime you run experiment in parallel mode.
Or you can create it manually to avoid creating and destroying cluster every time you run experiment.
Or you can create it manually by the command shown below to avoid creating and destroying cluster every time you run experiment.
```shell
ray start --head [OPTIONS]
```
πŸ‘€ **NOTE:** You need to keep `num_cpus: null` and `num_gpus: null` in your config file for connecting to a existing `Ray` cluster.
```yaml
# your_config_file.yml
# Connect to an existing Ray cluster in localhost.
mode: parallel
parallel:
ray_cluster_addr: null
...
num_gpus: null
num_cpus: null
...
...
```
```shell
ray start --head [OPTIONS]
```
πŸ‘€ **NOTE:** You need to keep `num_cpus: null` and `num_gpus: null` in your config file for connecting to a existing `Ray` cluster.




Expand Down
Loading

0 comments on commit 618bf91

Please sign in to comment.