Skip to content

Releases: databrickslabs/pytester

v0.2.2

19 Sep 10:47
@nfx nfx
f97e489
Compare
Choose a tag to compare
  • Use watchdog timeout to catalog properties (#48). This pull request introduces a new RemoveAfter property for catalogs, which allows for marking them for skipping by the watchdog. This change addresses the current implementation gap, which does not explicitly indicate when catalogs are being used. The new property will specify the time from which objects can be purged. A corresponding fixture watchdog_remove_after has been added to the list of available fixtures, and the make_catalog fixture has been updated to include this new property. Additionally, a timeout mechanism for catalogs has been implemented, which improves the system's efficiency and safety by marking catalogs as in use. A test for the make_catalog function has been included to ensure that the RemoveAfter entry is correctly added to the catalog properties. However, the specific call parameters for the catalogs.create method cannot be accurately determined in the test.
  • use tags instead of name suffix for queries (#47). This release introduces updates to the testing library for Databricks, enhancing the naming conventions for queries to improve readability and comprehension. The previous implementation used name suffixes, which have been replaced with watchdog query tags. The watchdog_purge_suffix fixture has been renamed to watchdog_remove_after, and the new make_query fixture has been added to the documentation. In addition, the make_query and create functions now accept an optional tags argument, and the query name is generated with a unique identifier. If tags are provided, the RemoveAfter tag is added. The original_query_tag is no longer hardcoded in the create function and has been removed. These changes improve the overall user experience and maintainability of the project.

Contributors: @ericvergnaud

v0.2.1

18 Sep 12:40
@nfx nfx
0fa2127
Compare
Choose a tag to compare
  • Moved remaining UCX integration tests and fixtures (#45). In this release, we have made significant changes to the UCX integration tests and fixtures, as indicated by multiple commit messages. Firstly, we have moved remaining UCX integration tests and fixtures, introducing a new PyTest fixture called Installation in the README.md file, providing instructions on how to add databricks-labs-pytester as a test-time dependency when using hatch as the build system. Additionally, we have added the make_feature_table fixture, which creates a Databricks feature table and cleans it up after the test, taking optional parameters for customization. We have also modified the mypy configuration in the pyproject.toml file to allow untyped imports during the type-checking process. In the compute.py file, we have updated the make_job fixture to return a function that creates a databricks.sdk.service.jobs.Job instance, and modified the create function to return the databricks.sdk.service.jobs.Job instance directly. We have also added a new fixture called make_feature_table in the plugin file, which simulates the lifecycle of a feature table in the machine learning service, with functions to generate a unique name and create/remove the feature table. In the test_catalog.py file, we have made changes to clean up the file and ensure proper logging of test events and errors. Overall, these changes aim to refactor, expand functionality, and improve user-friendliness for the adopters of the project, ensuring proper logging and debugging capabilities.
  • [internal] port over existing UCX integration tests (#44). Three new integration tests have been added to the UCX project to verify the functionality of the RemoveAfter property for tables and schemas. The test_remove_after_property_table and test_remove_after_property_schema tests create new tables and schemas, respectively, and check if the RemoveAfter property is included in their properties. However, these tests are still marked as TODO due to existing issues with the tables.get and schemas.get functions. In addition, existing UCX integration tests have been ported over, which include new functions for testing the removal of resources based on the RemoveAfter tag. These tests are located in the tests/integration/fixtures/test_compute.py file and test the removal of various types of resources, including jobs, clusters, warehouses, and instance pools. The tests ensure that the time until purge is less than the TEST_RESOURCE_PURGE_TIMEOUT value plus one hour and import the datetime module and the TEST_RESOURCE_PURGE_TIMEOUT constant from the watchdog fixture, as well as the logging and databricks.sdk.service.iam modules.

Contributors: @nfx

v0.2.0

18 Sep 10:47
@nfx nfx
0c5347c
Compare
Choose a tag to compare
  • Added acc and make_acc_group fixtures (#42). In this release, we have added two new fixtures, acc and make_acc_group, to the open-source library. The acc fixture provides a Databricks AccountClient object for use in tests, which can interact with the Databricks account API and automatically determines the account host from the DATABRICKS_HOST environment variable. The make_acc_group fixture is used for managing Databricks account groups, creating them with specified members and roles, and automatically deleting them after the test is complete. This fixture mirrors the behavior of the make_group fixture but interacts with the account client instead of the workspace client. These fixtures enable more comprehensive integration tests for the acc object and its various methods, enhancing the testing and management of Databricks account groups.

Contributors: @nfx

v0.1.1

18 Sep 09:46
@nfx nfx
2bc7842
Compare
Choose a tag to compare
  • Fixed nightly CI builds (#40). In this release, we have removed the no-cheat GitHub Actions workflow that checked for disables pylint directives in new code. We have also updated the pytest requirement version to ~8.3.3 and added badges for Python version support and lines of code to the README file. The permissions.py file in the databricks/labs/pytester/fixtures directory has been updated to fix nightly CI builds by improving import statements and updating types. The SqlPermissionLevel class has been imported from the databricks.sdk.service.sql module, and an existing test case has been updated to use this new permission level for SQL-specific queries. Additionally, we have updated the version constraints for three dependencies in the pyproject.toml file to allow for more flexibility in selecting compatible library versions. These changes may simplify the project's GitHub Actions workflows, reduce maintenance overhead, and enhance the testing process and code quality.

Contributors: @nfx

v0.1.0

17 Sep 20:36
@nfx nfx
47a00ec
Compare
Choose a tag to compare
  • Added Databricks Connect fixture. A new fixture named spark has been added to the codebase, providing a Databricks Connect Spark session for testing purposes. The fixture requires the databricks-connect package to be installed and takes a WorkspaceClient object as an argument. It first checks if a cluster_id is present in the environment, and if not, it skips the test and raises a message. The fixture then ensures that the cluster is running and attempts to import the DatabricksSession class from the databricks.connect module. If the import fails, it skips the test and raises a message. This new fixture enables easier testing of Databricks Connect functionality, reducing boilerplate code required to set up a Spark session within tests. Additionally, a new is_in_debug fixture has been added, although there is no further documentation or usage examples provided for it.
  • Added make_*_permissions fixtures. In this release, we have added new fixtures to the pytester plugin for managing permissions in Databricks. These fixtures include make_alert_permissions, make_authorization_permissions, make_cluster_permissions, make_cluster_policy_permissions, make_dashboard_permissions, make_directory_permissions, make_instance_pool_permissions, make_job_permissions, make_notebook_permissions, make_pipeline_permissions, make_query_permissions, make_registered_model_permissions, make_repository_permissions, make_serving_endpoint_permissions, make_warehouse_permissions, make_workspace_file_permissions, and make_workspace_file_path_permissions. These fixtures allow for easier testing of functionality that requires managing permissions in Databricks, and are used for managing permissions for various Databricks resources such as alerts, authorization, clusters, cluster policies, dashboards, directories, instance pools, jobs, notebooks, pipelines, queries, registered models, repositories, serving endpoints, warehouses, and workspace files. Additionally, a new make_notebook_permissions fixture has been introduced in the test_permissions.py file for integration tests, which allows for more comprehensive testing of the IAM system's behavior when handling notebook permissions.
  • Added make_catalog fixture. A new fixture, make_catalog, has been added to the codebase to facilitate testing with specific catalogs, ensuring isolation and reproducibility. This fixture creates a catalog, returns its information, and removes the catalog after the test is complete. It can be used in conjunction with other fixtures such as ws, sql_backend, and make_random. The fixture is utilized in the updated test_catalog_fixture integration test function, which now includes new arguments make_catalog, make_schema, and make_table. These fixtures create catalog, schema, and table objects, enabling more comprehensive testing of the catalog, schema, and table creation functionality. Please note that catalogs created using this fixture are not currently protected from being deleted by the watchdog.
  • Added make_catalog, make_schema, and make_table fixtures (#33). In this release, we have updated the databricks-labs-blueprint package dependency to databricks-labs-lsql~=0.10 and added several fixtures to the codebase to improve the reliability and maintainability of the test suite. We have introduced three new fixtures make_catalog, make_schema, and make_table that are used for creating and managing test catalogs, schemas, and tables, respectively. These fixtures enable the creation of arbitrary test data and simplify testing by allowing predictable and consistent setup and teardown of test data for integration tests. Additionally, we have added several debugging fixtures, including debug_env_name, debug_env, env_or_skip, and sql_backend, to aid in testing DataBricks features related to SQL, environments, and more. The make_udf fixture has also been added for testing user-defined functions in DataBricks. These new fixtures and methods will assist in testing the project's functionality and ensure that the code is working as intended, making the tests more maintainable and easier to understand.
  • Added make_cluster documentation. The make_cluster fixture has been updated with new functionality and improvements. It now creates a Databricks cluster with specified configurations, waits for it to start, and cleans it up after the test, returning a function to create clusters. The cluster_id attribute is accessible from the returned object. The fixture accepts several keyword arguments: single_node to create a single-node cluster, cluster_name to specify a cluster name, spark_version to set the Spark version, and autotermination_minutes to determine when the cluster should be automatically terminated. The ws and make_random parameters have been removed. The commit also introduces a new test function, test_cluster, that creates a single-node cluster and outputs a message indicating the creation. Documentation for the make_cluster function has been added, and the make_cluster_policy function remains unchanged.
  • Added make_experiment fixture. In this release, we introduce the make_experiment fixture in the databricks.labs.pytester.fixtures.ml module, facilitating the creation and cleanup of Databricks Experiments for testing purposes. This fixture accepts optional path and experiment_name parameters and returns a databricks.sdk.service.ml.CreateExperimentResponse object. Additionally, make_experiment_permissions has been added for managing experiment permissions. In the permissions.py file, the _make_permissions_factory function replaces the previous _make_redash_permissions_factory, enhancing the code's maintainability and extensibility. Furthermore, a make_experiment fixture has been added to the plugin.py file for creating experiments with custom names and descriptions. Lastly, a test_experiments function has been included in the tests/integration/fixtures directory, utilizing make_group, make_experiment, and make_experiment_permissions fixtures to create experiments and assign group permissions.
  • Added make_instance_pool documentation. In this release, the make_instance_pool fixture has been updated with added documentation, and the usage example has been slightly modified. The fixture now accepts optional keyword arguments for the instance pool name and node type ID, with default values set for each. The make_random fixture is still required for generating unique names. Additionally, a new function, log_workspace_link, has been updated to accept a new parameter anchor for controlling the inclusion of an anchor (#) in the generated URL. New test functions test_instance_pool and test_cluster_policy have been added to enhance the integration testing of the compute system, providing more comprehensive coverage for instance pools and cluster policies. Furthermore, documentation has been added for the make_instance_pool fixture. Lastly, three test functions, test_cluster, test_instance_pool, and test_job, have been removed, but the setup functions for these tests are retained, indicating a possible streamlining of the codebase.
  • Added make_job documentation. The make_job fixture has been updated with additional arguments and improved documentation. It now accepts notebook_path, name, spark_conf, and libraries as optional keyword arguments, and can accept any additional arguments to be passed to the WorkspaceClient.jobs.create method. If no notebook_path or tasks argument is provided, a random notebook is created and a single task with a notebook task is run using the latest Spark version and a single worker cluster. The fixture has been improved to manage Databricks jobs and clean them up after testing. Additionally, documentation has been added for the make_job function and the test_job function in the test fixtures file. The test_job function, which created a job and logged its creation, has been removed, and the test_cluster and test_pipeline functions remain unchanged. The os module is no longer imported in this file.
  • Added make_model fixture. A new pytest fixture, make_model, has been added to the codebase for the open-source library. This fixture facilitates the creation and automatic cleanup of Databricks Models during tests, returning a GetModelResponse object. The optional model_name parameter allows for customization, with a default value of dummy-*. The make_model fixture can be utilized in conjunction with other fixtures such as ws, make_random, and make_registered_model_permissions, streamlining the testing of model-related functionality. Additionally, a new test function, test_models, has been introduced, utilizing make_model, make_group, and make_registered_model_permissions fixtures to test model management within the system. This new feature enhances the library's testing capabilities, making it easier to create, configure, and manage models and related resources during test execution.
  • Added make_pipeline fixture. A new fixture named make_pipeline has been added to the project, which facilitates the creation and cleanup of a Delta Live Tables Pipeline after testing. This fixture is added to the compute.py file and takes optional keyword arguments such as name, libraries, and clusters. It generates a random name, creates a disposable notebook with random libraries, and creates a single node cluster with 16GB memory and local disk if these arguments are not provided. The fixture returns a function to create pipelines, resulting in a CreatePipelineResponse instance. Additionally, a new integration test has been added to test the functionality of this fixture, and it logs information about the created pipeline for debugging and inspection purposes. T...
Read more