Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FederatedRuntime Workflow for CI Pipeline - 301 Watermarking notebook run #1267

Merged
merged 29 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fbf358a
FederatedRuntime Workflow for CI Pipeline - 301 Watermarking notebook…
noopurintel Jan 13, 2025
d1a9744
Display output on screen
noopurintel Jan 13, 2025
e7512e0
5 Rounds
noopurintel Jan 13, 2025
cb4dcbe
Removed extra ) bracket
noopurintel Jan 13, 2025
903ca3e
Timeout of 30 min due to 5 rounds
noopurintel Jan 13, 2025
d1f42e8
End the loop after all rounds
noopurintel Jan 13, 2025
024220c
Review comments incor
noopurintel Jan 15, 2025
49bfe5d
Merge branch 'develop' into develop
noopurintel Jan 15, 2025
2865d67
Retry the envoy fetch
noopurintel Jan 15, 2025
4293de0
Added invalid code just to verify negative scenario
noopurintel Jan 15, 2025
60d4ff4
Added invalid code just to verify negative scenario
noopurintel Jan 15, 2025
c1d8106
20m job timeout
noopurintel Jan 15, 2025
6b64ff4
Revert invalid code and stdout notebook run
noopurintel Jan 15, 2025
9edbb2f
Use markdown with stdout
noopurintel Jan 15, 2025
eda05cf
Induced error for testing
noopurintel Jan 15, 2025
e9a2b37
Reverted error, added 10s sleep in github fetch logic
noopurintel Jan 15, 2025
cb14071
Code format check
noopurintel Jan 15, 2025
5a164da
pytest for the notebook
noopurintel Jan 15, 2025
487d6e5
Pip install ipython ipykernel
noopurintel Jan 15, 2025
dbe1d7b
Minor changes
noopurintel Jan 15, 2025
edd6c75
Test summary step corrected for wf_functional_e2e workflow
noopurintel Jan 15, 2025
3e3a52b
3 rounds instead of 5
noopurintel Jan 15, 2025
0eeb3e9
Merge branch 'develop' into develop
noopurintel Jan 15, 2025
299628f
Job name change
noopurintel Jan 16, 2025
ebe0a7b
Merge branch 'develop' into develop
noopurintel Jan 16, 2025
69b1d1a
Review comments incorp
noopurintel Jan 16, 2025
55eaa1c
Increased timeout to 30m for CI pipeline jobs
noopurintel Jan 16, 2025
c4529c8
Increased timeout to 30m for CI pipeline jobs
noopurintel Jan 16, 2025
ff862bf
Merge branch 'develop' into develop
noopurintel Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/tr_post_test_run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
if: ${{ always() }}
run: |
export PYTHONPATH="$PYTHONPATH:."
python tests/end_to_end/utils/summary_helper.py
python tests/end_to_end/utils/summary_helper.py --func_name "print_task_runner_score"
echo "Test summary printed"
shell: bash

Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/federated_runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#---------------------------------------------------------------------------
# Workflow to run 301_MNIST_Watermarking notebook
# Authors - Noopur, Payal Chaurasiya
#---------------------------------------------------------------------------
name: Federated Runtime 301 MNIST Watermarking

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

workflow_dispatch:

permissions:
contents: read

jobs:
test_federated_runtime_301_watermarking_notebook:
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Checkout OpenFL repository
uses: actions/[email protected]
with:
fetch-depth: 2 # needed for detecting changes
submodules: "true"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies # Without this step, fx command will not work
id: install_dependencies
run: |
python -m pip install --upgrade pip ipython ipykernel
pip install .
pip install -r test-requirements.txt

- name: Run Federated Runtime 301 MNIST Watermarking via pytest
id: run_tests
run: |
python -m pytest -s tests/end_to_end/test_suites/wf_federated_runtime_tests.py -k test_federated_runtime_301_watermarking
echo "Federated Runtime 301 MNIST Watermarking test run completed"

- name: Print test summary
id: print_test_summary
if: ${{ always() }}
run: |
export PYTHONPATH="$PYTHONPATH:."
python tests/end_to_end/utils/summary_helper.py --func_name "print_federated_runtime_score"
echo "Test summary printed"

- name: Tar files
if: ${{ always() }} # collect artifacts regardless of failures
run: |
tar -cvf notebook_301.tar --exclude="__pycache__" $HOME/results --ignore-failed-read
echo "TAR file created"

- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{ always() }} # collect artifacts regardless of failures
with:
name: federated_runtime_301_watermarking_${{ github.run_id }}
path: notebook_301.tar
2 changes: 1 addition & 1 deletion .github/workflows/straggler-handling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
timeout-minutes: 15
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/task_runner_basic_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
test_with_tls:
name: tr_tls
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
strategy:
matrix:
# There are open issues for some of the models, so excluding them for now:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
test_with_non_tls:
name: tr_non_tls
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
strategy:
matrix:
# Testing non TLS scenario only for torch_cnn_mnist model and python 3.10
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
test_with_no_client_auth:
name: tr_no_client_auth
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
strategy:
matrix:
# Testing non TLS scenario only for torch_cnn_mnist model and python 3.10
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
test_memory_logs:
name: tr_tls_memory_logs
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
strategy:
matrix:
# Testing non TLS scenario only for torch_cnn_mnist model and python 3.10
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/taskrunner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wf_functional_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ env:
NUM_COLLABORATORS: ${{ github.event.inputs.num_collaborators || '2' }}

jobs:
test_wf_func:
test_wf_functional_local_runtime:
if: github.event.pull_request.draft == false
name: wf_func
name: wf_functional_local_runtime
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
if: ${{ always() }}
run: |
export PYTHONPATH="$PYTHONPATH:."
python tests/end_to_end/utils/summary_helper.py
python tests/end_to_end/utils/summary_helper.py --func_name "print_local_runtime_score"
echo "Test summary printed"
- name: Create Tar (exclude cert and data folders)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_interface_101_mnist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run_notebook:
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
steps:
- name: Checkout OpenFL repository
uses: actions/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "d79eacbd",
"metadata": {},
"outputs": [],
Expand All @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "f7475cba",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -95,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "9bd8ac2d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -193,7 +193,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "89cf4866",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -245,7 +245,7 @@
" watermark_pretrain_optimizer=None,\n",
" watermark_retrain_optimizer=None,\n",
" round_number=0,\n",
" n_rounds=1,\n",
" n_rounds=3,\n",
" **kwargs,\n",
" ):\n",
" super().__init__(**kwargs)\n",
Expand Down Expand Up @@ -425,7 +425,20 @@
" + f\" Acc: {self.watermark_retrain_validation_score:<.6f}\")\n",
" retrain_round += 1\n",
"\n",
" self.next(self.end)\n",
" self.next(self.internal_loop)\n",
" \n",
" @aggregator\n",
" def internal_loop(self):\n",
" \"\"\"\n",
" Internal loop to continue the Federated Learning process.\n",
" \"\"\"\n",
" if self.round_number == self.n_rounds - 1:\n",
" print(f\"\\nCompleted training for all {self.n_rounds} round(s)\")\n",
" self.next(self.end)\n",
" else:\n",
" self.round_number += 1\n",
" print(f\"\\nCompleted round: {self.round_number}\")\n",
" self.next(self.aggregated_model_validation, foreach='collaborators')\n",
"\n",
" @aggregator\n",
" def end(self):\n",
Expand All @@ -449,7 +462,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "1715a373",
"metadata": {},
"outputs": [],
Expand All @@ -468,7 +481,7 @@
"federated_runtime = FederatedRuntime(\n",
" collaborators=authorized_collaborators,\n",
" director=director_info, \n",
" notebook_path='./MNIST_Watermarking.ipynb'\n",
" notebook_path='./MNIST_Watermarking.ipynb',\n",
")"
]
},
Expand Down Expand Up @@ -552,7 +565,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "fed_run",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -566,7 +579,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
13 changes: 11 additions & 2 deletions openfl/experimental/workflow/runtime/federated_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ def get_flow_state(self) -> Tuple[bool, Any]:

return status, flow_object

def get_envoys(self) -> None:
"""Prints the status of Envoys in a formatted way."""
def get_envoys(self) -> List[str]:
"""
Prints the status of Envoys in a formatted way.
Returns:
online_envoys (List[str]): List of online envoys.
"""
# Fetch envoy data
envoys = self._dir_client.get_envoys()
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
Expand All @@ -204,6 +208,7 @@ def get_envoys(self) -> None:
headers = ["Name", "Online", "Last Updated", "Experiment Running", "Experiment Name"]
# Prepare the table rows
rows = []
online_envoys = []
for envoy in envoys.envoy_infos:
rows.append(
[
Expand All @@ -214,11 +219,15 @@ def get_envoys(self) -> None:
envoy.experiment_name if envoy.experiment_name else "None",
]
)
if envoy.is_online:
online_envoys.append(envoy.envoy_name)

# Use tabulate to format the table
result = tabulate(rows, headers=headers, tablefmt="grid")
# Display the current timestamp
print(f"Status of Envoys connected to Federation at: {now}\n")
print(result)
return online_envoys

def stream_experiment_stdout(self, experiment_name) -> None:
"""Stream experiment stdout.
Expand Down
3 changes: 2 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pytest-asyncio==0.25.2
pytest-mock==3.14.0
defusedxml==0.7.1
matplotlib==3.10.0
fpdf==1.7.2
fpdf==1.7.2
papermill==2.6.0
1 change: 1 addition & 0 deletions tests/end_to_end/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ markers =
log_memory_usage: mark a test as a log memory usage test.
task_runner_basic: mark a test as a task runner basic test.
task_runner_dockerized_ws: mark a test as a task runner dockerized workspace test.
federated_runtime_301_watermarking: mark a test as a federated runtime 301 watermarking test.
asyncio_mode=auto
asyncio_default_fixture_loop_scope="function"
Loading
Loading