Skip to content

Commit

Permalink
Merge pull request #951 from ITISFoundation/merge_to_staging
Browse files Browse the repository at this point in the history
Merge to staging the following fixes:

- Fix endpoint of s3 in production (#943)
- Fix simcore.s3 tree loading issue (#947)
- Add context manager for long standing connections (#949)
  • Loading branch information
pcrespov authored Jul 16, 2019
2 parents 1313669 + 24ae516 commit 0e7dc80
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
45 changes: 29 additions & 16 deletions services/sidecar/src/sidecar/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _parse_progress(line: str):

def _log_accumulated_logs(new_log: str, acc_logs: List[str], time_logs_sent: float):
# do not overload broker with messages, we log once every 1sec
TIME_BETWEEN_LOGS_S = 1.0
TIME_BETWEEN_LOGS_S = 2.0
acc_logs.append(new_log)
now = time.monotonic()
if (now - time_logs_sent) > TIME_BETWEEN_LOGS_S:
Expand Down Expand Up @@ -329,30 +329,43 @@ def process(self):

log.debug('DONE Processing Pipeline %s and node %s from container', self._task.project_id, self._task.internal_id)

def run(self):
connection = pika.BlockingConnection(self._pika.parameters)

@contextmanager
def safe_log_channel(self):
connection = pika.BlockingConnection(self._pika.parameters)
channel = connection.channel()
channel.exchange_declare(exchange=self._pika.log_channel, exchange_type='fanout', auto_delete=True)
try:
yield channel
finally:
connection.close()

def run(self):
with self.safe_log_channel() as channel:
msg = "Preprocessing start..."
self._log(channel, msg)

msg = "Preprocessing start..."
self._log(channel, msg)
self.preprocess()
msg = "...preprocessing end"
self._log(channel, msg)

msg = "Processing start..."
self._log(channel, msg)
with self.safe_log_channel() as channel:
msg = "...preprocessing end"
self._log(channel, msg)
msg = "Processing start..."
self._log(channel, msg)

self.process()
msg = "...processing end"
self._log(channel, msg)

msg = "Postprocessing start..."
self._log(channel, msg)
with self.safe_log_channel() as channel:
msg = "...processing end"
self._log(channel, msg)
msg = "Postprocessing start..."
self._log(channel, msg)

self.postprocess()
msg = "...postprocessing end"
self._log(channel, msg)
connection.close()

with self.safe_log_channel() as channel:
msg = "...postprocessing end"
self._log(channel, msg)


def postprocess(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ qx.Class.define("qxapp.component.widget.logger.LoggerView", {

this.__createInitMsg();

this.__textfield.addListener("changeValue", this.__applyFilters, this);
this.__textFilterField.addListener("changeValue", this.__applyFilters, this);
},

events: {},
Expand Down Expand Up @@ -137,7 +137,7 @@ qx.Class.define("qxapp.component.widget.logger.LoggerView", {

members: {
__currentNodeButton: null,
__textfield: null,
__textFilterField: null,
__logModel: null,
__logView: null,
__messengerColors: null,
Expand All @@ -155,12 +155,12 @@ qx.Class.define("qxapp.component.widget.logger.LoggerView", {
toolbar.add(currentNodeButton);

toolbar.add(new qx.ui.toolbar.Separator());
this.__textfield = new qx.ui.form.TextField().set({
const textFilterField = this.__textFilterField = new qx.ui.form.TextField().set({
appearance: "toolbar-textfield",
liveUpdate: true,
placeholder: this.tr("Filter")
});
toolbar.add(this.__textfield, {
toolbar.add(textFilterField, {
flex: 1
});

Expand Down Expand Up @@ -239,9 +239,9 @@ qx.Class.define("qxapp.component.widget.logger.LoggerView", {
const workbench = this.getWorkbench();
const node = workbench.getNode(nodeId);
if (node) {
this.__textfield.setValue(node.getLabel());
this.__textFilterField.setValue(node.getLabel());
} else {
this.__textfield.setValue("");
this.__textFilterField.setValue("");
}
},

Expand Down Expand Up @@ -321,7 +321,7 @@ qx.Class.define("qxapp.component.widget.logger.LoggerView", {
return;
}

this.__logModel.setFilterString(this.__textfield.getValue());
this.__logModel.setFilterString(this.__textFilterField.getValue());
this.__logModel.setFilterLogLevel(this.getLogLevel());
this.__logModel.reloadData();
},
Expand Down
16 changes: 8 additions & 8 deletions services/web/client/source/class/qxapp/desktop/StudyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ qx.Class.define("qxapp.desktop.StudyEditor", {
initDefault: function() {
const study = this.getStudy();

const treeView = this.__nodesTree = new qxapp.component.widget.NodesTree(study.getName(), study.getWorkbench());
treeView.addListener("addNode", () => {
const nodesTree = this.__nodesTree = new qxapp.component.widget.NodesTree(study.getName(), study.getWorkbench());
nodesTree.addListener("addNode", () => {
this.__addNode();
}, this);
treeView.addListener("removeNode", e => {
nodesTree.addListener("removeNode", e => {
const nodeId = e.getData();
this.__removeNode(nodeId);
}, this);
this.__sidePanel.addOrReplaceAt(new qxapp.desktop.PanelView(this.tr("Service tree"), treeView), 0);
this.__sidePanel.addOrReplaceAt(new qxapp.desktop.PanelView(this.tr("Service tree"), nodesTree), 0);

const extraView = this.__extraView = new qxapp.component.metadata.StudyInfo(study);
this.__sidePanel.addOrReplaceAt(new qxapp.desktop.PanelView(this.tr("Study information"), extraView), 1);
Expand Down Expand Up @@ -176,15 +176,15 @@ qx.Class.define("qxapp.desktop.StudyEditor", {
});

const workbenchUI = this.__workbenchUI;
const treeView = this.__nodesTree;
treeView.addListener("changeSelectedNode", e => {
const nodesTree = this.__nodesTree;
nodesTree.addListener("changeSelectedNode", e => {
const node = workbenchUI.getNodeUI(e.getData());
if (node && node.classname.includes("NodeUI")) {
node.setActive(true);
}
});
workbenchUI.addListener("changeSelectedNode", e => {
treeView.nodeSelected(e.getData());
nodesTree.nodeSelected(e.getData());
});
},

Expand Down Expand Up @@ -233,7 +233,7 @@ qx.Class.define("qxapp.desktop.StudyEditor", {
}
}

this.__treeView.nodeSelected(nodeId, openNodeAndParents);
this.__nodesTree.nodeSelected(nodeId, openNodeAndParents);
this.__loggerView.setCurrentNodeId(nodeId);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ qx.Class.define("qxapp.file.FilesTreePopulator", {
},

populateMyLocation: function(locationId = null) {
if (locationId) {
if (locationId !== null) {
const locationModel = this.__getLocationModel(locationId);
if (locationModel) {
locationModel.getChildren().removeAll();
Expand Down

0 comments on commit 0e7dc80

Please sign in to comment.