Skip to content

Commit

Permalink
Dynamically change python target version for MR dependencies (#1898)
Browse files Browse the repository at this point in the history
* Install MR from pip instead of locally

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

* fetch python version at runtime

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

* Fix python version fetching

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

* remove global variable keyword call

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

---------

Signed-off-by: lugi0 <[email protected]>
  • Loading branch information
lugi0 authored Oct 8, 2024
1 parent e125d3b commit 55a958c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
29 changes: 16 additions & 13 deletions ods_ci/tests/Resources/Page/ODH/JupyterHub/JupyterLabLauncher.robot
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,24 @@ Run Cell And Get Output
RETURN ${output}

Python Version Check
[Arguments] ${expected_version}=3.8
Add And Run JupyterLab Code Cell In Active Notebook !python --version
Wait Until JupyterLab Code Cell Is Not Active
#Get the text of the last output cell
${output} = Get Text (//div[contains(@class,"jp-OutputArea-output")])[last()]
#start is inclusive, end exclusive, get x.y from Python x.y.z string
${output} = Fetch From Right ${output} ${SPACE}
${vers} = Get Substring ${output} 0 3
${status} = Run Keyword And Return Status Should Match ${vers} ${expected_version}
IF '${status}' == 'FAIL' Run Keyword And Continue On Failure FAIL "Expected Python at version ${expected_version}, but found at v ${vers}"

[Documentation] Checks that the X.Y python version of the current Jupyterlab instance matches an expected one
[Arguments] ${expected_version}=3.8
${vers} = Get XY Python Version From Jupyterlab
${status} = Run Keyword And Return Status Should Match ${vers} ${expected_version}
IF '${status}' == 'FAIL' Run Keyword And Continue On Failure FAIL "Expected Python at version ${expected_version}, but found at v ${vers}" # robocop: disable

Get XY Python Version From Jupyterlab
[Documentation] Fetches the X.Y Python version from the current Jupyterlab instance
${output}= Run Cell And Get Output !python --version
${output}= Fetch From Right ${output} ${SPACE}
# Y and Z can be > len 1, split on "." instead of getting substring from indices
@{split_out}= Split String ${output} separator=.
${vers}= Set Variable ${split_out}[0].${split_out}[1]
RETURN ${vers}

Maybe Select Kernel
${is_kernel_selected} = Run Keyword And Return Status Page Should Not Contain Element xpath=//div[@class="jp-Dialog-buttonLabel"][.="Select"]
IF not ${is_kernel_selected} Click Button xpath=//div[@class="jp-Dialog-buttonLabel"][.="Select"]/..
${is_kernel_selected} = Run Keyword And Return Status Page Should Not Contain Element xpath=//div[@class="jp-Dialog-buttonLabel"][.="Select"]
IF not ${is_kernel_selected} SeleniumLibrary.Click Button xpath=//div[@class="jp-Dialog-buttonLabel"][.="Select"]/..

Clean Up Server
[Documentation] Cleans up user server and checks that everything has been removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ Remove Deployment Files
Download Python Client Dependencies
[Documentation] Download the model-registry package for a specific platform
[Arguments] ${destination} ${package_version}
${result}= Run Process command=pip download --platform=manylinux2014_x86_64 --python-version=3.9 --abi=cp39 --only-binary=:all: --dest=${destination} ${package_version} # robocop: disable:line-too-long
# We could add --abi=cp311 as a parameter, but it does not appear to be needed as it will default to the cpython
# version compatible with the specific python version. If specified it will need to be updated to point to the
# correct cpython version (e.g. cp311 for python 3.11, cp312 for python 3.12 etc.)
Open New Notebook
${python_version}= Get XY Python Version From Jupyterlab
${result}= Run Process command=pip download --platform=manylinux2014_x86_64 --python-version=${python_version} --only-binary=:all: --dest=${destination} ${package_version} # robocop: disable:line-too-long
... shell=yes
Should Be Equal As Numbers ${result.rc} 0 ${result.stderr}

Expand Down

0 comments on commit 55a958c

Please sign in to comment.