Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a deepcopy of config in api client #172

Merged
merged 11 commits into from
Jun 21, 2023
Merged

Create a deepcopy of config in api client #172

merged 11 commits into from
Jun 21, 2023

Conversation

kartikgupta-db
Copy link
Contributor

Changes

  • We do not want the config to change after API client has been initialised. One API client should be linked to 1 set of Config variables ONLY.
  • make test run locally
  • make fmt applied
  • relevant integration tests applied

@kartikgupta-db kartikgupta-db requested a review from nfx June 14, 2023 12:18

@property
def config(self):
return deepcopy(self._config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure it's a good thing. w.config.authenticate() should reuse the same refresh token

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Riggghttt. Completely forgot about this. We can atleast restrict the initial config form being passed around. If they directly reuse config from client, or edit it, atleast they know why stuff is changing.

@kartikgupta-db kartikgupta-db requested a review from nfx June 14, 2023 13:31
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm still not sure that we should do it this way. if we want to prevent config from being modified, we can add these in Config:

    self._init_auth()
    self._initialized = True

and these in ConfigAttribute:

    def __set__(self, cfg: 'Config', value: any):
        if cfg._initialized: raise ValueError(...)
        cfg._inner[self.name] = self.transform(value)

and test in in DBR for dbr-native auth

main.py Outdated
from databricks.connect import DatabricksSession
from databricks.sdk.core import Config

config = Config(host='https://x', token='x', product="xapp", product_version="0.0.0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file

@kartikgupta-db kartikgupta-db requested review from nfx and mgyucht June 16, 2023 10:09
Signed-off-by: Kartik Gupta <88345179+kartikgupta-db@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2023

Codecov Report

Patch coverage: 90.00% and project coverage change: +0.01 🎉

Comparison is base (5052185) 53.28% compared to head (0fb3e69) 53.30%.

❗ Current head 0fb3e69 differs from pull request most recent head 461d78b. Consider uploading reports for the commit 461d78b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #172      +/-   ##
==========================================
+ Coverage   53.28%   53.30%   +0.01%     
==========================================
  Files          30       30              
  Lines       18344    18350       +6     
==========================================
+ Hits         9775     9781       +6     
  Misses       8569     8569              
Impacted Files Coverage Δ
databricks/sdk/__init__.py 74.10% <66.66%> (+0.23%) ⬆️
databricks/sdk/core.py 67.38% <100.00%> (+0.22%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@nfx nfx merged commit 2d9da3f into main Jun 21, 2023
@nfx nfx deleted the deepcopy-config branch June 21, 2023 11:30
@nfx nfx mentioned this pull request Jun 21, 2023
nfx added a commit that referenced this pull request Jun 21, 2023
* Added Sphinx documentation
([#184](#184),
[#191](#191),
[#183](#183),
[#193](#193)).
* Integrated with ReadTheDocs service
([#188](#188),
[#189](#189),
[#190](#190)).
* Create a deepcopy of config in api client
([#172](#172)).
* Fix client/secret auth
([#186](#186)).
* Increase DBFS copy buffer size
([#185](#185)).
* Move classes to other repository
([#192](#192)).
* Relax `requests` version upper bound to <3
([#138](#138)).
@pietern pietern mentioned this pull request Jun 23, 2023
3 tasks
nfx pushed a commit that referenced this pull request Jun 28, 2023
## Changes

* Modification to template to regenerate the change made in #172 
* Use fully qualified type names instead of aliasing them on import
(e.g. `compute.ComputeSpec`)
* Update integration tests to accommodate type name changes in the spec.

Spec: 8687781fe17d83694a0c67396e04c70830b0d398 (2023-06-23)

Type renames:
* `compute.BaseClusterInfo -> compute.ClusterSpec`
* `compute.ClusterInfo -> compute.ClusterDetails`
* `jobs.JobTaskSettings -> jobs.Task`
* `jobs.RunSubmitTaskSettings -> jobs.SubmitTask`
* `jobs.JobWebhookNotifications -> jobs.WebhookNotifications`
* `jobs.CreateJobFormat -> jobs.Format`
* `jobs.GitSourceGitProvider -> jobs.GitProvider`
* `jobs.FileArrivalTriggerSettings ->
jobs.FileArrivalTriggerConfiguration`

## Tests

- [x] `make test` run locally
- [x] `make fmt` applied
- [x] relevant integration tests applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants