Skip to content

Commit bf51bb9

Browse files
Eyal-Danielidanielperezziguazio-cicd
authored
Cherry pick ci (#885)
* fix batch_inference_v2:infer() endpoint_id docstring (#880) * [Infra] Convert `mlrun/hub-assets` into a monorepo and adjust `functions` CI/CD (#881) * fix batch_inference_v2:infer() endpoint_id docstring * new structure * fix workflow * trigger function test * trigger function test * modify workflow to work on push event * modify workflow to work on push event * test if its a matter with the grep * fix the matrix creation step * mock the functions directoy (instead of with path we used) * correct the location of requirements.txt * correct the location of requirements.txt * upgrade mlrun version due to cython bug * remove dummy-category * re-structure cli * correct functions_cli path * ci.yaml fix attempt * ci.yaml fix attempt #2 * ci.yaml fix attempt #3 * align the fix to test-all workflow * fix command flag (long option must start with --) * one centralized cli directory * cli import path fix attempt * adjusting test-all to the new structure * investigate why there appears to be 0 passed tests * investigate why there appears to be 0 passed tests #2 * add a print to function name * fix attempt to functions discovery * fix describe_dask cython bug by upgrading the mlrun version * fix sklearn_calssifier cython bug by upgrading the mlrun version * fix cython bug by upgrading all mlrun versions to be >= 1.7.0 * Revert "fix cython bug by upgrading all mlrun versions to be >= 1.7.0" This reverts commit 61bcd26. * fix cython bug failures by upgrading mlrun versions to be >= 1.7.0 * delete logs * adds logs to debug describe_dask stuck test * adds flag to view logs to debug describe_dask stuck test * remove the debug prints * test workflow optimization trick * test workflow optimization trick (fix) * test workflow optimization trick (test-all) * test new matrix building method * test new matrix building method (identation fix) * test new matrix building method (another fix attempt) * test new matrix building method (another fix) * test new matrix building method (another fix attempt) * remove redundant logging * test new matrix building method also for test-all * invalidate the sklearn_classifier test * remove extra logging * invalidate test due to mlrun-varsion required update (no module named mlrun.mlrutils) * add dummy module test * add modules/README and dummy_module/item.yaml so the test will be identified * test build-marketplace new command * test build-marketplace new command (remove needs) * fix the project-root path (after moving helpers in utils sub-directory) * fix worng cli path * add print of temp_docs to inspect the module not found error * attempt to fix module not found by inserting their path to sys.path * attempt to fix module not found by inserting their path to sys.path #2 * test notebooks internal links fix * attempt to upload the result as artifact to github * another fix attempt to notebooks' broken links * another fix attempt to notebooks' broken links * test build-marketplace on modules * add assumed fields and files to dummy module for testing * fic dummy_module filename * check is the function.yaml exist before rendering it * READMEs auto-update * READMEs auto-update (add install requirements step) * chore(readme): auto-update asset tables [skip ci] * remove the old functions/readme section * replace the deprecated set-output command * remove the debug mode from the workflows * don't mention asset-types by name in the command * fix and modify the check for function.yaml file * remove todo * fixes + adapt to upcoming repo rename * add the branch to the trigger top test workflow * uncomment the conditions trigger top test workflow * revert the debug mode * remove the dummy module * remove todo * remove mlrun/functions mentions * post review fixes * revert debug mode * remove redundant character --------- Co-authored-by: iguazio-cicd <[email protected]> * Update test-all.yaml add workflow dispatch * chore(readme): auto-update asset tables [skip ci] * Create empty modules/src and add .DS_store files to .gitignore (#882) * fix batch_inference_v2:infer() endpoint_id docstring * new structure * fix workflow * trigger function test * trigger function test * modify workflow to work on push event * modify workflow to work on push event * test if its a matter with the grep * fix the matrix creation step * mock the functions directoy (instead of with path we used) * correct the location of requirements.txt * correct the location of requirements.txt * upgrade mlrun version due to cython bug * remove dummy-category * re-structure cli * correct functions_cli path * ci.yaml fix attempt * ci.yaml fix attempt #2 * ci.yaml fix attempt #3 * align the fix to test-all workflow * fix command flag (long option must start with --) * one centralized cli directory * cli import path fix attempt * adjusting test-all to the new structure * investigate why there appears to be 0 passed tests * investigate why there appears to be 0 passed tests #2 * add a print to function name * fix attempt to functions discovery * fix describe_dask cython bug by upgrading the mlrun version * fix sklearn_calssifier cython bug by upgrading the mlrun version * fix cython bug by upgrading all mlrun versions to be >= 1.7.0 * Revert "fix cython bug by upgrading all mlrun versions to be >= 1.7.0" This reverts commit 61bcd26. * fix cython bug failures by upgrading mlrun versions to be >= 1.7.0 * delete logs * adds logs to debug describe_dask stuck test * adds flag to view logs to debug describe_dask stuck test * remove the debug prints * test workflow optimization trick * test workflow optimization trick (fix) * test workflow optimization trick (test-all) * test new matrix building method * test new matrix building method (identation fix) * test new matrix building method (another fix attempt) * test new matrix building method (another fix) * test new matrix building method (another fix attempt) * remove redundant logging * test new matrix building method also for test-all * invalidate the sklearn_classifier test * remove extra logging * invalidate test due to mlrun-varsion required update (no module named mlrun.mlrutils) * add dummy module test * add modules/README and dummy_module/item.yaml so the test will be identified * test build-marketplace new command * test build-marketplace new command (remove needs) * fix the project-root path (after moving helpers in utils sub-directory) * fix worng cli path * add print of temp_docs to inspect the module not found error * attempt to fix module not found by inserting their path to sys.path * attempt to fix module not found by inserting their path to sys.path #2 * test notebooks internal links fix * attempt to upload the result as artifact to github * another fix attempt to notebooks' broken links * another fix attempt to notebooks' broken links * test build-marketplace on modules * add assumed fields and files to dummy module for testing * fic dummy_module filename * check is the function.yaml exist before rendering it * READMEs auto-update * READMEs auto-update (add install requirements step) * chore(readme): auto-update asset tables [skip ci] * remove the old functions/readme section * replace the deprecated set-output command * remove the debug mode from the workflows * don't mention asset-types by name in the command * fix and modify the check for function.yaml file * remove todo * fixes + adapt to upcoming repo rename * add the branch to the trigger top test workflow * uncomment the conditions trigger top test workflow * revert the debug mode * remove the dummy module * remove todo * remove mlrun/functions mentions * post review fixes * revert debug mode * remove redundant character * keep empty modules/src * remove unwanted changes from last commit * Delete .DS_Store * Delete modules/.DS_Store * Delete modules/src/.DS_Store * avoid including non-directories in the tests matrix * removed .ds_store files * skip testing if matrix is empty * skip testing if matrix is empty (#2) --------- Co-authored-by: iguazio-cicd <[email protected]> * Fix the workflows (#883) * fix batch_inference_v2:infer() endpoint_id docstring * new structure * fix workflow * trigger function test * trigger function test * modify workflow to work on push event * modify workflow to work on push event * test if its a matter with the grep * fix the matrix creation step * mock the functions directoy (instead of with path we used) * correct the location of requirements.txt * correct the location of requirements.txt * upgrade mlrun version due to cython bug * remove dummy-category * re-structure cli * correct functions_cli path * ci.yaml fix attempt * ci.yaml fix attempt #2 * ci.yaml fix attempt #3 * align the fix to test-all workflow * fix command flag (long option must start with --) * one centralized cli directory * cli import path fix attempt * adjusting test-all to the new structure * investigate why there appears to be 0 passed tests * investigate why there appears to be 0 passed tests #2 * add a print to function name * fix attempt to functions discovery * fix describe_dask cython bug by upgrading the mlrun version * fix sklearn_calssifier cython bug by upgrading the mlrun version * fix cython bug by upgrading all mlrun versions to be >= 1.7.0 * Revert "fix cython bug by upgrading all mlrun versions to be >= 1.7.0" This reverts commit 61bcd26. * fix cython bug failures by upgrading mlrun versions to be >= 1.7.0 * delete logs * adds logs to debug describe_dask stuck test * adds flag to view logs to debug describe_dask stuck test * remove the debug prints * test workflow optimization trick * test workflow optimization trick (fix) * test workflow optimization trick (test-all) * test new matrix building method * test new matrix building method (identation fix) * test new matrix building method (another fix attempt) * test new matrix building method (another fix) * test new matrix building method (another fix attempt) * remove redundant logging * test new matrix building method also for test-all * invalidate the sklearn_classifier test * remove extra logging * invalidate test due to mlrun-varsion required update (no module named mlrun.mlrutils) * add dummy module test * add modules/README and dummy_module/item.yaml so the test will be identified * test build-marketplace new command * test build-marketplace new command (remove needs) * fix the project-root path (after moving helpers in utils sub-directory) * fix worng cli path * add print of temp_docs to inspect the module not found error * attempt to fix module not found by inserting their path to sys.path * attempt to fix module not found by inserting their path to sys.path #2 * test notebooks internal links fix * attempt to upload the result as artifact to github * another fix attempt to notebooks' broken links * another fix attempt to notebooks' broken links * test build-marketplace on modules * add assumed fields and files to dummy module for testing * fic dummy_module filename * check is the function.yaml exist before rendering it * READMEs auto-update * READMEs auto-update (add install requirements step) * chore(readme): auto-update asset tables [skip ci] * remove the old functions/readme section * replace the deprecated set-output command * remove the debug mode from the workflows * don't mention asset-types by name in the command * fix and modify the check for function.yaml file * remove todo * fixes + adapt to upcoming repo rename * add the branch to the trigger top test workflow * uncomment the conditions trigger top test workflow * revert the debug mode * remove the dummy module * remove todo * remove mlrun/functions mentions * post review fixes * revert debug mode * remove redundant character * keep empty modules/src * remove unwanted changes from last commit * Delete .DS_Store * Delete modules/.DS_Store * Delete modules/src/.DS_Store * avoid including non-directories in the tests matrix * removed .ds_store files * skip testing if matrix is empty * skip testing if matrix is empty (#2) * debug why matrix is empty * debug why matrix is empty by removing filter step * debug why matrix is empty by removing filter step * rename changed-files to all-files to match this workflow * missing $ * extra checks to exclude the root from the matrix * extra checks to exclude the root from the matrix * debug the empty path by logging candidates * add grep to remove empty lines from json * align ci to the fix as well * align ci to the fix as well * align ci to the fix as well * align ci to the fix as well * reset to development and start again debug process * debug mode * grep to remove empty lined from metrix json * align ci.yaml to the fix and remove debug mode * new-line delimiter --------- Co-authored-by: iguazio-cicd <[email protected]> * fetch to dev --------- Co-authored-by: Daniel Perez <[email protected]> Co-authored-by: iguazio-cicd <[email protected]>
1 parent d83394b commit bf51bb9

File tree

248 files changed

+1130
-2277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+1130
-2277
lines changed

.github/workflows/ci.yaml

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test functions
1+
name: Test Assets
22
permissions:
33
contents: read
44
on:
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- name: Get the current branch name
1616
shell: bash
17-
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
17+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
1818
id: myref
1919

2020
- uses: actions/checkout@v3
@@ -34,14 +34,42 @@ jobs:
3434
# This is previous fetch command that stopped working (wile invetsigating added WA bello in run sectiong): git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
3535
# This is old git diff version: git diff ${{ github.base_ref }} --name-only | sed 's,/*[^/]\+/*$,,' | sort | uniq | grep -v '^\.' | sed 's/.*/"&"/' | sed '$!s/.*/&,/'
3636
# Based on instructions regarding https://docs.github.com/en/actions/learn-github-actions/contexts#github-context , github.base_ref triggers a workflow run is either pull_request or pull_request_target
37-
run: |
38-
git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }}:${{ github.base_ref }}
39-
matrix=$((
40-
echo '{ "package" : ['
41-
git diff ${{ github.base_ref }} --name-only | sed 's,/*[^/]\+/*$,,' | sort | uniq | grep -v '^\.' | sed 's/.*/"&"/' | sed '$!s/.*/&,/'
42-
echo " ]}"
43-
) | jq 'del(.[][] | select(. == ""))' -c)
44-
echo "::set-output name=matrix::$matrix"
37+
run: |
38+
echo "base ref: ${{ github.base_ref }}"
39+
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
40+
base_ref="origin/${{ github.base_ref }}"
41+
42+
echo "Diffing against $base_ref:"
43+
changed_files="$(git diff "$base_ref" --name-only || true)"
44+
45+
# Collect candidate package paths from diff
46+
candidates=$(
47+
printf '%s\n' "$changed_files" \
48+
| awk -F'/' '
49+
/^functions\/src\// {print $1"/"$2"/"$3}
50+
/^modules\/src\// {print $1"/"$2"/"$3}
51+
' \
52+
| sort -u
53+
)
54+
55+
# Keep only those that are actual directories
56+
packages=""
57+
for dir in $candidates; do
58+
if [[ -d "$dir" ]]; then
59+
packages+="$dir"$'\n'
60+
fi
61+
done
62+
63+
if [[ -z "$packages" ]]; then
64+
matrix_json='{"package":[]}'
65+
else
66+
matrix_json=$(printf '%s\n' "$packages" \
67+
| grep -v '^$' \
68+
| jq -R . \
69+
| jq -s '{package: .}' \
70+
| jq -c) # <-- compact
71+
fi
72+
echo "matrix=$matrix_json" >> "$GITHUB_OUTPUT"
4573
outputs:
4674
matrix: ${{ steps.set-matrix.outputs.matrix }}
4775

@@ -58,17 +86,17 @@ jobs:
5886
echo $matrix
5987
echo $matrix | jq .
6088
echo $matrix | json2yaml
89+
6190
run_monorepo_tests:
6291
needs: build_strategy_matrix
92+
if: needs.build_strategy_matrix.outputs.matrix != '{"package":[]}'
6393
runs-on: ubuntu-latest
6494
strategy:
6595
# matrix: [{"package": some package that changed}, {...}, ...]
6696
matrix: ${{fromJson(needs.build_strategy_matrix.outputs.matrix)}}
6797
steps:
6898
- name: Checkout current repo
6999
uses: actions/checkout@v3
70-
with:
71-
path: functions
72100
# Install python 3.10.17
73101
- name: Install python 3.10.17
74102
uses: actions/setup-python@v4
@@ -79,17 +107,17 @@ jobs:
79107
id: cache
80108
with:
81109
path: ~/.cache/pip
82-
key: ${{ runner.os }}-pip-${{ hashFiles('functions/requirements.txt') }}
110+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
83111
restore-keys: |
84112
${{ runner.os }}-pip-
85113
- name: Install requirements
86114
run: |
87115
pip install --upgrade pip
88-
pip install -r functions/requirements.txt
89-
90-
- name: Run py tests
91-
run: python functions/functions.py run-tests -r functions -s py -fn ${{ matrix.package }}
92-
93-
- name: Clean
116+
pip install -r requirements.txt
117+
- name: Print workspace structure
94118
run: |
95-
rm -rf functions
119+
echo "Current directory: $(pwd)"
120+
echo "Tree structure:"
121+
find . -type f | sort
122+
- name: Run py tests
123+
run: python -m cli.cli run-tests -r ${{ matrix.package }} -s py -fn $(basename "${{ matrix.package }}")

.github/workflows/test-all.yaml

Lines changed: 79 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
name: Test all functions, build marketplace
1+
name: Test all assets, build marketplace
22
permissions:
33
contents: read
44
on:
55
push:
66
branches:
77
- development
88
- master
9+
workflow_dispatch: {}
910

1011
jobs:
1112
build_strategy_matrix:
1213
runs-on: ubuntu-latest
1314
steps:
1415
- name: Get the current branch name
1516
shell: bash
16-
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
17+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
1718
id: myref
1819

1920
- uses: actions/checkout@v4
@@ -32,13 +33,31 @@ jobs:
3233
# 3) Save matrix JSON to output
3334
# This is old fetch command it cant work cause base_ref is only avaliable on pull request actions: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
3435
run: |
35-
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ steps.myref.outputs.branch }}:refs/remotes/origin/${{ steps.myref.outputs.branch }}
36-
matrix=$((
37-
echo '{ "package" : ['
38-
git ls-files *[^cli] | grep '/' | sort | uniq| sed 's,/*[^/]\+/*$,,' | sort | uniq | grep -v '^\.' | sed 's/.*/"&"/' | sed '$!s/.*/&,/'
39-
echo " ]}"
40-
) | jq -c .)
41-
echo "::set-output name=matrix::$matrix"
36+
all_files="$(git ls-files || true)"
37+
# Collect candidate package paths from diff
38+
candidates=$(
39+
printf '%s\n' "$all_files" \
40+
| awk -F'/' '
41+
/^functions\/src\// {print $1"/"$2"/"$3}
42+
/^modules\/src\// {print $1"/"$2"/"$3}
43+
' \
44+
| sort -u
45+
)
46+
47+
# Keep only those that are actual directories
48+
packages=""
49+
for dir in $candidates; do
50+
if [[ -d "$dir" ]]; then
51+
packages+="$dir"$'\n'
52+
fi
53+
done
54+
55+
if [[ -z "$packages" ]]; then
56+
matrix_json='{"package":[]}'
57+
else
58+
matrix_json=$(printf '%s\n' "$packages" | grep -v '^$' | jq -R . | jq -s '{package: .}' | jq -c)
59+
fi
60+
echo "matrix=$matrix_json" >> "$GITHUB_OUTPUT"
4261
outputs:
4362
matrix: ${{ steps.set-matrix.outputs.matrix }}
4463

@@ -55,6 +74,7 @@ jobs:
5574
echo $matrix
5675
echo $matrix | jq .
5776
echo $matrix | json2yaml
77+
5878
run_monorepo_tests:
5979
needs: build_strategy_matrix
6080
runs-on: ubuntu-latest
@@ -65,8 +85,6 @@ jobs:
6585
# Source
6686
- name: Checkout current repo
6787
uses: actions/checkout@v4
68-
with:
69-
path: functions
7088
# Install python 3.10.17
7189
- name: Install python 3.10.17
7290
uses: actions/setup-python@v4
@@ -77,39 +95,69 @@ jobs:
7795
id: cache
7896
with:
7997
path: ~/.cache/pip
80-
key: ${{ runner.os }}-pip-${{ hashFiles('functions/requirements.txt') }}
98+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
8199
restore-keys: |
82100
${{ runner.os }}-pip-
83101
- name: Install requirements
84102
run: |
85103
pip install --upgrade pip
86-
pip install -r functions/requirements.txt
104+
pip install -r requirements.txt
87105
88106
- name: Run py tests
89-
run: python functions/functions.py run-tests -r functions -s py -fn ${{ matrix.package }}
107+
run: python -m cli.cli run-tests -r ${{ matrix.package }} -s py -fn $(basename "${{ matrix.package }}")
90108
continue-on-error: true
91109
# - name: Run ipynb tests
92-
# run: python functions/functions.py run-tests -r functions -s ipynb
93-
- name: Clean
110+
# run: python functions/cli/cli.py run-tests -r functions -s ipynb
111+
112+
update_readmes:
113+
needs: build_strategy_matrix
114+
if: github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets'
115+
runs-on: ubuntu-latest
116+
permissions:
117+
contents: write
118+
steps:
119+
- uses: actions/checkout@v4
120+
with:
121+
fetch-depth: 0
122+
- name: Install python 3.10.17
123+
uses: actions/setup-python@v4
124+
with:
125+
python-version: 3.10.17
126+
- name: Install requirements
127+
run: |
128+
pip install --upgrade pip
129+
pip install -r requirements.txt
130+
- name: Regenerate README tables
131+
run: python -m cli.cli update-readme --asset functions --asset modules
132+
- name: Commit & push (if changed)
133+
env:
134+
USERNAME: ${{ secrets.USERNAME }}
135+
USEREMAIL: ${{ secrets.USERMAIL }}
94136
run: |
95-
rm -rf functions
137+
if git diff --quiet; then
138+
echo "No README changes."
139+
exit 0
140+
fi
141+
git config --local user.name $USERNAME
142+
git config --local user.email $USEREMAIL
143+
git add functions/README.md modules/README.md || true
144+
git commit -m "chore(readme): auto-update asset tables [skip ci]"
145+
git push
96146
97147
build-marketplace:
98148
name: Build marketplace
99-
if: github.repository == 'mlrun/functions' && github.event_name != 'pull_request'
149+
if: (github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets')
100150
runs-on: ubuntu-latest
101151
needs: run_monorepo_tests
102152
continue-on-error: false
103153

104154
steps:
105155
- name: Get the current branch name
106156
shell: bash
107-
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
157+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
108158
id: branch
109159
- name: Checkout current repo
110160
uses: actions/checkout@v4
111-
with:
112-
path: functions
113161
- name: Checkout Marketplace
114162
uses: actions/checkout@v4
115163
with:
@@ -121,7 +169,6 @@ jobs:
121169
python-version: 3.10.17
122170
- name: Install requirements
123171
run: |
124-
cd functions
125172
pip install --upgrade pip
126173
pip install -r requirements.txt
127174
- name: Build marketplace docs
@@ -132,12 +179,19 @@ jobs:
132179
pwd
133180
git pull origin
134181
cd ..
135-
python functions/functions.py build-marketplace -s functions -m marketplace -c $CHANNEL -v -f
182+
python -m cli.cli build-marketplace -s ./functions/src -sn functions -m marketplace -c $CHANNEL -v -f
183+
python -m cli.cli build-marketplace -s ./modules/src -sn modules -m marketplace -c $CHANNEL -v -f
184+
## Uncomment the following lines if you want to upload the built marketplace as an artifact
185+
# - name: Upload built marketplace as artifact
186+
# uses: actions/upload-artifact@v4
187+
# with:
188+
# name: marketplace-build
189+
# path: marketplace/**
136190
- name: Publish marketplace release
137191
env:
138192
GITHUB_TOKEN: ${{ secrets.MARKETPLACE_ACCESS_TOKEN_V3 }}
139-
USERNAME: iguazio-cicd
140-
USEREMAIL: [email protected]
193+
USERNAME: ${{ secrets.USERNAME }}
194+
USEREMAIL: ${{ secrets.USERMAIL }}
141195
REPO_PATH: marketplace
142196
BASE_REPO: mlrun
143197
BASE_BRANCH: master

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ dmypy.json
140140
.pyre/
141141
conda-setup-cpu
142142
conda-setup-gpu
143+
.DS_Store

README.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)