Skip to content

Commit 4ec4e8f

Browse files
committed
formatting fixes
1 parent 70c1fd5 commit 4ec4e8f

File tree

9 files changed

+118
-69
lines changed

9 files changed

+118
-69
lines changed

ads/feature_store/docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Feature Store
2727
.. toctree::
2828
:maxdepth: 2
2929
:caption: Getting started:
30-
30+
3131
overview
3232
setup_feature_store
3333
quickstart

ads/feature_store/docs/source/setup_feature_store.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Known Issues
6969
-------------
7070

7171
1. Deployment doesn't work in Virtual Nodepool as the Feature Store API server relies on Instance Principal authentication.
72-
72+
7373

7474
.. toctree::
7575
:maxdepth: 1

ads/feature_store/docs/source/user_guides.setup.helm_chart.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ To login to Container Registry using the Helm CLI:
5454
- Click Generate Token. The new auth token is displayed.
5555
- Copy the auth token immediately to a secure location from where you can retrieve it later, because you won't see the auth token again in the Console.
5656
- Close the Generate Token dialog.
57-
57+
5858
- In a terminal window on the client machine running Docker, log in to Container Registry by entering ``helm registry login <region-key>.ocir.io``, where <region-key> corresponds to the key for the Container Registry region you're using. For example, ``helm registry login iad.ocir.io``. See `Availability by Region <https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryprerequisites.htm#regional-availability>`_.
5959
- When prompted for a username, enter your username in the format <tenancy-namespace>/<username>, where <tenancy-namespace> is the auto-generated Object Storage namespace string of your tenancy (as shown on the Tenancy Information page). For example, ansh81vru1zp/jdoe@acme.com. If your tenancy is federated with Oracle Identity Cloud Service, use the format <tenancy-namespace>/oracleidentitycloudservice/<username>.
6060
- When prompted for a password, enter the auth token you copied earlier.
@@ -188,4 +188,3 @@ __________________________________________________________
188188
periodSeconds:
189189
timeoutSeconds:
190190
failureThreshold:
191-

ads/opctl/operator/cmd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
OPERATOR_BASE_DOCKER_GPU_FILE,
3535
OPERATOR_BASE_GPU_IMAGE,
3636
OPERATOR_BASE_IMAGE,
37-
OPERATOR_BACKEND_SECTION_NAME
37+
OPERATOR_BACKEND_SECTION_NAME,
3838
)
3939
from ads.opctl.operator.common.operator_loader import OperatorInfo, OperatorLoader
4040
from ads.opctl.utils import publish_image as publish_image_cmd
@@ -190,7 +190,6 @@ def init(
190190
logger.debug(ex)
191191
print_traceback()
192192

193-
194193
# copy README and original schema files into a destination folder
195194
for src_file in ("README.md", "schema.yaml", "environment.yaml"):
196195
ads_common_utils.copy_file(

ads/opctl/operator/common/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,15 @@ def default_signer(**kwargs):
159159
from ads.common.auth import default_signer
160160

161161
return default_signer(**kwargs)
162+
163+
162164
def remove_prefix(text: str, prefix: str):
163165
if text.startswith(prefix):
164166
return text[len(prefix) :]
165167
else:
166168
return text
167169

170+
168171
def print_traceback():
169172
if logger.level == logging.DEBUG:
170173
ex_type, ex, tb = sys.exc_info()

ads/opctl/operator/lowcode/feature_store_marketplace/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Feature Store Marketplace Operator
2-
The Feature Store Marketplace Operator simplifies the process of deploying Feature Store stack from Marketplace to your existing OKE cluster.
2+
The Feature Store Marketplace Operator simplifies the process of deploying Feature Store stack from Marketplace to your existing OKE cluster.
33

44
Below are the steps to configure and run the Marketplace Operator:
55
## 1. Prerequisites

ads/opctl/operator/lowcode/feature_store_marketplace/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Copyright (c) 2023 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

7+
78
class ForecastSchemaYamlError(Exception):
89
"""Exception raised when there is an issue with the schema."""
910

tests/unitary/with_extras/operator/feature-store/test_local_marketplace.py

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,73 @@
44
import mock
55
import yaml
66

7-
from ads.opctl.backend.marketplace.local_marketplace import LocalMarketplaceOperatorBackend
8-
from ads.opctl.backend.marketplace.models.marketplace_type import HelmMarketplaceListingDetails
7+
from ads.opctl.backend.marketplace.local_marketplace import (
8+
LocalMarketplaceOperatorBackend,
9+
)
10+
from ads.opctl.backend.marketplace.models.marketplace_type import (
11+
HelmMarketplaceListingDetails,
12+
)
913
from ads.opctl.operator.common.operator_loader import OperatorInfo
1014

1115

12-
@patch('ads.opctl.backend.marketplace.local_marketplace.fsspec.open', new_callable=mock.mock_open())
16+
@patch(
17+
"ads.opctl.backend.marketplace.local_marketplace.fsspec.open",
18+
new_callable=mock.mock_open(),
19+
)
1320
def test_helm_values_to_yaml(file_writer: Mock):
1421
sample_helm_value = {
15-
"key1": {
16-
"inner_key1": "inner_value1",
17-
"inner_key2": "inner_value2"
18-
},
19-
"key2": {
20-
"inner_key3": "inner_value3",
21-
"inner_key4": "inner_value4"
22-
}
22+
"key1": {"inner_key1": "inner_value1", "inner_key2": "inner_value2"},
23+
"key2": {"inner_key3": "inner_value3", "inner_key4": "inner_value4"},
2324
}
2425
path = LocalMarketplaceOperatorBackend._save_helm_values_to_yaml_(sample_helm_value)
25-
assert path.endswith('values.yaml')
26-
file_writer.assert_called_with(path, mode='w')
27-
file_writer.return_value.__enter__().write.assert_called_once_with(yaml.dump(sample_helm_value))
26+
assert path.endswith("values.yaml")
27+
file_writer.assert_called_with(path, mode="w")
28+
file_writer.return_value.__enter__().write.assert_called_once_with(
29+
yaml.dump(sample_helm_value)
30+
)
2831

2932

30-
@patch('ads.opctl.backend.marketplace.local_marketplace.MarketplaceBackendRunner')
31-
@patch('ads.opctl.backend.marketplace.local_marketplace.operator_runtime')
33+
@patch("ads.opctl.backend.marketplace.local_marketplace.MarketplaceBackendRunner")
34+
@patch("ads.opctl.backend.marketplace.local_marketplace.operator_runtime")
3235
def test_run_with_python_success(operator_runtime: Mock, backend_runner: Mock):
33-
local_marketplace_operator = LocalMarketplaceOperatorBackend(config={'execution': {}}, operator_info=OperatorInfo())
36+
local_marketplace_operator = LocalMarketplaceOperatorBackend(
37+
config={"execution": {}}, operator_info=OperatorInfo()
38+
)
3439
local_marketplace_operator.process_helm_listing = Mock(return_value=0)
3540

3641
mock_helm_detail = Mock(spec=HelmMarketplaceListingDetails)
3742
mock_helm_detail.helm_values = {}
38-
mock_helm_detail.helm_app_name = 'helm_app_name'
39-
mock_helm_detail.ocir_fully_qualified_url = 'ocir_fully_qualified_url'
40-
mock_helm_detail.helm_chart_tag = 'helm_chart_tag'
41-
mock_helm_detail.namespace = 'namespace'
43+
mock_helm_detail.helm_app_name = "helm_app_name"
44+
mock_helm_detail.ocir_fully_qualified_url = "ocir_fully_qualified_url"
45+
mock_helm_detail.helm_chart_tag = "helm_chart_tag"
46+
mock_helm_detail.namespace = "namespace"
4247
backend_runner.return_value.get_listing_details.return_value = mock_helm_detail
4348
# helm_install_api.return_value.returncode = 0
4449
assert local_marketplace_operator._run_with_python_() == 0
4550

4651

47-
@patch('ads.opctl.backend.marketplace.local_marketplace.check_helm_login')
48-
@patch('ads.opctl.backend.marketplace.local_marketplace.check_prerequisites')
49-
@patch('ads.opctl.backend.marketplace.local_marketplace.run_helm_install')
50-
@patch('ads.opctl.backend.marketplace.local_marketplace.MarketplaceBackendRunner')
51-
@patch('ads.opctl.backend.marketplace.local_marketplace.operator_runtime')
52-
def test_run_with_python_failure(operator_runtime: Mock, backend_runner: Mock, helm_install_api: Mock,
53-
check_prerequisites: Mock,
54-
check_helm_login: Mock
55-
):
56-
local_marketplace_operator = LocalMarketplaceOperatorBackend(config={'execution': {}}, operator_info=OperatorInfo())
52+
@patch("ads.opctl.backend.marketplace.local_marketplace.check_helm_login")
53+
@patch("ads.opctl.backend.marketplace.local_marketplace.check_prerequisites")
54+
@patch("ads.opctl.backend.marketplace.local_marketplace.run_helm_install")
55+
@patch("ads.opctl.backend.marketplace.local_marketplace.MarketplaceBackendRunner")
56+
@patch("ads.opctl.backend.marketplace.local_marketplace.operator_runtime")
57+
def test_run_with_python_failure(
58+
operator_runtime: Mock,
59+
backend_runner: Mock,
60+
helm_install_api: Mock,
61+
check_prerequisites: Mock,
62+
check_helm_login: Mock,
63+
):
64+
local_marketplace_operator = LocalMarketplaceOperatorBackend(
65+
config={"execution": {}}, operator_info=OperatorInfo()
66+
)
5767
local_marketplace_operator.process_helm_listing = Mock(return_value=-1)
5868
mock_helm_detail = Mock(spec=HelmMarketplaceListingDetails)
5969
mock_helm_detail.helm_values = {}
60-
mock_helm_detail.helm_app_name = 'helm_app_name'
61-
mock_helm_detail.ocir_fully_qualified_url = 'ocir_fully_qualified_url'
62-
mock_helm_detail.helm_chart_tag = 'helm_chart_tag'
63-
mock_helm_detail.namespace = 'namespace'
70+
mock_helm_detail.helm_app_name = "helm_app_name"
71+
mock_helm_detail.ocir_fully_qualified_url = "ocir_fully_qualified_url"
72+
mock_helm_detail.helm_chart_tag = "helm_chart_tag"
73+
mock_helm_detail.namespace = "namespace"
6474
backend_runner.return_value.get_listing_details.return_value = mock_helm_detail
6575
helm_install_api.return_value.returncode = -1
6676
assert local_marketplace_operator._run_with_python_() == -1

tests/unitary/with_extras/operator/feature-store/test_prerequisite_checker.py

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,31 @@
44
import pytest
55
from oci.marketplace.models import AcceptedAgreementSummary, AgreementSummary
66

7-
from ads.opctl.backend.marketplace.models.marketplace_type import HelmMarketplaceListingDetails, \
8-
MarketplaceListingDetails
9-
from ads.opctl.backend.marketplace.prerequisite_checker import check_prerequisites, _prompt_kubernetes_confirmation_, \
10-
_check_binaries_, _check_license_for_listing_, BinaryValidation
7+
from ads.opctl.backend.marketplace.models.marketplace_type import (
8+
HelmMarketplaceListingDetails,
9+
MarketplaceListingDetails,
10+
)
11+
from ads.opctl.backend.marketplace.prerequisite_checker import (
12+
check_prerequisites,
13+
_prompt_kubernetes_confirmation_,
14+
_check_binaries_,
15+
_check_license_for_listing_,
16+
BinaryValidation,
17+
)
1118

1219

1320
@patch(
14-
"ads.opctl.backend.marketplace.prerequisite_checker._prompt_kubernetes_confirmation_")
21+
"ads.opctl.backend.marketplace.prerequisite_checker._prompt_kubernetes_confirmation_"
22+
)
1523
@patch("ads.opctl.backend.marketplace.prerequisite_checker._check_kubernetes_secret_")
1624
@patch("ads.opctl.backend.marketplace.prerequisite_checker._check_binaries_")
1725
@patch("ads.opctl.backend.marketplace.prerequisite_checker._check_license_for_listing_")
18-
def test_check_prerequisites(license_api: Mock, check_binary_api: Mock, prompt_kubernetes_confirmation_api: Mock,
19-
check_kubernetes_secret_api: Mock):
26+
def test_check_prerequisites(
27+
license_api: Mock,
28+
check_binary_api: Mock,
29+
prompt_kubernetes_confirmation_api: Mock,
30+
check_kubernetes_secret_api: Mock,
31+
):
2032
listing_detail = Mock(spec=HelmMarketplaceListingDetails)
2133
check_prerequisites(listing_detail)
2234
license_api.assert_called_once()
@@ -28,18 +40,22 @@ def test_check_prerequisites(license_api: Mock, check_binary_api: Mock, prompt_k
2840
@patch("ads.opctl.backend.marketplace.prerequisite_checker.click")
2941
def test_prompt_kubernetes_confirmation(click: Mock):
3042
_prompt_kubernetes_confirmation_()
31-
click.confirm.assert_called_once_with(text='Is it safe to proceed?', default=False, abort=True)
43+
click.confirm.assert_called_once_with(
44+
text="Is it safe to proceed?", default=False, abort=True
45+
)
3246

3347

3448
@patch("ads.opctl.backend.marketplace.prerequisite_checker.subprocess.run")
3549
def test_check_binaries_success(subprocess_runner: Mock):
3650
binaries = [BinaryValidation("bin_a", ""), BinaryValidation("bin_b", "")]
3751
subprocess_runner.return_value = CompletedProcess(args="", returncode=0)
3852
_check_binaries_(binaries)
39-
subprocess_runner.assert_has_calls([
40-
call(['which', 'bin_a'], capture_output=True),
41-
call(['which', 'bin_b'], capture_output=True)
42-
])
53+
subprocess_runner.assert_has_calls(
54+
[
55+
call(["which", "bin_a"], capture_output=True),
56+
call(["which", "bin_b"], capture_output=True),
57+
]
58+
)
4359

4460

4561
@patch("ads.opctl.backend.marketplace.prerequisite_checker.subprocess.run")
@@ -48,39 +64,60 @@ def test_check_binaries_failure(subprocess_runner: Mock):
4864
binaries = [BinaryValidation("bin_a", ""), BinaryValidation("bin_b", "")]
4965
subprocess_runner.return_value = CompletedProcess(args="", returncode=-1)
5066
_check_binaries_(binaries)
51-
subprocess_runner.assert_has_calls([
52-
call(['which', 'bin_a'], capture_output=True),
53-
call(['which', 'bin_b'], capture_output=True)
54-
])
67+
subprocess_runner.assert_has_calls(
68+
[
69+
call(["which", "bin_a"], capture_output=True),
70+
call(["which", "bin_b"], capture_output=True),
71+
]
72+
)
5573

5674

5775
@patch("ads.opctl.backend.marketplace.prerequisite_checker.get_marketplace_client")
5876
def test_check_license_for_listing_when_already_accepted(marketplace_client: Mock):
59-
listing_detail = MarketplaceListingDetails(listing_id="lid", compartment_id="c_id", version="1.0")
60-
61-
accepted_agreement = AcceptedAgreementSummary(agreement_id="accepted_agreement_ocid")
62-
marketplace_client.return_value.list_accepted_agreements.return_value.data = [accepted_agreement]
63-
marketplace_client.return_value.list_agreements.return_value.data = [AgreementSummary(id="accepted_agreement_ocid")]
77+
listing_detail = MarketplaceListingDetails(
78+
listing_id="lid", compartment_id="c_id", version="1.0"
79+
)
80+
81+
accepted_agreement = AcceptedAgreementSummary(
82+
agreement_id="accepted_agreement_ocid"
83+
)
84+
marketplace_client.return_value.list_accepted_agreements.return_value.data = [
85+
accepted_agreement
86+
]
87+
marketplace_client.return_value.list_agreements.return_value.data = [
88+
AgreementSummary(id="accepted_agreement_ocid")
89+
]
6490

6591
_check_license_for_listing_(listing_detail)
6692
marketplace_client.assert_called_once()
6793
marketplace_client.return_value.list_accepted_agreements.assert_called_once()
6894
marketplace_client.return_value.list_agreements.assert_called_once()
6995

96+
7097
@patch("ads.opctl.backend.marketplace.prerequisite_checker.click")
7198
@patch("ads.opctl.backend.marketplace.prerequisite_checker.time")
7299
@patch("ads.opctl.backend.marketplace.prerequisite_checker.webbrowser.open")
73100
@patch("ads.opctl.backend.marketplace.prerequisite_checker.get_marketplace_client")
74-
def test_check_license_for_listing_pending_and_accepted(marketplace_client: Mock, web_client:Mock, timer:Mock, click:Mock):
75-
listing_detail = MarketplaceListingDetails(listing_id="lid", compartment_id="c_id", version="1.0")
101+
def test_check_license_for_listing_pending_and_accepted(
102+
marketplace_client: Mock, web_client: Mock, timer: Mock, click: Mock
103+
):
104+
listing_detail = MarketplaceListingDetails(
105+
listing_id="lid", compartment_id="c_id", version="1.0"
106+
)
76107
AGREEMENT_CONTENT_URL = "https://test.content.url"
77108
AGREEMENT_PROMPT = "test-prompt"
78109

79110
click.confirm.return_value = True
80111
marketplace_client.return_value.list_accepted_agreements.return_value.data = []
81-
marketplace_client.return_value.list_agreements.return_value.data = [AgreementSummary(id="accepted_agreement_ocid")]
82-
marketplace_client.return_value.get_agreement.return_value.data.content_url = AGREEMENT_CONTENT_URL
83-
marketplace_client.return_value.get_agreement.return_value.data.prompt = AGREEMENT_PROMPT
112+
marketplace_client.return_value.list_agreements.return_value.data = [
113+
AgreementSummary(id="accepted_agreement_ocid")
114+
]
115+
marketplace_client.return_value.get_agreement.return_value.data.content_url = (
116+
AGREEMENT_CONTENT_URL
117+
)
118+
marketplace_client.return_value.get_agreement.return_value.data.prompt = (
119+
AGREEMENT_PROMPT
120+
)
84121

85122
_check_license_for_listing_(listing_detail)
86123

@@ -89,4 +126,4 @@ def test_check_license_for_listing_pending_and_accepted(marketplace_client: Mock
89126
marketplace_client.return_value.list_agreements.assert_called_once()
90127
web_client.assert_called_once_with(AGREEMENT_CONTENT_URL)
91128
click.confirm.assert_called_once_with(AGREEMENT_PROMPT, default=False)
92-
marketplace_client.return_value.create_accepted_agreement.assert_called_once()
129+
marketplace_client.return_value.create_accepted_agreement.assert_called_once()

0 commit comments

Comments
 (0)