-
Notifications
You must be signed in to change notification settings - Fork 15
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
Upsert minds/datasources #44
Conversation
minds/datasources/datasources.py
Outdated
class Datasources: | ||
def __init__(self, client): | ||
self.api = client.api | ||
|
||
def create(self, ds_config: DatabaseConfig, replace=False): | ||
def create(self, ds_config: DatabaseConfig, replace=False, update=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the word 'replace' here. Without code inspection i can't predict what would happen if set this option to 'true'. For example, if i have mind 'X' with attached datasource 'Y', and then call datasource.create('Y', replace=True)
, then datasource 'Y' will be detached from mind 'X'. It does't look like 'replace'.
The presence of two options 'replace' and 'update' also make behavior undefined. What if i set both to 'true'?
Better will be to split this into two methods without 'replace' or 'update' arguments:
- create - raise error if ds exists
- upsert - update if exists, create otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove 'replace' parameter
@@ -53,6 +53,16 @@ def post(self, url, data): | |||
_raise_for_status(resp) | |||
return resp | |||
|
|||
def put(self, url, data): | |||
resp = requests.put( | |||
self.base_url + url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safer to use urllib.parse.urljoin
Added update parameter for minds.create and datasources.create.
If it is set: mind or datasource will be updated if it is exist
Dependent on https://github.com/mindsdb/mindsdb_gateway/pull/956