brainvisa / casa-distro

Unified development environment for BrainVISA projects.
2 stars 1 forks source link

Create a GUI to setup casa_distro environements #80

Closed sapetnioc closed 3 years ago

sapetnioc commented 4 years ago

In Capsul we developed a modular configuration system allowing to define, complete (i.e. try to automatically set some important missing values) and validate configuration. This system also manage dependencies between modules as well as versioning of software. There is no GUI yet for the Capsul configuration system but there is a need for it.

I believe, this issue could be done by using the same GUI as the one to be developed for Capsul. The only thing that is specific is the need to identify the items in the configuration that are directories and set a corresponding mount point in the virtual environment. This special container or virtual machine use case could be taken into account by Capsul settings system.

denisri commented 4 years ago

I have started writing a GUI widget for config modules: capsul.qt_gui.widgets.settings_editor.SettingsEditor because I will need it in populse_mia soon.

ylep commented 4 years ago

Here is the outcome of the brainstorming session I just had with @Hboni, including a drawing of the interface that we want to implement: gui_drawing

Hboni commented 4 years ago

I pushed the first version of the GUI to configure mount points and to launch brainvisa/anatomist/a teminal. I will need help to implement it after with casa_distro/bv command.

denisri commented 4 years ago

It's strange, your GUI script seems to use the API of casa_distro 2 (/casa/build, /casa/home instead of /casa/host/*, and uses "container_volumes" in the config which has changed to "mounts" or something), whereas the script is actually in branch 3.0...

Hboni commented 4 years ago

Oh yeah, I developed it on my casa_distro 2, I had some troubles to install and use casa_distro 3, so I first create the scaffold. I'll try it in casa_distro 3 quickly.

denisri commented 4 years ago

I pushed a little modif for that but it's not enough ("mounts" is not mandatory in casa-dostro3 config so the key doesn't always exist in the dict)

denisri commented 4 years ago

A pair of remarks about the GUI:

denisri commented 4 years ago

For icons I see: the paths are hard-coded in the script: '/casa/host/build/share/doc/axon/images/brainvisa.png' but here we are in /casa/install. Things need to be found relatively to the python modules, or the executable.

ylep commented 4 years ago

I agree with your comment on #127 to put the lancher in share/scripts.

  • it runs inside the container, thus mounts cannot be added via a regular file browser, because we have to select directories from the host filesystem, and mount them at mount points which don't exist on the container filesystem. So we need another way to type paths.

We plan to have casa-distro add a mount of / -> /host, so we can use a file browser to select directories. We just have to strip the leading /host before saving the path to casa_distro.json.

  • on a "user" distro, we don't have any xterm installed on the system, so the "terminal" button makes the application crash. Maybe we should install minimal tools like xterm, vi, or even gedit ?

I think @Hboni put xterm just as a placeholder here. We should include a lightweight terminal emulator, maybe lxterminal. You are right about a text editor, I just opened #140 to track what other graphical software we need to include.

denisri commented 3 years ago

Some improvements have been done in the config GUI:

Are there any other important missing features ?

Hboni commented 3 years ago

Nice job! The only features that I remember was the configuration of softwares like Matlab, SPM, FSL ... But it's possible in Brainvisa preferences. So I am not sure this is important for the first release.

Hboni commented 3 years ago

After a new install of casa_distro 3.0 this week, and a pull of 3.0 branch, I tried to use the bv command to launch the GUI, but I get this error :

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/casa/host/src/casa-distro/python/casa_distro/configuration_gui.py", line 595, in <module>
    dialog = CasaLauncher(conf_path)
  File "/casa/host/src/casa-distro/python/casa_distro/configuration_gui.py", line 52, in __init__
    with open(conf_path, 'r') as conf_file:
FileNotFoundError: [Errno 2] No such file or directory: '/conf/casa_distro.json'

It seems that there is too much/not enough os.path.dirname in configuration_gui.py

denisri commented 3 years ago

It works for me... Is there anything different in your install setup (host directories...?)

denisri commented 3 years ago

singularity 3 seems unable to mount a host directory inside a container directory which is already a mount, it just creates an empty directory. Thus mounting anyting inside /casa/home does not work. Thus the .ssh mount option is pointless. Sigh.

Hboni commented 3 years ago

Oh, I think that I see why it's not working for me. In my bv_maker I have the option

default_source_dir={component}

So I don't have master or bug_fix folder, so I do not have the same depth for the configuration_gui file

ylep commented 3 years ago

Thus the .ssh mount option is pointless. Sigh.

Slightly off-topic, but maybe this can help you with SSH: I have committed a change to casa-distro yesterday, which will forward the ssh-agent of the host in the container, so the container is able to use the private keys of the host.

denisri commented 3 years ago

Thus the .ssh mount option is pointless. Sigh.

Slightly off-topic, but maybe this can help you with SSH: I have committed a change to casa-distro yesterday, which will forward the ssh-agent of the host in the container, so the container is able to use the private keys of the host.

How does it work, how do we activate it ? It doesn't work in my existing environment - do we need to set it up again, with a new .bashrc ?

denisri commented 3 years ago

Thus the .ssh mount option is pointless. Sigh.

Slightly off-topic, but maybe this can help you with SSH: I have committed a change to casa-distro yesterday, which will forward the ssh-agent of the host in the container, so the container is able to use the private keys of the host.

How does it work, how do we activate it ? It doesn't work in my existing environment - do we need to set it up again, with a new .bashrc ?

Is it b46d6d785640a3d2f0dae767e37ce2d44 ? I have a SSH_AUTH_SOCK env variable (which value is /casa/ssh_auth_sock) but it doesn't make ssh work any better. Am I missing anything ?

ylep commented 3 years ago

Is it b46d6d7 ? I have a SSH_AUTH_SOCK env variable (which value is /casa/ssh_auth_sock) but it doesn't make ssh work any better. Am I missing anything ?

Yes it is that commit. Can you check what ssh-add -l says on the host and in the container?

You need to have a working ssh-agent for that to work (some desktop environments set one up at the opening of a session). Once this is running, you can use ssh-add on the host to store the key in the agent, and then use it from the container.

denisri commented 3 years ago

Oh that was it. I didn't know how this agent works and I didn't have one. Is it persistent or do I have to re-add this each time I restart the machine (or session ?) on my host ? Or is it safe to add it in our host .bash_profile ? Maybe we should document this somewhere ?

ylep commented 3 years ago

The agent is not persistent, it has to be started by some mechanism (session manager, bash_profile...). I personally use keychain (apt-get install keychain), which starts the agent for you and is able to reuse it in all sessions. I have something along these lines in ~/.profile:

eval $(keychain --eval --agents ssh id_rsa)
denisri commented 3 years ago

Is there still anything important missing (or not working) in the GUI for the first release, or do we close the ticket ?

ylep commented 3 years ago

I fear there is some work left: I did not manage to get the GUI to work in a user image:

$ ./brainvisa-2021-01-13/bin/bv 
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-yl243478'
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/casa/install/python/casa_distro/configuration_gui.py", line 537, in <module>
    dialog = CasaLauncher(conf_path)
  File "/casa/install/python/casa_distro/configuration_gui.py", line 52, in __init__
    with open(conf_path, 'r') as conf_file:
IOError: [Errno 2] No such file or directory: '/conf/casa_distro.json'
Hboni commented 3 years ago

I have the same problem, as I supposed before, it is maybe when you don't have master/bug_fix directory level in your installation.

denisri commented 3 years ago

Ah. I haven't made a user image yet, so I didn't test this case. But @Hboni this seems not to be related to sources because user images don't contain sources, or it's a different problem. I'm looking at that. I heard that @sapetnioc has proposed a different sources organization but I haven't understood that it was already used. Was it necessary ?

denisri commented 3 years ago

In the casa-dev image I am using (built on jan 8) after a setup_dev, bv doesn't work at all when invoked without arguments. As a matter of fact, casa-distro paths are not setup any longer inside the image...

denisri commented 3 years ago

I think we should not get into configuring external software such as SPM, Freesurfer or Matlab in the bv tool for this release, because

So I suggest to stick with the current GUI, allowing to edit mount points and the casa_distro.json config file.

denisri commented 3 years ago

We said during the last meeting: