Skip to content

Commit 5e276a5

Browse files
authored
Update python/pyta/jupyter testers to allow a requirements file (#580)
1 parent 04ec2ab commit 5e276a5

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
All notable changes to this project will be documented here.
33

44
## [unreleased]
5+
- Update python, pyta and jupyter testers to allow a requirements file (#580)
56

67
## [v2.6.0]
78
- Update python versions in docker file (#568)

server/autotest_server/testers/jupyter/settings_schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"pip_requirements": {
2626
"title": "Package requirements",
2727
"type": "string"
28+
},
29+
"pip_requirements_file": {
30+
"title": "Package requirements file",
31+
"type": "string"
2832
}
2933
}
3034
},

server/autotest_server/testers/jupyter/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ def create_environment(settings_, env_dir, _default_env_dir):
1111
requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
1212
pip = os.path.join(env_dir, "bin", "pip")
1313
subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True)
14-
subprocess.run([pip, "install", "-r", requirements, *pip_requirements], check=True)
14+
pip_install_command = [pip, "install", "-r", requirements, *pip_requirements]
15+
if env_data.get("pip_requirements_file"):
16+
pip_install_command.append("-r")
17+
pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file")))
18+
subprocess.run(pip_install_command, check=True)
1519
return {"PYTHON": os.path.join(env_dir, "bin", "python3")}
1620

1721

server/autotest_server/testers/py/settings_schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"pip_requirements": {
2626
"title": "Package requirements",
2727
"type": "string"
28+
},
29+
"pip_requirements_file": {
30+
"title": "Package requirements file",
31+
"type": "string"
2832
}
2933
}
3034
},

server/autotest_server/testers/py/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ def create_environment(settings_, env_dir, _default_env_dir):
1111
requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
1212
pip = os.path.join(env_dir, "bin", "pip")
1313
subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True)
14-
subprocess.run([pip, "install", "-r", requirements, *pip_requirements], check=True)
14+
pip_install_command = [pip, "install", "-r", requirements, *pip_requirements]
15+
if env_data.get("pip_requirements_file"):
16+
pip_install_command.append("-r")
17+
pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file")))
18+
subprocess.run(pip_install_command, check=True)
1519
return {"PYTHON": os.path.join(env_dir, "bin", "python3")}
1620

1721

server/autotest_server/testers/pyta/settings_schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
"title": "Package requirements",
2727
"type": "string"
2828
},
29+
"pip_requirements_file": {
30+
"title": "Package requirements file",
31+
"type": "string"
32+
},
2933
"pyta_version": {
3034
"title": "PyTA version",
3135
"type": "string",

server/autotest_server/testers/pyta/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def create_environment(settings_, env_dir, _default_env_dir):
1717
requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
1818
pip = os.path.join(env_dir, "bin", "pip")
1919
subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True)
20-
subprocess.run([pip, "install", "-r", requirements, *env_properties], check=True)
20+
pip_install_command = [pip, "install", "-r", requirements, *env_properties]
21+
if env_data.get("pip_requirements_file"):
22+
pip_install_command.append("-r")
23+
pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file")))
24+
subprocess.run(pip_install_command, check=True)
2125
return {"PYTHON": os.path.join(env_dir, "bin", "python3")}
2226

2327

0 commit comments

Comments
 (0)