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

Don't allow deleting datasources if they are linked to a predictor #1324

Merged
merged 3 commits into from Jul 12, 2021

Conversation

ilia-tsyplenkov
Copy link
Contributor

@ilia-tsyplenkov ilia-tsyplenkov commented Jul 12, 2021

Fixes #1280

Perform simple checking before delete a datasource.
By setting force_datasource_removing to True in config any datasource would be deleted despite on any linked models.

Comment on lines 12 to +13
'data_source': fields.String(required=False, description='The data source it\'s learning from'),
'data_source_name': fields.String(required=False, description='The name of the datasource it\'s learning from'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this not the same as 'data_source'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, in general data_source points to the .csv file with data

models = request.native_interface.get_models()
linked_models = [x["name"] for x in models if x['data_source_name'] == name]
if linked_models:
return "Can't delete {} datasource because there are next models linked to it: {}".format(name, linked_models), 403
try:
request.default_store.delete_datasource(name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to check 'force_datasource_removing' in 'delete_datasource', because datasource can be removed not only through http api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that is a really good note. Fixed

@ilia-tsyplenkov ilia-tsyplenkov merged commit 47287f3 into staging Jul 12, 2021
@ilia-tsyplenkov ilia-tsyplenkov deleted the it_delete_datasource_without_models branch July 12, 2021 14:03
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.

None yet

2 participants