Skip to content

Commit 25524fb

Browse files
committed
Merge remote-tracking branch 'origin' into push_container_image_on_merge
2 parents e371bcd + 181f859 commit 25524fb

31 files changed

+1361
-318
lines changed

.github/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Run `tox`
77
- Close stale PRs
88
- Check for offensive language
9+
- Assign the PR to the author
910

1011
### On user action
1112
- Add to or remove a label from PR; supported labels: `wip`, `lgtm`, `verified`, and `hold`.
@@ -23,7 +24,6 @@
2324

2425
## To be added
2526
- Block merging if not all defined checks pass. For example: a `verified` label was added and at least 2 approvals.
26-
- When a PR is opened, assign the PR to the PR owner
2727
- When a PR is opened, add reviewers (requires updates to OWNERS file(s))
2828
- When a PR is reviewed/commented by a user who's not the PR owner, add `reviewed|commented|approved-by-<username>` label
2929
- When a PR is ready to be merged (all checks passed), add `ready-to-merge` label

.github/workflows/add-welcome-comment.yml renamed to .github/workflows/add-welcome-comment-set-assignee.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Add Welcome Comment
1+
name: Add Welcome Comment And Set PR Assignee
22
on:
33
pull_request_target:
44
types: [opened]
@@ -8,7 +8,7 @@ permissions:
88
contents: write
99

1010
jobs:
11-
add-welcome-comment:
11+
add-welcome-comment-set-assignee:
1212
runs-on: ubuntu-latest
1313

1414
steps:
@@ -23,5 +23,5 @@ jobs:
2323
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
2424
GITHUB_EVENT_ACTION: ${{github.event.action}}
2525
GITHUB_EVENT_NAME: ${{github.event_name}}
26-
ACTION: "add-welcome-comment"
26+
ACTION: "add-welcome-comment-set-assignee"
2727
run: uv run python .github/workflows/scripts/pr_workflow.py

.github/workflows/scripts/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* PR size label.
2626
* Run [pre-commit](https://pre-commit.ci/)
2727
* Run [tox](https://tox.wiki/)
28+
* Add PR author as the PR assignee
2829
2930
Available user actions:
3031
* To mark a PR as `WIP`, add `/wip` in a comment. To remove it from the PR comment `/wip cancel` to the PR.

.github/workflows/scripts/pr_workflow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class PrBaseClass:
3131
class SupportedActions:
3232
add_remove_labels_action_name: str = "add-remove-labels"
3333
pr_size_action_name: str = "add-pr-size-label"
34-
welcome_comment_action_name: str = "add-welcome-comment"
34+
welcome_comment_action_name: str = "add-welcome-comment-set-assignee"
3535
supported_actions: set[str] = {
3636
pr_size_action_name,
3737
add_remove_labels_action_name,
@@ -115,7 +115,7 @@ def run_pr_label_action(self) -> None:
115115
self.add_remove_pr_labels()
116116

117117
if self.action == self.SupportedActions.welcome_comment_action_name:
118-
self.add_welcome_comment()
118+
self.add_welcome_comment_set_assignee()
119119

120120
def get_pr_size(self) -> int:
121121
additions: int = 0
@@ -294,8 +294,9 @@ def issue_comment_label_actions(
294294
if commented_by_label not in self.pr_labels:
295295
self.add_pr_label(label=commented_by_label)
296296

297-
def add_welcome_comment(self) -> None:
297+
def add_welcome_comment_set_assignee(self) -> None:
298298
self.pr.create_issue_comment(body=WELCOME_COMMENT)
299+
self.pr.add_to_assignees(self.pr.user.login)
299300

300301

301302
def main() -> None:

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- id: detect-secrets
3636

3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.11.0
38+
rev: v0.11.2
3939
hooks:
4040
- id: ruff
4141
- id: ruff-format
@@ -49,7 +49,7 @@ repos:
4949
# - id: renovate-config-validator
5050

5151
- repo: https://github.com/gitleaks/gitleaks
52-
rev: v8.24.0
52+
rev: v8.24.2
5353
hooks:
5454
- id: gitleaks
5555

conftest.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def pytest_addoption(parser: Parser) -> None:
3232
buckets_group = parser.getgroup(name="Buckets")
3333
runtime_group = parser.getgroup(name="Runtime details")
3434
upgrade_group = parser.getgroup(name="Upgrade options")
35+
platform_group = parser.getgroup(name="Platform")
3536

3637
# AWS config and credentials options
3738
aws_group.addoption(
@@ -113,6 +114,12 @@ def pytest_addoption(parser: Parser) -> None:
113114
"If not set, all will be tested.",
114115
)
115116

117+
# Platform options
118+
platform_group.addoption(
119+
"--applications-namespace",
120+
help="RHOAI/ODH applications namespace",
121+
)
122+
116123

117124
def pytest_cmdline_main(config: Any) -> None:
118125
config.option.basetemp = py_config["tmp_base_dir"] = f"{config.option.basetemp}-{shortuuid.uuid()}"
@@ -196,9 +203,6 @@ def pytest_sessionstart(session: Session) -> None:
196203
log_level=session.config.getoption("log_cli_level") or logging.INFO,
197204
)
198205

199-
if py_config.get("distribution") == "upstream":
200-
py_config["applications_namespace"] = "opendatahub"
201-
202206

203207
def pytest_fixture_setup(fixturedef: FixtureDef[Any], request: FixtureRequest) -> None:
204208
LOGGER.info(f"Executing {fixturedef.scope} fixture: {fixturedef.argname}")
@@ -207,8 +211,9 @@ def pytest_fixture_setup(fixturedef: FixtureDef[Any], request: FixtureRequest) -
207211
def pytest_runtest_setup(item: Item) -> None:
208212
"""
209213
Performs the following actions:
210-
1. Adds skip fixture for kserve if serverless or authorino operators are not installed.
211-
2. Adds skip fixture for serverless if authorino/serverless/service mesh are not deployed.
214+
1. Updates global config (`updated_global_config`)
215+
2. Adds skip fixture for kserve if serverless or authorino operators are not installed.
216+
3. Adds skip fixture for serverless if authorino/serverless/service mesh are not deployed.
212217
"""
213218

214219
BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
@@ -226,6 +231,9 @@ def pytest_runtest_setup(item: Item) -> None:
226231
elif KServeDeploymentType.MODEL_MESH.lower() in item.keywords:
227232
item.fixturenames.insert(0, "enabled_modelmesh_in_dsc")
228233

234+
# The above fixtures require the global config to be updated before being called
235+
item.fixturenames.insert(0, "updated_global_config")
236+
229237

230238
def pytest_runtest_call(item: Item) -> None:
231239
BASIC_LOGGER.info(f"{separator(symbol_='-', val='CALL')}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies = [
6363
"timeout-sampler>=1.0.6",
6464
"shortuuid>=1.0.13",
6565
"jira>=3.8.0",
66-
"openshift-python-wrapper>=11.0.26",
66+
"openshift-python-wrapper>=11.0.38",
6767
"semver>=3.0.4",
6868
]
6969

tests/conftest.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
from simple_logger.logger import get_logger
2222

2323
from utilities.data_science_cluster_utils import update_components_in_dsc
24-
from utilities.infra import create_ns, login_with_user_password, get_openshift_token
24+
from utilities.infra import (
25+
create_ns,
26+
get_dsci_applications_namespace,
27+
get_operator_distribution,
28+
login_with_user_password,
29+
get_openshift_token,
30+
)
2531
from utilities.constants import AcceleratorType, DscComponents
2632
from utilities.infra import update_configmap_data
2733

@@ -45,6 +51,21 @@ def tests_tmp_dir(request: FixtureRequest, tmp_path_factory: TempPathFactory) ->
4551
shutil.rmtree(path=str(tests_tmp_path), ignore_errors=True)
4652

4753

54+
@pytest.fixture(scope="session")
55+
def updated_global_config(request: FixtureRequest, admin_client: DynamicClient) -> None:
56+
if get_operator_distribution(client=admin_client) == "Open Data Hub":
57+
py_config["distribution"] = "upstream"
58+
59+
else:
60+
py_config["distribution"] = "downstream"
61+
62+
if applications_namespace := request.config.getoption("applications_namespace"):
63+
py_config["applications_namespace"] = applications_namespace
64+
65+
else:
66+
py_config["applications_namespace"] = get_dsci_applications_namespace(client=admin_client)
67+
68+
4869
@pytest.fixture(scope="session")
4970
def current_client_token(admin_client: DynamicClient) -> str:
5071
return get_openshift_token()
@@ -275,6 +296,17 @@ def enabled_modelmesh_in_dsc(dsc_resource: DataScienceCluster) -> Generator[Data
275296
yield dsc
276297

277298

299+
@pytest.fixture(scope="package")
300+
def enabled_kserve_in_dsc(
301+
dsc_resource: DataScienceCluster,
302+
) -> Generator[DataScienceCluster, Any, Any]:
303+
with update_components_in_dsc(
304+
dsc=dsc_resource,
305+
components={DscComponents.KSERVE: DscComponents.ManagementState.MANAGED},
306+
) as dsc:
307+
yield dsc
308+
309+
278310
@pytest.fixture(scope="session")
279311
def cluster_monitoring_config(admin_client: DynamicClient) -> Generator[ConfigMap, Any, Any]:
280312
data = {"config.yaml": yaml.dump({"enableUserWorkload": True})}
@@ -304,5 +336,8 @@ def unprivileged_model_namespace(
304336
request.getfixturevalue(argname="enabled_modelmesh_in_dsc")
305337
ns_kwargs["model_mesh_enabled"] = True
306338

339+
if (_dashboard_label := request.param.get("dashboard-label")) is not None:
340+
ns_kwargs["add_dashboard_label"] = _dashboard_label
341+
307342
with create_ns(**ns_kwargs) as ns:
308343
yield ns
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from typing import Generator, Any
2+
3+
import pytest
4+
from _pytest.fixtures import FixtureRequest
5+
from kubernetes.dynamic import DynamicClient
6+
from ocp_resources.namespace import Namespace
7+
from ocp_resources.secret import Secret
8+
from ocp_resources.service import Service
9+
10+
from tests.model_explainability.constants import MINIO, MINIO_PORT
11+
12+
OPENDATAHUB_IO: str = "opendatahub.io"
13+
14+
15+
@pytest.fixture(scope="class")
16+
def minio_service(admin_client: DynamicClient, model_namespace: Namespace) -> Generator[Service, Any, Any]:
17+
with Service(
18+
client=admin_client,
19+
name=MINIO,
20+
namespace=model_namespace.name,
21+
ports=[
22+
{
23+
"name": "minio-client-port",
24+
"port": MINIO_PORT,
25+
"protocol": "TCP",
26+
"targetPort": MINIO_PORT,
27+
}
28+
],
29+
selector={
30+
"app": MINIO,
31+
},
32+
) as minio_service:
33+
yield minio_service
34+
35+
36+
@pytest.fixture(scope="class")
37+
def minio_data_connection(
38+
request: FixtureRequest, admin_client: DynamicClient, model_namespace: Namespace, minio_service: Service
39+
) -> Generator[Secret, Any, Any]:
40+
with Secret(
41+
client=admin_client,
42+
name="aws-connection-minio-data-connection",
43+
namespace=model_namespace.name,
44+
data_dict=request.param["data-dict"],
45+
label={
46+
f"{OPENDATAHUB_IO}/dashboard": "true",
47+
f"{OPENDATAHUB_IO}/managed": "true",
48+
},
49+
annotations={
50+
f"{OPENDATAHUB_IO}/connection-type": "s3",
51+
"openshift.io/display-name": "Minio Data Connection",
52+
},
53+
) as minio_secret:
54+
yield minio_secret
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from utilities.general import get_s3_secret_dict
2+
3+
MINIO: str = "minio"
4+
MINIO_PORT: int = 9000
5+
6+
MINIO_ACCESS_KEY: str = "MINIO_ACCESS_KEY"
7+
MINIO_ACCESS_KEY_VALUE: str = "THEACCESSKEY"
8+
MINIO_SECRET_KEY: str = "MINIO_SECRET_KEY"
9+
MINIO_SECRET_KEY_VALUE: str = "THESECRETKEY"
10+
11+
MINIO_DATA_DICT: dict[str, str] = get_s3_secret_dict(
12+
aws_access_key=MINIO_ACCESS_KEY_VALUE,
13+
aws_secret_access_key=MINIO_SECRET_KEY_VALUE, # pragma: allowlist secret
14+
aws_s3_bucket="modelmesh-example-models",
15+
aws_s3_endpoint=f"http://minio:{str(MINIO_PORT)}",
16+
aws_s3_region="us-south",
17+
)

0 commit comments

Comments
 (0)