Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for running on mybinder.org #13

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

danehkar
Copy link

@danehkar danehkar commented Nov 4, 2022

I made the following changes in gdl_kernel.py to run it on mybinder.org

from IPython.utils.path import locate_profile

to

from IPython.paths import locate_profile

Remove " --use-wx "

Add apt.txt for installing gnudatalanguage.

Now it works on

Binder

Select Kernel: GDL

@danehkar
Copy link
Author

danehkar commented Nov 4, 2022

The current version of Ubuntu on mybinder.org:
cat /etc/lsb-release
Ubunntu 18.04 bionic

gdl --version
GDL - GNU Data Language, Version 0.9.7

There is no later version of GDL for Ubunntu 18.04 bionic, which allows plotting using xwin --use-wx. When the higher version is available, we need to add plplot-driver-xwin to apt.txt for installing xwin driver. Currently, it gives this error, when we try to plot on mybinder.org:

    % PLplot installation lacks the requested driver: xwin

After adding the following package to apt.txt:
libwxbase3.0-dev
libwxgtk3.0-dev
libplplot-dev
plplot-driver-xwin
xorg
xserver-xorg-core
xserver-xorg
openbox
X11 is installed, but I got the following error:

    % Cannot connect to X server

I think GDL-0.9.7 does not support xwin, and Jupyter does not support Xorg. The plotting can be done using xwin in later version of GDL.

@slayoo
Copy link
Member

slayoo commented Nov 4, 2022

Thank you!
Should we introduce a conditional expression for the --use-wx flag then - to support both older and newer versions of GDL, so that we do not break gdl_kernel for users of newer GDL?

@danehkar
Copy link
Author

danehkar commented Nov 4, 2022

Should we introduce a conditional expression for the --use-wx flag then - to support both older and newer versions of GDL, so that we do not break gdl_kernel for users of newer GDL?

@slayoo Yes, we can check the version with gdl --version and choose between:

 self._child  = spawn(self._executable+' --use-wx ',timeout = 300, encoding='utf-8')

and

 self._child  = spawn(self._executable,timeout = 300, encoding='utf-8'

However, I have the latest version of GDL, v 1.0.1. It does not have any option --use-wx, but it has the following options:

  • --MAC Graphic device will be called 'MAC' on MacOSX. (default: 'X')
  • --no-use-wx Tells GDL not to use WxWidgets graphics. Also enabled by setting the environment variable GDL_DISABLE_WX_PLOTS to a non-null value.
  • --notebook Force SVG-only device, used only when GDL is a Python Notebook Kernel.

I am not sure which version after v0.9.7 had the option --use-wx.

@danehkar
Copy link
Author

danehkar commented Nov 4, 2022

It works locally on my machine (Fedora 36.x86_64, GDL v 1.0.1) without -use-wx. However, I am not sure if it will work on mybinder.org in the future when they update from GDL 0.9.7 to 1.0.1, and from Ubunntu 18.04 to 20.04.

@danehkar
Copy link
Author

danehkar commented Nov 7, 2022

I made other changes on gdl_kernel.py, which allows us to use it on a cloud platform such as mybinder.org. X-Window does not work on most of cloud platforms. Another option is Z-Buffer, but there is a color issue with Z-Buffer in GDL. I tested on IDL, and it does not have this color problem.

I made the following changes to choose between X and Z device in gdl_kernel.py:

    postcall = """
        if !D.NAME eq 'X' then begin
            device,window_state=winds_arefgij
            if !inline and total(winds_arefgij) ne 0 then begin
                w_CcjqL6MA = where(winds_arefgij ne 0,nw_CcjqL6MA)
                for i_KEv8eW6E=0,nw_CcjqL6MA-1 do begin
                    wset, w_CcjqL6MA[i_KEv8eW6E]
                    outfile_c5BXq4dV = '%(plot_dir)s/__fig'+strtrim(i_KEv8eW6E,2)+'.png'
                    ii_rsApk4JS = snapshot(outfile_c5BXq4dV)
                    wdelete
                endfor
        endif
    endif else begin
            if !D.NAME eq 'Z' then begin
                device
                if !inline and (total(tvrd()) ne 0.0) then begin
                    i_KEv8eW6E=0
                    outfile_c5BXq4dV = '%(plot_dir)s/__fig'+strtrim(i_KEv8eW6E,2)+'.png'
                    ii_rsApk4JS = snapshot(outfile_c5BXq4dV)
                    erase
            endif
        endif
    endelse
    end
    """ % locals()

I also moved demo_gdl.ipynb and demo_gdl_fbp.ipynb to the main directory since the GDL could not find snapshot.pro when we use Jupyter on another folder (/notebooks). On a local machine one needs to compile snapshot.pro with a correct path since it is not copied with gdl_kernel.py to .local/lib/python3.9/site-packages/ :

    .compile ~/snapshot.pro

When one runs Jupyter on a local machine, the GDL kernel looks for snapshot.pro in .local/lib/python3.9/site-packages/ while it is not there.

I also updated examples for Z-buffer, but I did not remove examples on X-Window. X-Window will work on a local machine, but not on a cloud platform.

@danehkar
Copy link
Author

danehkar commented Nov 7, 2022

I also added the !inline check to the Z-Buffer part in the following line:

if !inline and (total(tvrd()) ne 0.0) then begin

@danehkar
Copy link
Author

danehkar commented Nov 7, 2022

I did a few changes to demo_gdl_fbp.ipynb. Now it has a better show with set_pixel_depth=8. However, set_pixel_depth=8 should show Grayscale similar to what plotted for X-Window, see IDL manual for Supported_Devices.html#Z-Buffer.The GDL team should fix color issues with Z-buffer, and carefully test it against IDL.

@danehkar
Copy link
Author

Scripts for Travis and Appveyor Setup were added. Currently, they are set up on my personal Travis and Appveyor accounts. You need to make an account for gdl_kernel on gnudatalanguage on https://app.travis-ci.com/ and https://ci.appveyor.com/.

@slayoo
Copy link
Member

slayoo commented Nov 22, 2022

Thanks @danehkar !
Let's try to have separate PRs for separate functionalities, the smaller the PR, the more streamlined merging, in general.

In the main GDL repo, we have moved away from Travis to GitHub Actions (as Travis stopped supporting open-source projects for free), I suggest we do the same here.
Github Actions supports Linux, macOS and Windows - perhaps then we can also do without Appveyor?

@danehkar
Copy link
Author

@slayoo Currently, I am not familiar with GitHub Actions. I am working to include GitHub Actions in my own repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants