You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,40 +3,40 @@
3
3
## First Principles
4
4
5
5
We must use the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/) in this project. It is a toolkit for our project.
6
-
If something doesn't naturally belong to the `WorkspaceClient`, it needs to go through a "mixin" process before it can be used with the SDK.
7
-
Imagine the `WorkspaceClient` as the main control center, and the "mixin" process as a way to adapt other things to work with it.
6
+
If something doesn't naturally belong to the `WorkspaceClient`, it must go through a "mixin" process before it can be used with the SDK.
7
+
Imagine the `WorkspaceClient` as the main control center and the "mixin" process as a way to adapt other things to work with it.
8
8
You can find an example of how mixins are used with `StatementExecutionExt`. There's a specific example of how to make something
9
9
work with the WorkspaceClient using `StatementExecutionExt`. This example can help you understand how mixins work in practice.
10
10
11
11
## Code Organization
12
12
13
-
When you're writing code, make sure to divide it into two main parts: **Components for API Interaction** and **Components for Business Logic**.
14
-
API Interaction should only deal with talking to external systems through APIs. They are usually integrationtested and mocks are simpler.
13
+
When writing code, divide it into two main parts: **Components for API Interaction** and **Components for Business Logic**.
14
+
API Interaction should only deal with talking to external systems through APIs. They are usually integration-tested, and mocks are simpler.
15
15
Business Logic handles the actual logic of your application, like calculations, data processing, and decision-making.
16
16
17
17
_Keep API components simple._ In the components responsible for API interactions, try to keep things as straightforward as possible.
18
-
Don't overload them with lots of complex logic; instead, focus on making API calls and handling the data from those calls.
18
+
Refrain from overloading them with complex logic; instead, focus on making API calls and handling the data from those calls.
19
19
20
20
_Inject Business Logic._ If you need to use business logic in your API-calling components, don't build it directly there.
21
21
Instead, inject (or pass in) the business logic components into your API components. This way, you can keep your API components
22
22
clean and flexible, while the business logic remains separate and reusable.
23
23
24
-
_Test your Business Logic._ It's essential to thoroughly test your business logic to ensure it works correctly. When writing
25
-
unit tests, avoid making actual API calls - unit tests are executed for every pull request and **_take seconds to complete_**.
24
+
_Test your Business Logic._ It's essential to test your business logic to ensure it works correctly and thoroughly. When writing
25
+
unit tests, avoid making actual API calls - unit tests are executed for every pull request, and **_take seconds to complete_**.
26
26
For calling any external services, including Databricks Connect, Databricks Platform, or even Apache Spark, unit tests have
27
-
to use "mocks" or fake versions of the APIs to simulate their behavior. This makes it easier to test your code and catch any
27
+
to use "mocks" or fake versions of the APIs to simulate their behavior. This makes testing your code more manageable and catching any
28
28
issues without relying on external systems. Focus on testing the edge cases of the logic, especially the scenarios where
29
29
things may fail. See [this example](https://github.com/databricks/databricks-sdk-py/pull/295) as a reference of an extensive
30
30
unit test coverage suite and the clear difference between _unit tests_ and _integration tests_.
31
31
32
32
## Integration Testing Infrastructure
33
33
34
-
All new code additions must be accompanied by integration tests. Integration tests help us validate that various parts of
34
+
Integration tests must accompany all new code additions. Integration tests help us validate that various parts of
35
35
our application work correctly when they interact with each other or external systems. This practice ensures that our
36
36
software _**functions as a cohesive whole**_. Integration tests run every night and take approximately 15 minutes
37
-
for the whole test suite to complete.
37
+
for the entire test suite to complete.
38
38
39
-
For integration tests, we encourage using predefined test infrastructure provided through environment variables.
39
+
We encourage using predefined test infrastructure provided through environment variables for integration tests.
40
40
These fixtures are set up in advance to simulate specific scenarios, making it easier to test different use cases. These
41
41
predefined fixtures enhance test consistency and reliability and point to the real infrastructure used by integration
42
42
testing. See [Unified Authentication Documentation](https://databricks-sdk-py.readthedocs.io/en/latest/authentication.html)
@@ -54,19 +54,19 @@ for the latest reference of environment variables related to authentication.
54
54
-`TEST_DEFAULT_WAREHOUSE_ID`: This variable contains the identifier for the default warehouse used in testing. The value
55
55
resembles a unique warehouse ID, like "49134b80d2...".
56
56
-`TEST_INSTANCE_POOL_ID`: This environment variable stores the identifier for the instance pool used in testing.
57
-
You must utilise existing instance pools as much as possible for the sake of cluster startup time and cost reduction.
57
+
You must utilise existing instance pools as much as possible for cluster startup time and cost reduction.
58
58
The value is a unique instance pool ID, like "0824-113319-...".
59
59
-`TEST_LEGACY_TABLE_ACL_CLUSTER_ID`: This variable holds the identifier for the cluster used in testing legacy table
60
60
access control. The value is a unique cluster ID, like "0824-161440-...".
61
61
-`TEST_USER_ISOLATION_CLUSTER_ID`: This environment variable contains the identifier for the cluster used in testing
62
62
user isolation. The value is a unique cluster ID, like "0825-164947-...".
63
63
64
-
We encourage you to leverage the extensive set of [pytest fixtures](https://docs.pytest.org/en/latest/explanation/fixtures.html#about-fixtures).
65
-
These fixtures follow a consistent naming pattern, starting with "make_". These are functions that can be called multiple
64
+
We'd like to encourage you to leverage the extensive set of [pytest fixtures](https://docs.pytest.org/en/latest/explanation/fixtures.html#about-fixtures).
65
+
These fixtures follow a consistent naming pattern, starting with "make_". These functions can be called multiple
66
66
times to _create and clean up objects as needed_ for your tests. Reusing these fixtures helps maintain clean and consistent
67
-
test setups across the codebase. In cases where your tests require unique fixture setups, it's crucial to keep the wall
68
-
clock time of fixture initialization under one second. Fast fixture initialization ensures that tests run quickly, reducing
69
-
development cycle times and allowing for faster feedback during development.
67
+
test setups across the codebase. In cases where your tests require unique fixture setups, keeping the wall
68
+
clock time of fixture initialization under one second is crucial. Fast fixture initialization ensures that tests run quickly, reducing
69
+
development cycle times and allowing for more immediate feedback during development.
70
70
71
71
```python
72
72
from databricks.sdk.service.workspace import AclPermission
By adhering to these guidelines, we ensure that our integration tests are robust, efficient, and easily maintainable. This,
87
+
Adhering to these guidelines ensures that our integration tests are robust, efficient, and easily maintainable. This,
88
88
in turn, contributes to the overall reliability and quality of our software.
89
89
90
90
Currently, VSCode IDE is not supported, as it does not offer interactive debugging single integration tests.
@@ -144,6 +144,8 @@ Here are the example steps to submit your first contribution:
144
144
9. .. fix if any
145
145
10.`git commit -a`. Make sure to enter meaningful commit message title.
146
146
11.`git push origin FEATURENAME`
147
-
12. go to GitHub UI and create PR. Alternatively, `gh pr create` (if you have [GitHub CLI](https://cli.github.com/) installed).
148
-
Make sure to use meaningful pull request title, because it'll appear in the release notes.
149
-
13. announce PR for the review
147
+
12. Go to GitHub UI and create PR. Alternatively, `gh pr create` (if you have [GitHub CLI](https://cli.github.com/) installed).
148
+
Use a meaningful pull request title because it'll appear in the release notes. Use `Resolves #NUMBER` in pull
149
+
request description to [automatically link it](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue)
0 commit comments