Skip to content

Commit f104f17

Browse files
authored
Changes in PQ Pipeline & Publish Package workflows for PYPI_API_TOKEN (securefederatedai#1520)
* Added dev environment Signed-off-by: noopur <noopur@intel.com> * Added dev environment Signed-off-by: noopur <noopur@intel.com> * Do not continue on error Signed-off-by: noopur <noopur@intel.com> * Added permission for token read write Signed-off-by: noopur <noopur@intel.com> * Use shell commands Signed-off-by: noopur <noopur@intel.com> * Testing Signed-off-by: noopur <noopur@intel.com> * Testing Signed-off-by: noopur <noopur@intel.com> * Final changes Signed-off-by: noopur <noopur@intel.com> * Changes in PQ pipeline as well Signed-off-by: noopur <noopur@intel.com> * Comment out jobs fopr quick testing Signed-off-by: noopur <noopur@intel.com> * Modified Signed-off-by: noopur <noopur@intel.com> * Modified Signed-off-by: noopur <noopur@intel.com> * Modified Signed-off-by: noopur <noopur@intel.com> * Pass on token Signed-off-by: noopur <noopur@intel.com> * Inherit secret Signed-off-by: noopur <noopur@intel.com> * Do not pass env from called wf Signed-off-by: noopur <noopur@intel.com> * Do not pass env from called wf Signed-off-by: noopur <noopur@intel.com> * Revert the testing changes Signed-off-by: noopur <noopur@intel.com> * Renmote printing job Signed-off-by: noopur <noopur@intel.com> * Run publish step for manual trigger as well Signed-off-by: noopur <noopur@intel.com> * Ignore case for Aggregated model validation score Signed-off-by: noopur <noopur@intel.com> * Read 10 lines Signed-off-by: noopur <noopur@intel.com> * For trusted publishing Signed-off-by: noopur <noopur@intel.com> * Revert previous change Signed-off-by: noopur <noopur@intel.com> * Search string in lowercase Signed-off-by: noopur <noopur@intel.com> * Review comments incorp Signed-off-by: noopur <noopur@intel.com> --------- Signed-off-by: noopur <noopur@intel.com>
1 parent 1c17e0b commit f104f17

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

.github/workflows/pq_pipeline.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ jobs:
178178
# publish nightly package to PyPI (only run on schedule)
179179
publish_package:
180180
if: |
181-
(github.event_name == 'schedule' && github.repository_owner == 'securefederatedai')
181+
(github.event_name == 'schedule' && github.repository_owner == 'securefederatedai') ||
182+
(github.event_name == 'workflow_dispatch')
182183
name: Publish Nightly Package to PyPI
184+
permissions:
185+
id-token: write
183186
needs: [
184187
wf_mnist_local_runtime,
185188
wf_watermark_e2e,
@@ -198,3 +201,4 @@ jobs:
198201
uses: ./.github/workflows/publish_nightly_package.yml
199202
with:
200203
commit_id: ${{ needs.set_commit_id_for_all_jobs.outputs.commit_id }}
204+
secrets: inherit

.github/workflows/publish_nightly_package.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
commit_id:
1010
required: false
1111
type: string
12+
secrets:
13+
PYPI_API_TOKEN:
14+
required: true
1215
workflow_dispatch:
1316
inputs:
1417
commit_id:
@@ -19,14 +22,17 @@ on:
1922
env:
2023
COMMIT_ID: ${{ inputs.commit_id || github.sha }} # use commit_id from the calling workflow
2124

25+
permissions:
26+
id-token: write
27+
2228
jobs:
2329
publish_package:
2430
name: Publish Nightly Package
2531
runs-on: ubuntu-22.04
32+
environment: dev
2633
if: |
2734
(github.event_name == 'schedule' && github.repository_owner == 'securefederatedai') ||
28-
(github.event_name == 'workflow_dispatch') ||
29-
(github.event.pull_request.draft == false)
35+
(github.event_name == 'workflow_dispatch')
3036
steps:
3137
- name: Checkout OpenFL repository
3238
uses: actions/checkout@v4
@@ -45,14 +51,11 @@ jobs:
4551
4652
- name: Build package
4753
run: |
48-
python3 -m pip install --upgrade build
54+
python3 -m pip install setuptools wheel twine --upgrade build
4955
python3 -m build
56+
echo "Package built successfully!"
5057
51-
- name: Publish package
52-
uses: pypa/gh-action-pypi-publish@release/v1
53-
continue-on-error: true
54-
with:
55-
user: __token__
56-
password: ${{ secrets.PYPI_API_TOKEN }}
57-
repository-url: https://pypi.org/legacy/
58-
verbose: true
58+
- name: Upload package to PyPI
59+
run: |
60+
python3 -m twine upload dist/openfl_nightly* --verbose -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
61+
echo "Package published successfully!"

tests/end_to_end/utils/federation_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _verify_completion_for_participant(
338338
lines = [line.strip() for line in file.readlines()]
339339

340340
# Below change is done to handle warnings coming in end of runs
341-
content = list(filter(str.rstrip, lines))[-7:] if len(lines) >= 7 else lines
341+
content = list(filter(str.rstrip, lines))[-10:] if len(lines) >= 10 else lines
342342

343343
# Print last line of the log file on screen to track the progress
344344
log.info(f"Last line in {participant.name} log: {lines[-1:]}")
@@ -355,8 +355,6 @@ def _verify_completion_for_participant(
355355
log.info(f"Process completed for {participant.name}")
356356
break
357357

358-
time.sleep(45)
359-
360358
# If process.poll() has a value, it means the process has completed
361359
# If None, it means the process is still running
362360
# This is applicable for native process only
@@ -370,6 +368,8 @@ def _verify_completion_for_participant(
370368
# Dockerized workspace scenario
371369
log.info(f"No process found for participant {participant.name}")
372370

371+
time.sleep(45)
372+
373373
# Read tensor.db file for aggregator to check if the process is completed
374374
if participant.name == "aggregator" and num_rounds > 1:
375375
current_round = get_current_round(participant.tensor_db_file)

tests/end_to_end/utils/summary_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ def print_federated_runtime_score(nb_name):
190190
# Open and read the log file
191191
with open(dir_res_file, "r") as file:
192192
for line in file:
193-
if search_string in line:
193+
if search_string.lower() in line.lower():
194194
last_occurrence = line
195195

196196
# Extract the value from the last occurrence
197197
if last_occurrence:
198198
match = re.search(
199-
r"Aggregated model validation score = (\d+\.\d+)", last_occurrence
199+
r"Aggregated model validation score = (\d+\.\d+)", last_occurrence, re.IGNORECASE
200200
)
201201
if match:
202202
aggregated_model_score = match.group(1)

0 commit comments

Comments
 (0)