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

Add check for running experiments before deleting #612

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lab/lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ app.delete('/api/v1/datasets/:id', async (req, res, next) => {
let dataset = await db.datasets.findByIdAsync(dataset_id);

if (dataset == null) {
return res.send({ message: 'dataset ' + req.params.id + ' not found'});
return res.status(404).send({ message: 'dataset ' + req.params.id + ' not found'});
}

const dataset_file_id = db.toObjectID(dataset.files[0]._id);
Expand All @@ -648,7 +648,14 @@ app.delete('/api/v1/datasets/:id', async (req, res, next) => {
{"_dataset_id": {"$eq": dataset_id}},
{"_dataset_file_id": {"$eq": dataset_file_id}},
]}

let experiments = await db.experiments.find(query).toArrayAsync();
let runningExp = experiments.find(exp => exp._status == 'running');

if (runningExp) {
return res.status(409).send({message: 'cannot delete dataset, experiments running'});
}

let experimentIds = []; // maybe I don't need this one.
experiments.forEach(exp => {
experimentIds.push(exp._id);
Expand Down
Loading