Skip to content

Commit

Permalink
FederatedRuntime Workflow for CI Pipeline - 301 Watermarking notebook…
Browse files Browse the repository at this point in the history
… run (#1267)

* FederatedRuntime Workflow for CI Pipeline - 301 Watermarking notebook run

Signed-off-by: noopur <[email protected]>

* Display output on screen

Signed-off-by: noopur <[email protected]>

* 5 Rounds

Signed-off-by: noopur <[email protected]>

* Removed extra ) bracket

Signed-off-by: noopur <[email protected]>

* Timeout of 30 min due to 5 rounds

Signed-off-by: noopur <[email protected]>

* End the loop after all rounds

Signed-off-by: noopur <[email protected]>

* Review comments incor

Signed-off-by: noopur <[email protected]>

* Retry the envoy fetch

Signed-off-by: noopur <[email protected]>

* Added invalid code just to verify negative scenario

Signed-off-by: noopur <[email protected]>

* Added invalid code just to verify negative scenario

Signed-off-by: noopur <[email protected]>

* 20m job timeout

Signed-off-by: noopur <[email protected]>

* Revert invalid code and stdout notebook run

Signed-off-by: noopur <[email protected]>

* Use markdown with stdout

Signed-off-by: noopur <[email protected]>

* Induced error for testing

Signed-off-by: noopur <[email protected]>

* Reverted error, added 10s sleep in github fetch logic

Signed-off-by: noopur <[email protected]>

* Code format check

Signed-off-by: noopur <[email protected]>

* pytest for the notebook

Signed-off-by: noopur <[email protected]>

* Pip install ipython ipykernel

Signed-off-by: noopur <[email protected]>

* Minor changes

Signed-off-by: noopur <[email protected]>

* Test summary step corrected for wf_functional_e2e workflow

Signed-off-by: noopur <[email protected]>

* 3 rounds instead of 5

Signed-off-by: noopur <[email protected]>

* Job name change

Signed-off-by: noopur <[email protected]>

* Review comments incorp

Signed-off-by: noopur <[email protected]>

* Increased timeout to 30m for CI pipeline jobs

Signed-off-by: noopur <[email protected]>

* Increased timeout to 30m for CI pipeline jobs

Signed-off-by: noopur <[email protected]>

---------

Signed-off-by: noopur <[email protected]>
  • Loading branch information
noopurintel authored Jan 16, 2025
1 parent 9658c03 commit b8e2c70
Show file tree
Hide file tree
Showing 28 changed files with 479 additions and 40 deletions.
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

0 comments on commit b8e2c70

Please sign in to comment.