-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce instance mappings * Introduce changes for tests to make them compatible with Marqo Cloud --------- Co-authored-by: Farshid Zavareh <farshid@marqo.ai>
- Loading branch information
Showing
40 changed files
with
1,311 additions
and
1,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[build-system] | ||
requires = ["setuptools>=42"] | ||
build-backend = "setuptools.build_meta" | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.pytest.ini_options] | ||
markers = "ignore_during_cloud_tests: Mark tests to be ignored when running with env set to cloud_tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import time | ||
|
||
from marqo.marqo_logging import mq_logger | ||
from marqo._httprequests import HttpRequests | ||
from marqo.enums import IndexStatus | ||
|
||
|
||
def cloud_wait_for_index_status(req: HttpRequests, index_name: str, status: IndexStatus): | ||
""" Wait for index to achieve some status on Marqo Cloud by checking | ||
it's status every 10 seconds until it becomes expected value | ||
Args: | ||
req (HttpRequests): HttpRequests object | ||
index_name (str): name of the index | ||
status (IndexStatus): expected status of the index | ||
""" | ||
current_status = req.get(f"indexes/{index_name}/status") | ||
while current_status['index_status'] != status: | ||
time.sleep(10) | ||
current_status = req.get(f"indexes/{index_name}/status") | ||
mq_logger.info(f"Current index status: {current_status['index_status']}") | ||
mq_logger.info(f"Index achieved status {status} successfully") | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
|
||
from marqo import utils | ||
from marqo.instance_mappings import InstanceMappings | ||
|
||
|
||
class DefaultInstanceMappings(InstanceMappings): | ||
def __init__(self, url: str, main_user: str = None, main_password: str = None): | ||
self._url = url.lower() | ||
|
||
if main_user is not None and main_password is not None: | ||
self._url = utils.construct_authorized_url(self._url, main_user, main_password) | ||
|
||
local_host_markers = ["localhost", "0.0.0.0", "127.0.0.1"] | ||
if any([marker in self._url for marker in local_host_markers]): | ||
self._is_remote = False | ||
else: | ||
self._is_remote = True | ||
|
||
def get_index_base_url(self, index_name: str) -> str: | ||
return self._url | ||
|
||
def get_control_base_url(self) -> str: | ||
return self._url | ||
|
||
def is_remote(self): | ||
return self._is_remote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ class Devices: | |
cpu = "cpu" | ||
cuda = "cuda" | ||
|
||
|
||
class IndexStatus: | ||
CREATED = "READY" | ||
DELETED = "DELETED" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.