-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into karansh1/callbacks_api
- Loading branch information
Showing
7 changed files
with
246 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,3 +230,70 @@ jobs: | |
with: | ||
name: tr_no_client_auth_${{ env.MODEL_NAME }}_python${{ env.PYTHON_VERSION }}_${{ github.run_id }} | ||
path: result.tar | ||
|
||
test_memory_logs: | ||
name: tr_tls_memory_logs | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 15 | ||
strategy: | ||
matrix: | ||
# Testing non TLS scenario only for torch_cnn_mnist model and python 3.10 | ||
# If required, this can be extended to other models and python versions | ||
model_name: ["torch_cnn_mnist"] | ||
python_version: ["3.10"] | ||
fail-fast: false # do not immediately fail if one of the combinations fail | ||
|
||
env: | ||
MODEL_NAME: ${{ matrix.model_name }} | ||
PYTHON_VERSION: ${{ matrix.python_version }} | ||
|
||
steps: | ||
- name: Checkout OpenFL repository | ||
id: checkout_openfl | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 2 # needed for detecting changes | ||
submodules: "true" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Python | ||
id: setup_python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install dependencies | ||
id: install_dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
pip install -r test-requirements.txt | ||
- name: Run Task Runner E2E tests without TLS | ||
id: run_tests | ||
run: | | ||
python -m pytest -s tests/end_to_end/test_suites/memory_logs_tests.py \ | ||
--model_name ${{ env.MODEL_NAME }} --num_rounds ${{ env.NUM_ROUNDS }} \ | ||
--num_collaborators ${{ env.NUM_COLLABORATORS }} --log_memory_usage | ||
echo "Task runner memory logs 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 | ||
echo "Test summary printed" | ||
- name: Tar files | ||
id: tar_files | ||
if: ${{ always() }} | ||
run: tar -cvf result.tar results | ||
|
||
- name: Upload Artifacts | ||
id: upload_artifacts | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ always() }} | ||
with: | ||
name: tr_tls_memory_logs_${{ env.MODEL_NAME }}_python${{ env.PYTHON_VERSION }}_${{ github.run_id }} | ||
path: result.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
"""Logs utilities.""" | ||
|
||
import json | ||
import logging | ||
|
||
from rich.console import Console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright 2020-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
import logging | ||
import os | ||
import json | ||
|
||
from tests.end_to_end.utils import federation_helper as fed_helper | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.log_memory_usage | ||
def test_log_memory_usage(request, fx_federation): | ||
""" | ||
This module contains end-to-end tests for logging memory usage in a federated learning setup. | ||
Test Suite: | ||
- test_log_memory_usage: Tests the memory usage logging functionality for the torch_cnn_mnist model. | ||
Functions: | ||
- test_log_memory_usage(request, fx_federation): | ||
Test the memory usage logging functionality in a federated learning setup. | ||
Parameters: | ||
- request: The pytest request object containing configuration options. | ||
- fx_federation: The fixture representing the federated learning setup. | ||
Steps: | ||
1. Skip the test if memory usage logging is disabled. | ||
2. Setup PKI for trusted communication if TLS is enabled. | ||
3. Start the federation and verify its completion. | ||
4. Verify the existence of memory usage logs for the aggregator. | ||
5. Verify the memory usage details for each round. | ||
6. Verify the existence and details of memory usage logs for each collaborator. | ||
7. Log the availability of memory usage details for all participants. | ||
""" | ||
# Skip test if fx_federation.log_memory_usage is False | ||
if not request.config.log_memory_usage: | ||
pytest.skip("Memory usage logging is disabled") | ||
|
||
# Setup PKI for trusted communication within the federation | ||
if request.config.use_tls: | ||
assert fed_helper.setup_pki(fx_federation), "Failed to setup PKI for trusted communication" | ||
|
||
# Start the federation | ||
results = fed_helper.run_federation(fx_federation) | ||
|
||
# Verify the completion of the federation run | ||
assert fed_helper.verify_federation_run_completion(fx_federation, results, \ | ||
num_rounds=request.config.num_rounds), "Federation completion failed" | ||
# Verify the aggregator memory logs | ||
aggregator_memory_usage_file = os.path.join(fx_federation.workspace_path, "logs", "aggregator_memory_usage.json") | ||
assert os.path.exists(aggregator_memory_usage_file), "Aggregator memory usage file is not available" | ||
|
||
# Log the aggregator memory usage details | ||
memory_usage_dict = json.load(open(aggregator_memory_usage_file)) | ||
|
||
# check memory usage entries for each round | ||
assert len(memory_usage_dict) == request.config.num_rounds, \ | ||
"Memory usage details are not available for all rounds" | ||
|
||
# check memory usage entries for each collaborator | ||
for collaborator in fx_federation.collaborators: | ||
collaborator_memory_usage_file = os.path.join(fx_federation.workspace_path, | ||
"logs", | ||
f"{collaborator.collaborator_name}_memory_usage.json") | ||
|
||
assert os.path.exists(collaborator_memory_usage_file), f"Memory usage file for collaborator {collaborator.collaborator_name} is not available" | ||
|
||
memory_usage_dict = json.load(open(collaborator_memory_usage_file)) | ||
|
||
assert len(memory_usage_dict) == request.config.num_rounds, \ | ||
f"Memory usage details are not available for all rounds for collaborator {collaborator.collaborator_name}" | ||
|
||
log.info("Memory usage details are available for all participants") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.