SlicerMorph / SlicerScriptEditor

a simple programming editor for Slicer based on monaco
BSD 2-Clause "Simplified" License
4 stars 2 forks source link

Terminal stdout is noisy and code completion is partial. #43

Open chir-set opened 1 month ago

chir-set commented 1 month ago

These messages appear in the terminal (not Python console) very often:

Running "json.dumps(list(globals().keys()))" result is "[\"name\", \"doc\", ... very loooooong list... \"json\"]"

In "PyFileFileWriter" class, function 'canWriteObject' is expected to return a boolean !

bool qSlicerSubjectHierarchyPluginHandler::registerPlugin(qSlicerSubjectHierarchyAbstractPlugin *) : SubjectHierarchy plugin "SavePyFile" is already registered

These ones appear in the Python terminal too:

[Qt] at async h (file:///home/user/programs/Slicer/slicer.org/Extensions-32977/SlicerEditor/lib/Slicer-5.7/qt-scripted-modules/Resources/monaco-editor/node_modules/monaco-editor/min/vs/editor/editor.main.js:641:26077) [Qt] at async Promise.all (index 0)

[Qt] "file:///home/user/programs/Slicer/slicer.org/Extensions-32977/SlicerEditor/lib/Slicer-5.7/qt-scripted-modules/Resources/monaco-editor/node_modules/monaco-editor/min/vs/base/worker/workerMain.js#editorWorkerService" 9 "Failed trying to load default language strings TypeError: Failed to fetch" [Qt] Failed trying to load default language strings TypeError: Failed to fetch

Some of these suggest something went wrong.

Indeed, code completion works partially.

For example, on typing:

pts = vtk.vtkPoi

the dropdown list filters anything with 'vtkPoin*'.

However, on continuation:

pts = vtk.vtkPoints()
pts.InsertNex

the dropdown list does not show anything with 'InsertNex*'.

I'm on Arch Linux, Qt5 5.15.14+kde+r143-1. Qt6 coexists, but Slicer does not use it. It's self-built Slicer and SlicerEditor of course.

I think it should be a great tool when the usability gets improved.

Regards.

pieper commented 1 month ago

Running "json.dumps(list(globals().keys()))" result is "["name", "doc", ... very loooooong list... "json"]"

That's due to this line. It is probably overkill for production but it's helpful when developing this kind of app. Probably there should be a web widget property that controls whether the command and result should be printed or not.

Some of the other outputs need to be debugged in the scripted writer and the subject hierarchy plugin code or in the monaco config. @oothomas it would be great if you could investigate.

pts = vtk.vtkPoints() pts.InsertNex

the dropdown list does not show anything with 'InsertNex*'.

This is expected because unlike in the python console the first line hasn't been executed yet, so the string pts doesn't correspond to an object yet. This is going to be an interesting question for next steps of development for project. Perhaps we'll want to have a console-like mode where lines are executed on Enter and then the objects are available for completion on the next line. That would be pretty compatible with the way I use external editors for test scenarios, where I write code that can be re-executed from the top to recreate the test, often with time-consuming parts like data loading bracketed in try/except blocks. Then I experiment with code by going back and forth to the console and pasting what works into my editor buffer. It would be great if the SlicerEditor could unify this into a seamless operation, but we need to expose this in a way that makes sense.

chir-set commented 1 month ago

That's due to this line.

Good to know, would commenting it in a local branch be a good idea for someone that won't debug in this particular case?

This is expected... hasn't been executed yet

Ok, then more can't be expected now.

Thank you.

pieper commented 1 month ago

That's due to this line.

Good to know, would commenting it in a local branch be a good idea for someone that won't debug in this particular case?

Yes, you could comment it out to clean things up locally, but adding a boolean property to the qSlicerWebWidget named something like debugEvalRequests that is false by default would be a nice addition since we probably don't want that much printing unless we are developing or debugging.