code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def test_load_prompt_with_no_active_model():
"""Test load_prompt when no active model is available."""
# Register a prompt
mlflow.register_prompt(name="test_prompt", template="Hello, {{name}}!")
# Mock no active model available
with mock.patch(
"mlflow.tracking._model_registry.fluent.get_a... | Test load_prompt when no active model is available. | test_load_prompt_with_no_active_model | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_linking_error_handling():
"""Test load_prompt error handling when linking fails."""
# Register a prompt
mlflow.register_prompt(name="test_prompt", template="Hello, {{name}}!")
# Test with invalid model ID - should still load prompt successfully
with mock.patch(
"mlflow... | Test load_prompt error handling when linking fails. | test_load_prompt_linking_error_handling | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_explicit_model_id_overrides_active_model():
"""Test that explicit model_id parameter overrides active model ID."""
# Register a prompt
mlflow.register_prompt(name="test_prompt", template="Hello, {{name}}!")
# Create models to test override behavior
with mlflow.start_run():
... | Test that explicit model_id parameter overrides active model ID. | test_load_prompt_explicit_model_id_overrides_active_model | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_with_tracing_single_prompt():
"""Test that load_prompt properly links a single prompt to an active trace."""
# Register a prompt
mlflow.register_prompt(name="test_prompt", template="Hello, {{name}}!")
# Start tracing and load prompt
with mlflow.start_span("test_operation") as ... | Test that load_prompt properly links a single prompt to an active trace. | test_load_prompt_with_tracing_single_prompt | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_with_tracing_multiple_prompts():
"""Test that load_prompt properly links multiple versions of the same prompt to one trace."""
# Register one prompt with multiple versions
mlflow.register_prompt(name="my_prompt", template="Hello, {{name}}!")
mlflow.register_prompt(name="my_prompt",... | Test that load_prompt properly links multiple versions of the same prompt to one trace. | test_load_prompt_with_tracing_multiple_prompts | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_with_tracing_no_active_trace():
"""Test that load_prompt works correctly when there's no active trace."""
# Register a prompt
mlflow.register_prompt(name="no_trace_prompt", template="Hello, {{name}}!")
# Load prompt without an active trace
prompt = mlflow.load_prompt("no_trace... | Test that load_prompt works correctly when there's no active trace. | test_load_prompt_with_tracing_no_active_trace | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_with_tracing_nested_spans():
"""Test that load_prompt links prompts to the same trace when using nested spans."""
# Register prompts
mlflow.register_prompt(name="outer_prompt", template="Outer: {{msg}}")
mlflow.register_prompt(name="inner_prompt", template="Inner: {{msg}}")
# ... | Test that load_prompt links prompts to the same trace when using nested spans. | test_load_prompt_with_tracing_nested_spans | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_caching_works():
"""Test that prompt caching works and improves performance."""
# Mock the client load_prompt method to count calls
with mock.patch("mlflow.MlflowClient.load_prompt") as mock_client_load:
# Configure mock to return a prompt
mock_prompt = PromptVersion(
... | Test that prompt caching works and improves performance. | test_load_prompt_caching_works | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_caching_respects_env_var():
"""Test that prompt caching respects the MLFLOW_PROMPT_CACHE_MAX_SIZE environment variable."""
# Test with a small cache size
original_value = MLFLOW_PROMPT_CACHE_MAX_SIZE.get()
try:
# Set cache size to 1
MLFLOW_PROMPT_CACHE_MAX_SIZE.set(1... | Test that prompt caching respects the MLFLOW_PROMPT_CACHE_MAX_SIZE environment variable. | test_load_prompt_caching_respects_env_var | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_skip_cache_for_allow_missing_none():
"""Test that we skip cache if allow_missing=True and the result is None."""
# Mock the client load_prompt method to return None (prompt not found)
with mock.patch("mlflow.MlflowClient.load_prompt") as mock_client_load:
mock_client_load.return... | Test that we skip cache if allow_missing=True and the result is None. | test_load_prompt_skip_cache_for_allow_missing_none | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_missing_then_created_then_found():
"""Test loading a prompt that doesn't exist, then creating it, then loading again."""
# First try to load a prompt that doesn't exist
result1 = mlflow.load_prompt(
"will_be_created", version=1, allow_missing=True, link_to_model=False
)
... | Test loading a prompt that doesn't exist, then creating it, then loading again. | test_load_prompt_missing_then_created_then_found | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_none_result_no_linking():
"""Test that if prompt version is None and allow_missing=True, we don't attempt any linking."""
# Mock only the client load_prompt method and linking methods
with (
mock.patch("mlflow.MlflowClient.load_prompt") as mock_client_load,
mock.patch("m... | Test that if prompt version is None and allow_missing=True, we don't attempt any linking. | test_load_prompt_none_result_no_linking | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_load_prompt_caching_with_different_parameters():
"""Test that caching works correctly with different parameter combinations."""
# Register a prompt
mlflow.register_prompt(name="param_test", template="Hello, {{name}}!")
with mock.patch("mlflow.MlflowClient.load_prompt") as mock_client_load:
... | Test that caching works correctly with different parameter combinations. | test_load_prompt_caching_with_different_parameters | python | mlflow/mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_model_registry_fluent.py | Apache-2.0 |
def test_default_get_registry_uri_with_databricks_tracking_uri_defaults_to_uc():
"""Test that databricks tracking URIs default to databricks-uc for registry"""
tracking_uri = "databricks://tracking_werohoz"
with mock.patch(
"mlflow.tracking._model_registry.utils._resolve_tracking_uri"
) as resol... | Test that databricks tracking URIs default to databricks-uc for registry | test_default_get_registry_uri_with_databricks_tracking_uri_defaults_to_uc | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_default_registry_uri_non_databricks_tracking_uri(tracking_uri):
"""Test that non-databricks tracking URIs are used directly as registry URI"""
with mock.patch(
"mlflow.tracking._tracking_service.utils.get_tracking_uri"
) as get_tracking_uri_mock:
get_tracking_uri_mock.return_value =... | Test that non-databricks tracking URIs are used directly as registry URI | test_default_registry_uri_non_databricks_tracking_uri | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_databricks_tracking_uri_variations_default_to_uc(tracking_uri, expected_registry_uri):
"""Test that various databricks tracking URI formats default to databricks-uc"""
with mock.patch(
"mlflow.tracking._tracking_service.utils.get_tracking_uri"
) as get_tracking_uri_mock:
get_trackin... | Test that various databricks tracking URI formats default to databricks-uc | test_databricks_tracking_uri_variations_default_to_uc | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_explicit_registry_uri_overrides_databricks_default():
"""Test that explicitly set registry URI takes precedence over databricks default"""
tracking_uri = "databricks://workspace"
explicit_registry_uri = "databricks://different_workspace"
with mock.patch(
"mlflow.tracking._tracking_serv... | Test that explicitly set registry URI takes precedence over databricks default | test_explicit_registry_uri_overrides_databricks_default | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_registry_uri_from_environment_overrides_databricks_default():
"""Test that registry URI from environment variable overrides databricks default"""
from mlflow.environment_variables import MLFLOW_REGISTRY_URI
tracking_uri = "databricks://workspace"
env_registry_uri = "http://env-registry-server:... | Test that registry URI from environment variable overrides databricks default | test_registry_uri_from_environment_overrides_databricks_default | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_registry_uri_from_spark_session_overrides_databricks_default():
"""Test that registry URI from Spark session overrides databricks default"""
tracking_uri = "databricks://workspace"
spark_registry_uri = "databricks-uc://spark_profile"
with (
mock.patch(
"mlflow.tracking._tra... | Test that registry URI from Spark session overrides databricks default | test_registry_uri_from_spark_session_overrides_databricks_default | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_edge_cases_for_databricks_uri_detection(tracking_uri, expected_result):
"""Test edge cases for databricks URI detection"""
with mock.patch(
"mlflow.tracking._tracking_service.utils.get_tracking_uri"
) as get_tracking_uri_mock:
get_tracking_uri_mock.return_value = tracking_uri
... | Test edge cases for databricks URI detection | test_edge_cases_for_databricks_uri_detection | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def test_store_object_can_be_serialized_by_pickle():
"""
This test ensures a store object generated by `_get_store` can be serialized by pickle
to prevent issues such as https://github.com/mlflow/mlflow/issues/2954
"""
pickle.dump(_get_store("https://example.com"), io.BytesIO())
pickle.dump(_get... |
This test ensures a store object generated by `_get_store` can be serialized by pickle
to prevent issues such as https://github.com/mlflow/mlflow/issues/2954
| test_store_object_can_be_serialized_by_pickle | python | mlflow/mlflow | tests/tracking/_model_registry/test_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/tracking/_model_registry/test_utils.py | Apache-2.0 |
def prefetch_models():
"""
Prefetches models used in the test suite to avoid downloading them during the test run.
Fetching model weights from the HuggingFace Hub has been proven to be flaky in the past, so
we want to avoid doing it in the middle of the test run, instead, failing fast.
"""
# Get... |
Prefetches models used in the test suite to avoid downloading them during the test run.
Fetching model weights from the HuggingFace Hub has been proven to be flaky in the past, so
we want to avoid doing it in the middle of the test run, instead, failing fast.
| prefetch_models | python | mlflow/mlflow | tests/transformers/helper.py | https://github.com/mlflow/mlflow/blob/master/tests/transformers/helper.py | Apache-2.0 |
def load_context(self, context):
"""
This method initializes the tokenizer and language model
using the specified snapshot location.
"""
snapshot_location = context.artifacts["bert-tiny-model"].removeprefix("hf:/")
# Initialize tokenizer and langua... |
This method initializes the tokenizer and language model
using the specified snapshot location.
| load_context | python | mlflow/mlflow | tests/transformers/test_transformers_model_export.py | https://github.com/mlflow/mlflow/blob/master/tests/transformers/test_transformers_model_export.py | Apache-2.0 |
def local_checkpoint_path(tmp_path):
"""
Fixture to create a local model checkpoint for testing fine-tuning scenario.
"""
model = transformers.AutoModelWithLMHead.from_pretrained("distilgpt2")
class DummyDataset(torch.utils.data.Dataset):
def __getitem__(self, idx):
pass
... |
Fixture to create a local model checkpoint for testing fine-tuning scenario.
| local_checkpoint_path | python | mlflow/mlflow | tests/transformers/test_transformers_model_export.py | https://github.com/mlflow/mlflow/blob/master/tests/transformers/test_transformers_model_export.py | Apache-2.0 |
def test_flush_metrics_queue_is_thread_safe():
"""
Autologging augments TensorBoard event logging hooks with MLflow `log_metric` API
calls. To prevent these API calls from blocking TensorBoard event logs, `log_metric`
API calls are scheduled via `_flush_queue` on a background thread. Accordingly, this t... |
Autologging augments TensorBoard event logging hooks with MLflow `log_metric` API
calls. To prevent these API calls from blocking TensorBoard event logs, `log_metric`
API calls are scheduled via `_flush_queue` on a background thread. Accordingly, this test
verifies that `_flush_queue` is thread safe.
... | test_flush_metrics_queue_is_thread_safe | python | mlflow/mlflow | tests/utils/test_autologging_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_autologging_utils.py | Apache-2.0 |
def test_no_throw():
"""
Outside of Databricks the databricks_utils methods should never throw and should only return
None.
"""
assert not databricks_utils.is_in_databricks_notebook()
assert not databricks_utils.is_in_databricks_repo_notebook()
assert not databricks_utils.is_in_databricks_jo... |
Outside of Databricks the databricks_utils methods should never throw and should only return
None.
| test_no_throw | python | mlflow/mlflow | tests/utils/test_databricks_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_databricks_utils.py | Apache-2.0 |
def test_databricks_runtime_version_parse(
version_str,
expected_is_client,
expected_major,
expected_minor,
):
"""Test that DatabricksRuntimeVersion.parse() correctly parses version strings."""
version = DatabricksRuntimeVersion.parse(version_str)
assert version.is_client_image == expected_i... | Test that DatabricksRuntimeVersion.parse() correctly parses version strings. | test_databricks_runtime_version_parse | python | mlflow/mlflow | tests/utils/test_databricks_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_databricks_utils.py | Apache-2.0 |
def test_databricks_runtime_version_parse_default(
monkeypatch,
env_version,
expected_is_client,
expected_major,
expected_minor,
):
"""Test that DatabricksRuntimeVersion.parse() works without arguments."""
monkeypatch.setenv("DATABRICKS_RUNTIME_VERSION", env_version)
version = Databricks... | Test that DatabricksRuntimeVersion.parse() works without arguments. | test_databricks_runtime_version_parse_default | python | mlflow/mlflow | tests/utils/test_databricks_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_databricks_utils.py | Apache-2.0 |
def test_databricks_runtime_version_parse_default_no_env(monkeypatch):
"""Test that DatabricksRuntimeVersion.parse() raises error when no environment variable is
set.
"""
monkeypatch.delenv("DATABRICKS_RUNTIME_VERSION", raising=False)
with pytest.raises(Exception, match="Failed to parse databricks r... | Test that DatabricksRuntimeVersion.parse() raises error when no environment variable is
set.
| test_databricks_runtime_version_parse_default_no_env | python | mlflow/mlflow | tests/utils/test_databricks_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_databricks_utils.py | Apache-2.0 |
def f(p1, p2, p3, p4):
"""asdf
Args:
p1:
asdf
p2: asdf
p3:
asdf
p4:
asdf
""" | asdf
Args:
p1:
asdf
p2: asdf
p3:
asdf
p4:
asdf
| f | python | mlflow/mlflow | tests/utils/test_docstring_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_docstring_utils.py | Apache-2.0 |
def test_tar_function_path_handling(tmp_path):
"""Test that _tar function correctly handles Path objects."""
# Create test files
root_dir = tmp_path / "root"
root_dir.mkdir()
(root_dir / "test.txt").write_text("test content")
(root_dir / "__pycache__").mkdir()
(root_dir / "__pycache__" / "te... | Test that _tar function correctly handles Path objects. | test_tar_function_path_handling | python | mlflow/mlflow | tests/utils/test_env_pack.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_env_pack.py | Apache-2.0 |
def test_pack_env_for_databricks_model_serving_pip_requirements(tmp_path, mock_dbr_version):
"""Test that pack_env_for_databricks_model_serving correctly handles pip requirements
installation.
"""
# Mock download_artifacts to return a path
mock_artifacts_dir = tmp_path / "artifacts"
mock_artifac... | Test that pack_env_for_databricks_model_serving correctly handles pip requirements
installation.
| test_pack_env_for_databricks_model_serving_pip_requirements | python | mlflow/mlflow | tests/utils/test_env_pack.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_env_pack.py | Apache-2.0 |
def test_pack_env_for_databricks_model_serving_pip_requirements_error(tmp_path, mock_dbr_version):
"""Test that pack_env_for_databricks_model_serving correctly handles pip install errors."""
# Mock download_artifacts to return a path
mock_artifacts_dir = tmp_path / "artifacts"
mock_artifacts_dir.mkdir()... | Test that pack_env_for_databricks_model_serving correctly handles pip install errors. | test_pack_env_for_databricks_model_serving_pip_requirements_error | python | mlflow/mlflow | tests/utils/test_env_pack.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_env_pack.py | Apache-2.0 |
def test_pack_env_for_databricks_model_serving_unsupported_version():
"""Test that pack_env_for_databricks_model_serving raises error for non-client image."""
with mock.patch.object(
DatabricksRuntimeVersion,
"parse",
return_value=DatabricksRuntimeVersion(
is_client_image=Fal... | Test that pack_env_for_databricks_model_serving raises error for non-client image. | test_pack_env_for_databricks_model_serving_unsupported_version | python | mlflow/mlflow | tests/utils/test_env_pack.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_env_pack.py | Apache-2.0 |
def test_pack_env_for_databricks_model_serving_runtime_version_check(tmp_path, monkeypatch):
"""Test that pack_env_for_databricks_model_serving correctly checks runtime version
compatibility.
"""
# Mock download_artifacts to return a path
mock_artifacts_dir = tmp_path / "artifacts"
mock_artifact... | Test that pack_env_for_databricks_model_serving correctly checks runtime version
compatibility.
| test_pack_env_for_databricks_model_serving_runtime_version_check | python | mlflow/mlflow | tests/utils/test_env_pack.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_env_pack.py | Apache-2.0 |
def test_parse_requirements(tmp_path, monkeypatch):
"""
Ensures `_parse_requirements` returns the same result as `pip._internal.req.parse_requirements`
"""
from pip._internal.network.session import PipSession # noqa: TID251
from pip._internal.req import ( # noqa: TID251
parse_requirements ... |
Ensures `_parse_requirements` returns the same result as `pip._internal.req.parse_requirements`
| test_parse_requirements | python | mlflow/mlflow | tests/utils/test_requirements_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_requirements_utils.py | Apache-2.0 |
def test_http_request_with_aws_sigv4(request, monkeypatch):
"""This test requires the "requests_auth_aws_sigv4" package to be installed"""
from requests_auth_aws_sigv4 import AWSSigV4
monkeypatch.setenvs(
{
"AWS_ACCESS_KEY_ID": "access-key",
"AWS_SECRET_ACCESS_KEY": "secret... | This test requires the "requests_auth_aws_sigv4" package to be installed | test_http_request_with_aws_sigv4 | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_http_request_with_invalid_url_raise_invalid_url_exception():
"""InvalidURL exception can be caught by a custom InvalidUrlException"""
host_only = MlflowHostCreds("http://my-host")
with pytest.raises(InvalidUrlException, match="Invalid url: http://my-host/invalid_url"):
with mock.patch("req... | InvalidURL exception can be caught by a custom InvalidUrlException | test_http_request_with_invalid_url_raise_invalid_url_exception | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_http_request_with_invalid_url_raise_mlflow_exception():
"""The InvalidUrlException can be caught by the MlflowException"""
host_only = MlflowHostCreds("http://my-host")
with pytest.raises(MlflowException, match="Invalid url: http://my-host/invalid_url"):
with mock.patch("requests.Session.r... | The InvalidUrlException can be caught by the MlflowException | test_http_request_with_invalid_url_raise_mlflow_exception | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_databricks_sdk_retry_on_transient_errors():
"""Test that Databricks SDK retries on transient HTTP errors."""
host_creds = MlflowHostCreds("http://example.com", use_databricks_sdk=True)
call_count = 0
def mock_do_failing_then_success(*args, **kwargs):
nonlocal call_count
call_c... | Test that Databricks SDK retries on transient HTTP errors. | test_databricks_sdk_retry_on_transient_errors | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_databricks_sdk_retry_max_retries_exceeded():
"""Test that Databricks SDK stops retrying when max_retries is exceeded."""
host_creds = MlflowHostCreds("http://example.com", use_databricks_sdk=True)
call_count = 0
def mock_do_always_fail(*args, **kwargs):
nonlocal call_count
cal... | Test that Databricks SDK stops retrying when max_retries is exceeded. | test_databricks_sdk_retry_max_retries_exceeded | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_databricks_sdk_retry_timeout_exceeded():
"""Test that Databricks SDK stops retrying when timeout is exceeded."""
host_creds = MlflowHostCreds("http://example.com", use_databricks_sdk=True)
call_count = 0
def mock_do_always_fail(*args, **kwargs):
nonlocal call_count
call_count ... | Test that Databricks SDK stops retrying when timeout is exceeded. | test_databricks_sdk_retry_timeout_exceeded | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_databricks_sdk_retry_non_retryable_error():
"""Test that Databricks SDK doesn't retry on non-retryable errors."""
host_creds = MlflowHostCreds("http://example.com", use_databricks_sdk=True)
call_count = 0
def mock_do_non_retryable_error(*args, **kwargs):
nonlocal call_count
ca... | Test that Databricks SDK doesn't retry on non-retryable errors. | test_databricks_sdk_retry_non_retryable_error | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_databricks_sdk_retry_backoff_calculation():
"""Test that Databricks SDK uses correct exponential backoff timing."""
from mlflow.utils.request_utils import _TRANSIENT_FAILURE_RESPONSE_CODES
from mlflow.utils.rest_utils import _retry_databricks_sdk_call_with_exponential_backoff
call_count = 0
... | Test that Databricks SDK uses correct exponential backoff timing. | test_databricks_sdk_retry_backoff_calculation | python | mlflow/mlflow | tests/utils/test_rest_utils.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_rest_utils.py | Apache-2.0 |
def test_append_to_uri_path_handles_special_uri_characters_in_posixpaths():
"""
Certain characters are treated specially when parsing and interpreting URIs. However, in the
case where a URI input for `append_to_uri_path` is simply a POSIX path, these characters should
not receive special treatment. This... |
Certain characters are treated specially when parsing and interpreting URIs. However, in the
case where a URI input for `append_to_uri_path` is simply a POSIX path, these characters should
not receive special treatment. This test case verifies that `append_to_uri_path` properly joins
POSIX paths contai... | test_append_to_uri_path_handles_special_uri_characters_in_posixpaths | python | mlflow/mlflow | tests/utils/test_uri.py | https://github.com/mlflow/mlflow/blob/master/tests/utils/test_uri.py | Apache-2.0 |
def test_load_pyfunc_succeeds_for_older_models_with_pyfunc_data_field(xgb_model, model_path):
"""
This test verifies that xgboost models saved in older versions of MLflow are loaded
successfully by ``mlflow.pyfunc.load_model``. These older models specify a pyfunc ``data``
field referring directly to a X... |
This test verifies that xgboost models saved in older versions of MLflow are loaded
successfully by ``mlflow.pyfunc.load_model``. These older models specify a pyfunc ``data``
field referring directly to a XGBoost model file. Newer models also have the
``model_class`` in XGBoost flavor.
| test_load_pyfunc_succeeds_for_older_models_with_pyfunc_data_field | python | mlflow/mlflow | tests/xgboost/test_xgboost_model_export.py | https://github.com/mlflow/mlflow/blob/master/tests/xgboost/test_xgboost_model_export.py | Apache-2.0 |
def parse_requirements(filename='requirements.txt'):
""" load requirements from a pip requirements file. (replacing from pip.req import parse_requirements)"""
lineiter = (line.strip() for line in open(filename))
return [line for line in lineiter if line and not line.startswith("#")] | load requirements from a pip requirements file. (replacing from pip.req import parse_requirements) | parse_requirements | python | AirtestProject/Poco | setup.py | https://github.com/AirtestProject/Poco/blob/master/setup.py | Apache-2.0 |
def driver(self):
"""
Return the driver of this agent related to. None if the driver is not ready to bind.
Returns:
:py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to.
"""
if not self._driver:
raise AttributeError("`dri... |
Return the driver of this agent related to. None if the driver is not ready to bind.
Returns:
:py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to.
| driver | python | AirtestProject/Poco | poco/agent.py | https://github.com/AirtestProject/Poco/blob/master/poco/agent.py | Apache-2.0 |
def __call__(self, name=None, **kw):
"""
Call Poco instance to select the UI element by query expression. Query expression can contain specific name
and/or other attributes. Invisible UI elements will be skipped even if "visible=False" argument is set.
Selection process is not executed ... |
Call Poco instance to select the UI element by query expression. Query expression can contain specific name
and/or other attributes. Invisible UI elements will be skipped even if "visible=False" argument is set.
Selection process is not executed instantly, the query expression is stored in the... | __call__ | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def wait_for_any(self, objects, timeout=120):
"""
Wait until any of given UI proxies show up before timeout and return the first appeared UI proxy.
All UI proxies will be polled periodically. See options :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more d... |
Wait until any of given UI proxies show up before timeout and return the first appeared UI proxy.
All UI proxies will be polled periodically. See options :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
objects (Iterable<:py:... | wait_for_any | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def wait_for_all(self, objects, timeout=120):
"""
Wait until all of given UI proxies show up before timeout.
All UI proxies will be polled periodically. See option :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
obje... |
Wait until all of given UI proxies show up before timeout.
All UI proxies will be polled periodically. See option :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
objects (Iterable<:py:class:`UIObjectProxy <poco.proxy.UIObje... | wait_for_all | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def freeze(this):
"""
Snapshot current **hierarchy** and cache it into a new poco instance. This new poco instance is a copy from
current poco instance (``self``). The hierarchy of the new poco instance is fixed and immutable. It will be
super fast when calling ``dump`` function from fro... |
Snapshot current **hierarchy** and cache it into a new poco instance. This new poco instance is a copy from
current poco instance (``self``). The hierarchy of the new poco instance is fixed and immutable. It will be
super fast when calling ``dump`` function from frozen poco. See the example bel... | freeze | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def click(self, pos):
"""
Perform click (touch, tap, etc.) action on target device at given coordinates.
The coordinates (x, y) are either a 2-list or 2-tuple. The coordinates values for x and y must be in the
interval between 0 ~ 1 to represent the percentage of the screen. For example... |
Perform click (touch, tap, etc.) action on target device at given coordinates.
The coordinates (x, y) are either a 2-list or 2-tuple. The coordinates values for x and y must be in the
interval between 0 ~ 1 to represent the percentage of the screen. For example, the coordinates ``[0.5, 0.5]``
... | click | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def swipe(self, p1, p2=None, direction=None, duration=2.0):
"""
Perform swipe action on target device from point to point given by start point and end point, or by the
direction vector. At least one of the end point or direction must be provided.
The coordinates (x, y) definition for po... |
Perform swipe action on target device from point to point given by start point and end point, or by the
direction vector. At least one of the end point or direction must be provided.
The coordinates (x, y) definition for points is the same as for ``click`` event. The components of the
... | swipe | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def long_click(self, pos, duration=2.0):
"""
Similar to click but press the screen for the given time interval and then release
Args:
pos (:obj:`2-list/2-tuple`): coordinates (x, y) in range from 0 to 1
duration: duration of press the screen
"""
try:
... |
Similar to click but press the screen for the given time interval and then release
Args:
pos (:obj:`2-list/2-tuple`): coordinates (x, y) in range from 0 to 1
duration: duration of press the screen
| long_click | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Scroll from the lower part to the upper part of the entire screen.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percen... |
Scroll from the lower part to the upper part of the entire screen.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percentage of the entire screen height or width according to
direction
... | scroll | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def apply_motion_tracks(self, tracks, accuracy=0.004):
"""
Similar to click but press the screen for the given time interval and then release
Args:
tracks (:py:obj:`list`): list of :py:class:`poco.utils.track.MotionTrack` object
accuracy (:py:obj:`float`): motion accuracy ... |
Similar to click but press the screen for the given time interval and then release
Args:
tracks (:py:obj:`list`): list of :py:class:`poco.utils.track.MotionTrack` object
accuracy (:py:obj:`float`): motion accuracy for each motion steps in normalized coordinate metrics.
| apply_motion_tracks | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def use_render_resolution(self, use=True, resolution=None):
'''
Whether to use render resolution
Args:
use: True or false
resolution: render resolution in portrait mode, offset_x, offset_y, offset_width, offset_height, (0, 10, 1080, 1820)
'''
self._agent.... |
Whether to use render resolution
Args:
use: True or false
resolution: render resolution in portrait mode, offset_x, offset_y, offset_width, offset_height, (0, 10, 1080, 1820)
| use_render_resolution | python | AirtestProject/Poco | poco/pocofw.py | https://github.com/AirtestProject/Poco/blob/master/poco/pocofw.py | Apache-2.0 |
def child(self, name=None, **attrs):
"""
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name ... |
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected
attrs: other query ... | child | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def offspring(self, name=None, **attrs):
"""
Select the offsprings including the direct child(ren) from the UI element(s) given by the query expression,
see ``QueryCondition`` for more details about selectors.
Args:
name: query expression of attribute "name", i.e. the UI ele... |
Select the offsprings including the direct child(ren) from the UI element(s) given by the query expression,
see ``QueryCondition`` for more details about selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected
... | offspring | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def sibling(self, name=None, **attrs):
"""
Select the sibling(s) from the UI element(s) given by the query expression, see ``QueryCondition`` for more
details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name will ... |
Select the sibling(s) from the UI element(s) given by the query expression, see ``QueryCondition`` for more
details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected
attrs: other query express... | sibling | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def parent(self):
"""
Select the direct parent from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Warnings:
Experimental method, may not be available for all drivers.
Returns:
:py:class:`UIO... |
Select the direct parent from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Warnings:
Experimental method, may not be available for all drivers.
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObje... | parent | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def __getitem__(self, item):
"""
Select the specific UI element by index. If this UI proxy represents a set of UI elements, then use this method
to access the specific UI element. The new UI element will be wrapped by UIObjectProxy instance and therefore
the returned value is also the UI... |
Select the specific UI element by index. If this UI proxy represents a set of UI elements, then use this method
to access the specific UI element. The new UI element will be wrapped by UIObjectProxy instance and therefore
the returned value is also the UI proxy object.
The order of UI ... | __getitem__ | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def click(self, focus=None, sleep_interval=None):
"""
Perform the click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is ... |
Perform the click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is also possible to click another point offset by providing ``fo... | click | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def rclick(self, focus=None, sleep_interval=None):
"""
Perform the right click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one.... |
Perform the right click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is also possible to click another point offset by providin... | rclick | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def double_click(self, focus=None, sleep_interval=None):
"""
Perform the double click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
... |
Perform the double click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is also possible to click another point offset by providi... | double_click | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def long_click(self, duration=2.0):
"""
Perform the long click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a
set of UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the
default one. Similar to cl... |
Perform the long click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a
set of UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the
default one. Similar to click but press the screen for the given time int... | long_click | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def drag_to(self, target, duration=2.0):
"""
Similar to swipe action, but the end point is provide by a UI proxy or by fixed coordinates.
Args:
target (:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`): a UI proxy or 2-list/2-tuple coordinates
(x, y) in NormalizedCo... |
Similar to swipe action, but the end point is provide by a UI proxy or by fixed coordinates.
Args:
target (:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`): a UI proxy or 2-list/2-tuple coordinates
(x, y) in NormalizedCoordinate system
duration (:py:obj:`float... | drag_to | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Simply touch down from point A and move to point B then release up finally. This action is performed within
specific motion range and duration.
Args:
direction (:py:obj:`str`): scrolling direction. "verti... |
Simply touch down from point A and move to point B then release up finally. This action is performed within
specific motion range and duration.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance... | scroll | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def focus(self, f):
"""
Get a new UI proxy copy with the given focus. Return a new UI proxy object as the UI proxy is immutable.
Args:
f (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): the focus point, it can be specified as 2-list/2-tuple
coordinates (x, y) in NormalizedCoo... |
Get a new UI proxy copy with the given focus. Return a new UI proxy object as the UI proxy is immutable.
Args:
f (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): the focus point, it can be specified as 2-list/2-tuple
coordinates (x, y) in NormalizedCoordinate system or as 'center' o... | focus | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def get_position(self, focus=None):
"""
Get the position of the UI elements.
Args:
focus: focus point of UI proxy, see :py:meth:`.focus() <poco.proxy.UIObjectProxy.focus>` for more details
Returns:
2-list/2-tuple: coordinates (x, y) in NormalizedCoordinate syst... |
Get the position of the UI elements.
Args:
focus: focus point of UI proxy, see :py:meth:`.focus() <poco.proxy.UIObjectProxy.focus>` for more details
Returns:
2-list/2-tuple: coordinates (x, y) in NormalizedCoordinate system
Raises:
TypeError: rais... | get_position | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def wait(self, timeout=3):
"""
Block and wait for max given time before the UI element appears.
Args:
timeout: maximum waiting time in seconds
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: self
"""
start = time.time()
wh... |
Block and wait for max given time before the UI element appears.
Args:
timeout: maximum waiting time in seconds
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: self
| wait | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def wait_for_appearance(self, timeout=120):
"""
Block and wait until the UI element **appears** within the given timeout. When timeout, the
:py:class:`PocoTargetTimeout <poco.exceptions.PocoTargetTimeout>` is raised.
Args:
timeout: maximum waiting time in seconds
Ra... |
Block and wait until the UI element **appears** within the given timeout. When timeout, the
:py:class:`PocoTargetTimeout <poco.exceptions.PocoTargetTimeout>` is raised.
Args:
timeout: maximum waiting time in seconds
Raises:
PocoTargetTimeout: when timeout
... | wait_for_appearance | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def setattr(self, name, val):
"""
Change the attribute value of the UI element. Not all attributes can be casted to text. If changing the
immutable attributes or attributes which do not exist, the InvalidOperationException exception is raised.
Args:
name: attribute name
... |
Change the attribute value of the UI element. Not all attributes can be casted to text. If changing the
immutable attributes or attributes which do not exist, the InvalidOperationException exception is raised.
Args:
name: attribute name
val: new attribute value to cast
... | setattr | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def exists(self):
"""
Test whether the UI element is in the hierarchy. Similar to :py:meth:`.attr('visible')
<poco.proxy.UIObjectProxy.attr>`.
Returns:
bool: True if exists otherwise False
"""
try:
return self.attr('visible')
except (Poco... |
Test whether the UI element is in the hierarchy. Similar to :py:meth:`.attr('visible')
<poco.proxy.UIObjectProxy.attr>`.
Returns:
bool: True if exists otherwise False
| exists | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def get_bounds(self):
"""
Get the parameters of bounding box of the UI element.
Returns:
:obj:`list` <:obj:`float`>: 4-list (top, right, bottom, left) coordinates related to the edge of screen in
NormalizedCoordinate system
"""
size = self.get_size()
... |
Get the parameters of bounding box of the UI element.
Returns:
:obj:`list` <:obj:`float`>: 4-list (top, right, bottom, left) coordinates related to the edge of screen in
NormalizedCoordinate system
| get_bounds | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def invalidate(self):
"""
Clear the flag to indicate to re-query or re-select the UI element(s) from hierarchy.
alias is refresh()
Example:
>>> a = poco(text="settings")
>>> print(a.exists())
>>> a.refresh()
>>> print(a.exists())
... |
Clear the flag to indicate to re-query or re-select the UI element(s) from hierarchy.
alias is refresh()
Example:
>>> a = poco(text="settings")
>>> print(a.exists())
>>> a.refresh()
>>> print(a.exists())
| invalidate | python | AirtestProject/Poco | poco/proxy.py | https://github.com/AirtestProject/Poco/blob/master/poco/proxy.py | Apache-2.0 |
def _is_running(self, package_name):
"""
use ps |grep to check whether the process exists
:param package_name: package name(e.g., com.github.uiautomator)
or regular expression(e.g., poco\|airtest\|uiautomator\|airbase)
:return: pid or None
"""
... |
use ps |grep to check whether the process exists
:param package_name: package name(e.g., com.github.uiautomator)
or regular expression(e.g., poco\|airtest\|uiautomator\|airbase)
:return: pid or None
| _is_running | python | AirtestProject/Poco | poco/drivers/android/uiautomation.py | https://github.com/AirtestProject/Poco/blob/master/poco/drivers/android/uiautomation.py | Apache-2.0 |
def get_instance(cls, device):
"""
This is only a slot to store and get already initialized poco instance rather than initializing again. You can
simply pass the ``current device instance`` provided by ``airtest`` to get the AndroidUiautomationPoco instance.
If no such AndroidUiautomatio... |
This is only a slot to store and get already initialized poco instance rather than initializing again. You can
simply pass the ``current device instance`` provided by ``airtest`` to get the AndroidUiautomationPoco instance.
If no such AndroidUiautomationPoco instance, a new instance will be cre... | get_instance | python | AirtestProject/Poco | poco/drivers/android/uiautomation.py | https://github.com/AirtestProject/Poco/blob/master/poco/drivers/android/uiautomation.py | Apache-2.0 |
def json_parser(node, screen_size, switch_flag=False, ori='PORTRAIT'):
"""
:param node: node info {}
:param screen_size: ios.windows_size()
:param switch_flag: If it is an ipad , when on the desktop, all coordinates must be converted to vertical screen coordinates
:param ori: wda ['PORTRAIT', 'LAND... |
:param node: node info {}
:param screen_size: ios.windows_size()
:param switch_flag: If it is an ipad , when on the desktop, all coordinates must be converted to vertical screen coordinates
:param ori: wda ['PORTRAIT', 'LANDSCAPE',
'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT',
... | json_parser | python | AirtestProject/Poco | poco/drivers/ios/__init__.py | https://github.com/AirtestProject/Poco/blob/master/poco/drivers/ios/__init__.py | Apache-2.0 |
def getAppRefByBundleId(cls, bundleId):
"""
Get the top level element for the application with the specified
bundle ID, such as com.vmware.fusion.
"""
ra = AppKit.NSRunningApplication
# return value (apps) is always an array. if there is a match it will
# have an ... |
Get the top level element for the application with the specified
bundle ID, such as com.vmware.fusion.
| getAppRefByBundleId | python | AirtestProject/Poco | poco/drivers/osx/sdk/OSXUIFunc.py | https://github.com/AirtestProject/Poco/blob/master/poco/drivers/osx/sdk/OSXUIFunc.py | Apache-2.0 |
def getRoot(self):
"""
Dump a hierarchy immediately from target runtime and store into a Node (subclass of :py:class:`AbstractNode
<poco.sdk.AbstractNode>`) object.
Returns:
:py:class:`inherit from AbstractNode <Node>`: Each time a new node instance is created by latest hie... |
Dump a hierarchy immediately from target runtime and store into a Node (subclass of :py:class:`AbstractNode
<poco.sdk.AbstractNode>`) object.
Returns:
:py:class:`inherit from AbstractNode <Node>`: Each time a new node instance is created by latest hierarchy
data.
... | getRoot | python | AirtestProject/Poco | poco/freezeui/hierarchy.py | https://github.com/AirtestProject/Poco/blob/master/poco/freezeui/hierarchy.py | Apache-2.0 |
def dumpHierarchyImpl(self, node, onlyVisibleNode=True):
"""
Crawl the hierarchy tree using the simple DFS algorithm. The ``dump`` procedure is the engine independent as
the hierarchy structure is wrapped by :py:class:`AbstractNode <poco.sdk.AbstractNode>` and therefore the
``dump`` proc... |
Crawl the hierarchy tree using the simple DFS algorithm. The ``dump`` procedure is the engine independent as
the hierarchy structure is wrapped by :py:class:`AbstractNode <poco.sdk.AbstractNode>` and therefore the
``dump`` procedure can be algorithmized.
Following code demonstrates the... | dumpHierarchyImpl | python | AirtestProject/Poco | poco/sdk/AbstractDumper.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/AbstractDumper.py | Apache-2.0 |
def getAttr(self, attrName):
"""
Return the attributes of the node. The list below shows the most used basic attributes used during while writing
test code. The implementation class should return the corresponding value as soon as it retrieves its value. If
the value cannot be determined... |
Return the attributes of the node. The list below shows the most used basic attributes used during while writing
test code. The implementation class should return the corresponding value as soon as it retrieves its value. If
the value cannot be determined, the default value is obtained from sup... | getAttr | python | AirtestProject/Poco | poco/sdk/AbstractNode.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/AbstractNode.py | Apache-2.0 |
def getAvailableAttributeNames(self):
"""
Enumerate all available attribute names of this node. This method in base class returns the basic
attribute name by default. It is possible to add other customized or engine-specific attributes.
See the example below.
.. note:: It is rec... |
Enumerate all available attribute names of this node. This method in base class returns the basic
attribute name by default. It is possible to add other customized or engine-specific attributes.
See the example below.
.. note:: It is recommended to always call the super method and retu... | getAvailableAttributeNames | python | AirtestProject/Poco | poco/sdk/AbstractNode.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/AbstractNode.py | Apache-2.0 |
def enumerateAttrs(self):
"""
Enumerate all available attributes and yield the 2-tuple (name, value).
Yields:
Iterable<:obj:`str`, :obj:`ValueType`>
"""
for attrName in self.getAvailableAttributeNames():
yield attrName, self.getAttr(attrName) |
Enumerate all available attributes and yield the 2-tuple (name, value).
Yields:
Iterable<:obj:`str`, :obj:`ValueType`>
| enumerateAttrs | python | AirtestProject/Poco | poco/sdk/AbstractNode.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/AbstractNode.py | Apache-2.0 |
def compare(self, origin, pattern):
"""
Args:
origin (:obj:`str`): original string
pattern (:obj:`str`): Regexp pattern string
Returns:
bool: True if matches otherwise False.
"""
if origin is None or pattern is None:
return False
... |
Args:
origin (:obj:`str`): original string
pattern (:obj:`str`): Regexp pattern string
Returns:
bool: True if matches otherwise False.
| compare | python | AirtestProject/Poco | poco/sdk/DefaultMatcher.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/DefaultMatcher.py | Apache-2.0 |
def setTouchDownDuration(self, duration):
"""
Set touch down duration for each click operation.
Args:
duration (:obj:`float`): the duration in seconds
"""
warnings.warn("This implementation of poco does not support changing default touch down duration. "
... |
Set touch down duration for each click operation.
Args:
duration (:obj:`float`): the duration in seconds
| setTouchDownDuration | python | AirtestProject/Poco | poco/sdk/interfaces/input.py | https://github.com/AirtestProject/Poco/blob/master/poco/sdk/interfaces/input.py | Apache-2.0 |
def default_device():
"""
Get default device, if no device connected, connect to first android device.
:return:
"""
try:
return current_device()
except NoDeviceError:
return connect_device('Android:///') |
Get default device, if no device connected, connect to first android device.
:return:
| default_device | python | AirtestProject/Poco | poco/utils/device.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/device.py | Apache-2.0 |
def print_(*args, **kwargs):
"""The new-style print function for Python 2.4 and 2.5."""
fp = kwargs.pop("file", sys.stdout)
if fp is None:
return
def write(data):
if not isinstance(data, basestring):
data = str(data)
# If the file has ... | The new-style print function for Python 2.4 and 2.5. | print_ | python | AirtestProject/Poco | poco/utils/six.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/six.py | Apache-2.0 |
def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if PY2:
... |
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
| python_2_unicode_compatible | python | AirtestProject/Poco | poco/utils/six.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/six.py | Apache-2.0 |
def discretize(self, contact_id=0, accuracy=0.004, dt=0.001):
"""
Sample this motion track into discretized motion events.
Args:
contact_id: contact point id
accuracy: motion minimum difference in space
dt: sample time difference
"""
if not s... |
Sample this motion track into discretized motion events.
Args:
contact_id: contact point id
accuracy: motion minimum difference in space
dt: sample time difference
| discretize | python | AirtestProject/Poco | poco/utils/track.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/track.py | Apache-2.0 |
def get_target_pos(self, x, y):
"""
get real time resolution on device of target (x,y)
"""
offsetx, offsety, pw, ph = self._get_touch_resolution()
pos = [x * pw + offsetx, y * ph + offsety]
return pos |
get real time resolution on device of target (x,y)
| get_target_pos | python | AirtestProject/Poco | poco/utils/airtest/input.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/airtest/input.py | Apache-2.0 |
def _get_touch_resolution(self):
"""
get real time resolution on device if full screen
or window size if running in window mode
"""
if device_platform() == 'Android':
if self.use_render_resolution:
if self.render_resolution and len(self.render_resolut... |
get real time resolution on device if full screen
or window size if running in window mode
| _get_touch_resolution | python | AirtestProject/Poco | poco/utils/airtest/input.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/airtest/input.py | Apache-2.0 |
def wrapped(self, nodes, name, *args, **kwargs):
"""
:param self:
:param nodes: UI object proxy
:param name: attribute name
:param args:
:param kwargs:
:return:
"""
tolerance_exc_types = (
'NodeHasBeenRemovedException',
'R... |
:param self:
:param nodes: UI object proxy
:param name: attribute name
:param args:
:param kwargs:
:return:
| wrapped | python | AirtestProject/Poco | poco/utils/hrpc/utils.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/hrpc/utils.py | Apache-2.0 |
def close(self, status = 1000, reason = u''):
"""
Send Close frame to the client. The underlying socket is only closed
when the client acknowledges the Close frame.
status is the closing identifier.
reason is the reason for the close.
"""
try:
... |
Send Close frame to the client. The underlying socket is only closed
when the client acknowledges the Close frame.
status is the closing identifier.
reason is the reason for the close.
| close | python | AirtestProject/Poco | poco/utils/net/transport/simple_wss.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/net/transport/simple_wss.py | Apache-2.0 |
def sendFragmentStart(self, data):
"""
Send the start of a data fragment stream to a websocket client.
Subsequent data should be sent using sendFragment().
A fragment stream is completed when sendFragmentEnd() is called.
If data is a unicode object then the frame... |
Send the start of a data fragment stream to a websocket client.
Subsequent data should be sent using sendFragment().
A fragment stream is completed when sendFragmentEnd() is called.
If data is a unicode object then the frame is sent as Text.
If the data is a... | sendFragmentStart | python | AirtestProject/Poco | poco/utils/net/transport/simple_wss.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/net/transport/simple_wss.py | Apache-2.0 |
def sendMessage(self, data):
"""
Send websocket data frame to the client.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray object then the frame is sent as Binary.
"""
opcode = BINARY
if _check_unicode(data):
... |
Send websocket data frame to the client.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray object then the frame is sent as Binary.
| sendMessage | python | AirtestProject/Poco | poco/utils/net/transport/simple_wss.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/net/transport/simple_wss.py | Apache-2.0 |
def __init__(self, prototype=None):
""" Build method dispatcher.
Parameters
----------
prototype : object or dict, optional
Initial method mapping.
Examples
--------
Init object with method dictionary.
>>> Dispatcher({"sum": lambda a, b: a ... | Build method dispatcher.
Parameters
----------
prototype : object or dict, optional
Initial method mapping.
Examples
--------
Init object with method dictionary.
>>> Dispatcher({"sum": lambda a, b: a + b})
None
| __init__ | python | AirtestProject/Poco | poco/utils/simplerpc/jsonrpc/dispatcher.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/simplerpc/jsonrpc/dispatcher.py | Apache-2.0 |
def build_method_map(self, prototype, prefix=''):
""" Add prototype methods to the dispatcher.
Parameters
----------
prototype : object or dict
Initial method mapping.
If given prototype is a dictionary then all callable objects will
be added to dispa... | Add prototype methods to the dispatcher.
Parameters
----------
prototype : object or dict
Initial method mapping.
If given prototype is a dictionary then all callable objects will
be added to dispatcher.
If given prototype is an object then all p... | build_method_map | python | AirtestProject/Poco | poco/utils/simplerpc/jsonrpc/dispatcher.py | https://github.com/AirtestProject/Poco/blob/master/poco/utils/simplerpc/jsonrpc/dispatcher.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.