Skip to content

Commit

Permalink
Only store hdf5 project data temporarily for parsing unless specified…
Browse files Browse the repository at this point in the history
… by the user
  • Loading branch information
Spurs20 committed Oct 1, 2024
1 parent 76117bf commit 3b441bb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
10 changes: 5 additions & 5 deletions packages/slycat/web/server/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ def numeric_order(x):
if '.h5' in self._aids[1] or '.hdf5' in self._aids[1]:
slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
files, self._aids, **self._kwargs)
if isinstance(self._aids[0], list):
slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
files, self._aids[0], **self._kwargs)
elif isinstance(self._aids[0], list):
slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
files, self._aids[0], **self._kwargs)
else:
slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
files, self._aids, **self._kwargs)
if model["model-type"] == "parameter-image" and self.useProjectData == True:
files, self._aids, **self._kwargs)
if model["model-type"] == "parameter-image" and self.useProjectData == True and '.h5' not in self._aids[1] and '.hdf5' not in self._aids[1]:
# Use project data
slycat.web.server.handlers.create_project_data(self._mid, self._aids, files)
except Exception as e:
Expand Down
16 changes: 11 additions & 5 deletions web-server/plugins/slycat-hdf5-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def parse_file(file, model, database):

def parse(database, model, input, files, aids, **kwargs):
# Read HDF5 file
slycat.web.server.handlers.create_project_data(model['_id'], aids, files)
start = time.time()

# parsed = [parse_file(file, model, database) for file in files]
Expand All @@ -89,10 +88,17 @@ def parse(database, model, input, files, aids, **kwargs):
# slycat.web.server.put_model_arrayset_data(database, model, aid, "%s/.../..." % array_index, combined_data)

end = time.time()
model = database.get("model", model['_id'])
slycat.web.server.put_model_parameter(database, model, "error-messages", "")
model["db_creation_time"] = (end - start)
database.save(model)
database = slycat.web.server.database.couchdb.connect()
model = database.get("model", model["_id"])
with slycat.web.server.database.couchdb.db_lock:
model["db_creation_time"] = (end - start)
database.save(model)
# If the user selected to not save project data, this will only be temporary during the wizard to parse the HDF5 file
slycat.web.server.handlers.create_project_data(model['_id'], aids, files)
slycat.web.server.put_model_parameter(database, model, "error-messages", "")
# model["db_creation_time"] = (end - start)
# model = database.get("model", model['_id'])
# database_curr.save(model)

def register_slycat_plugin(context):
context.register_parser("slycat-hdf5-parser", "HDF5", ["table"], parse)
23 changes: 21 additions & 2 deletions web-server/plugins/slycat-parameter-image/js/wizard-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ function constructor(params) {
component.cancel = function () {
component.smb_wizard_login_root.unmount();
if (component.model._id()) {
client
.get_project_data_in_model_fetch({
client.get_project_data_in_model_fetch({
mid: component.model._id(),
})
.then((did) => {
Expand Down Expand Up @@ -561,6 +560,26 @@ function constructor(params) {
mid: component.model._id(),
success : (results) =>
{
if (component.model._id() && component.useProjectData() == false) {
client.get_project_data_in_model_fetch({
mid: component.model._id(),
})
.then((did) => {
// if the data id isn't empty
// delete model first
client.delete_model_fetch({ mid: component.model._id() }).then(() => {
// Get list of model ids project data is used in
if (did.length >= 1) {
client.get_project_data_parameter_fetch({ did: did, param: "mid" }).then((models) => {
// if there are no more models using that project data, delete it
if (models && models.length === 0) {
client.delete_project_data_fetch({ did: did });
}
});
}
});
});
}
component.finish();
}
})
Expand Down

1 comment on commit 3b441bb

@Spurs20
Copy link
Contributor Author

@Spurs20 Spurs20 commented on 3b441bb Oct 9, 2024

Choose a reason for hiding this comment

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

Closes #1177

Please sign in to comment.