CARTA wrapper script #65
Replies: 7 comments 2 replies
-
I can't seem to upload a Python file, so here's the contents of
|
Beta Was this translation helpful? Give feedback.
-
Thanks for this feedback, @Jordatious . I will respond in more detail later, but very briefly: 1 and 3 are Electron packaging issues -- I'll let @ajm-asiaa comment. I agree that the normal Electron app executable should support scripting out of the box -- this would require a) a way to pass in 2: Did we not confirm that this was a carta / carta-beta preferences issue? We have separate user directories for release and beta packages. The same electron app should access the same directory regardless of how you launch it; changing between beta and release packages will always access different directories regardless of the package or invocation method. 4: This is a known issue; @kswang1029 is currently making a lot of suggestions for extending and fixing the high-level API (there are multiple issues open for this; you are welcome to file additional issues for specific problems with these functions as you find them). You can always access the low-level actions, but this isn't very user-friendly. The low-level actions will be easier to discover once there are generated frontend docs (coming soon). 5: I think this is an idle timeout issue; this should be filed as an issue in the controller repo -- I think we need some way of flagging that a session is being used for scripting and should be kept alive. 6: If this is intermittent, it could be another side-effect of 5. It would be helpful to have more step-by-step information. |
Beta Was this translation helpful? Give feedback.
-
Hi, @Jordatious. I'll have a detailed look at this when I get back from leave, but in the meantime please do file that issue, and you can look up what low-level actions and properties are available by browsing the tree of stores in the frontend source. The "app store" is at the top level; this is the default starting position of paths passed to the session's You can look at the implementation of the higher-level API functions in the wrapper's session and image classes to see how to use these paths with (In future we should have generated documentation for this API, and I'm also planning to add unix-like navigation commands to the wrapper to allow script writers to explore this tree interactively.) |
Beta Was this translation helpful? Give feedback.
-
@Jordatious @confluence I'm sorry about my slow response. I have looked into it. The Electron version of CARTA does not pass the However, perhaps @I-Chenn's frontend branch #2070 may be able to determine that information and show it somewhere on the frontend GUI in the Electron window. Assuming #2070 could show the URL/SessionID in the frontend, what do you think about the Electron version having the An alternative, assuming the user really wants to use the Electron window for the frontend and not the newly bundled carta.sh script (which skips the Electron component and uses the system's default web-browser for displaying the frontend), is that we could modify the Electron start-up script and have it print out the URL/SessionID that it is using in the terminal. This would only be feasible when starting CARTA using an alias in the command line. Here is an example,
But please keep in mind that Electron version of CARTA is designed to not accept all carta_backend flags because of the way it starts the carta-backend separately in the background. If you run
So although we could add the ability to |
Beta Was this translation helpful? Give feedback.
-
For the electron app, we would need to fit the capability here https://carta-python.readthedocs.io/en/latest/carta.html#module-carta.backend where a backend executable can be specified (automatically ideally). Can the electron app dynamically feed the enable_scripting flag to start carta_backend when we set a custom electron flag (cf —help —debug) such as —scripting? |
Beta Was this translation helpful? Give feedback.
-
Hi all, Sorry I completely forgot about this while travelling recently! Here are my quick responses.
Yes, I like this idea!
I agree this is a good use case! But I think it would be good to support both, so I also like this idea!
|
Beta Was this translation helpful? Give feedback.
-
@Jordatious I have created a modified CARTA macOS Electron version for testing the previously mentioned scenarios. I will upload it to Slack so you can try it. I added The carta-frontend's
I'm sure it will be easy to fix. I guess an extra loop can be added to check for the presence of "socketUrl" in the string, and if present it could take the value of socketUrl, as well as substitute "ws" with "http", and "&" with "?" (Replacing "&" with "?" is necessary as the python scripting interface does not seem to be able to parse it "&"). If the user prefers to start CARTA via an alias, I have modified the
Now, if the flag
That URL and Session ID can be entered into the python script and it appears to work. I thought we should use a different flag here i.e. Comments and/or suggestions are welcome. |
Beta Was this translation helpful? Give feedback.
-
Hey @confluence and @ajm-asiaa, let me know if there's a better place to discuss this. I've been playing with the CARTA python scripting, and have written a wrapper script for connecting to a server/controller instance or desktop application (only tested on Mac OSX for now). It's working quite nicely! I'm still developing it for my own purposes, but I thought it would be useful to share, as well as ask some questions / make some suggestions while I continue to develop it.
The server/controller instance works in the normal way, from any location where an authorised token exists. I do find the authentication step takes quite a while, which is an overhead that doesn't exist when scripting within a python session rather than making separate calls of such a wrapper script. But perhaps there's a way to make this more efficient?
The desktop application works in a slightly clunky way, as it calls an executable @confluence had me create, located in
/Applications/CARTA.app/Contents/Resources/app/carta-backend/bin/carta.sh
, with the following contents:I can launch this with an alias
carta
, ensuring I pass in--enable_scripting
. This then launches a Chrome window without my preferences retained, outputting the session ID and token, which I can pass into my script to interact with this session. Alternatively, I can start a new session, which launches in a profile-less Chrome window, which also doesn't retain my preferences.Here are some issues that would be great to address:
carta
alias) support CARTA scripting, without having the create a new executableNone
in as the colormap, but have to specify something. I'm using the default ofinferno
/carta.constants.Colormap.INFERNO
, but if the user has selected something else via the GUI, it will change their colormap. Are there additional accessors I'm not seeing documented?Beta Was this translation helpful? Give feedback.
All reactions