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

IPython extension fails on Julia 1.6.7 #460

Closed
MilesCranmer opened this issue Feb 12, 2024 · 4 comments
Closed

IPython extension fails on Julia 1.6.7 #460

MilesCranmer opened this issue Feb 12, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@MilesCranmer
Copy link
Contributor

MilesCranmer commented Feb 12, 2024

Affects: JuliaCall

Describe the bug
On Julia 1.6.7, I tried loading the JuliaCall IPython extension in a Jupyter notebook (as part of the PySR test suite, I have a notebook that runs and does %load_ext juliacall and does various Julia stuff).

I executed it in a line with %julia println(3). This gives me the following traceback:

JuliaError                                Traceback (most recent call last)
/tmp/ipykernel_3051/1932480696.py in <module>
----> 1 get_ipython().run_line_magic('julia', 'println(3)')

/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2416                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2417             with self.builtin_trap:
-> 2418                 result = fn(*args, **kwargs)
   2419             return result
   2420 
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/juliacall/ipython.py in julia(self, line, cell)
     52         ans = Main.seval('begin\n' + code + '\nend')
     53         # flush stderr/stdout
---> 54         PythonCall._flush_stdio()
     55         # copy variables back to Python
     56         # only copy those which are new or have changed value
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/juliacall/__init__.py in __call__(self, *args, **kwargs)
    206             return ValueBase.__dir__(self) + self._jl_callmethod($(pyjl_methodnum(pyjlany_dir)))
    207         def __call__(self, *args, **kwargs):
--> 208             return self._jl_callmethod($(pyjl_methodnum(pyjlany_call)), args, kwargs)
    209         def __bool__(self):
    210             return True
JuliaError: MethodError: no method matching flush(::Tuple{Base.PipeEndpoint, Base.PipeEndpoint})
Closest candidates are:
  flush(!Matched::Base.DevNull) at coreio.jl:19
  flush(!Matched::TextDisplay) at multimedia.jl:253
  flush(!Matched::IOStream) at iostream.jl:66
  ...
Stacktrace:
 [1] _flush_stdio()
   @ PythonCall ./none:11
 [2] pyjlany_call(self::typeof(PythonCall._flush_stdio), args_::Py, kwargs_::Py)
   @ PythonCall ~/.julia/packages/PythonCall/wXfah/src/jlwrap/any.jl:39
 [3] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall ~/.julia/packages/PythonCall/wXfah/src/jlwrap/base.jl:69
 [4] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.C ~/.julia/packages/PythonCall/wXfah/src/cpython/jlwrap.jl:47

This is the most recently released version of JuliaCall. So it basically looks like this flush call is not compatible with Julia 1.6?

@MilesCranmer MilesCranmer added the bug Something isn't working label Feb 12, 2024
@MilesCranmer MilesCranmer changed the title IPython extension fails on older Julia IPython extension fails on Julia 1.6 Feb 12, 2024
@MilesCranmer MilesCranmer changed the title IPython extension fails on Julia 1.6 IPython extension fails on Julia 1.6.7 Feb 12, 2024
@cjdoris
Copy link
Collaborator

cjdoris commented Feb 17, 2024

Looks like it. Can you figure out how to do that flush on 1.6?

@MilesCranmer
Copy link
Contributor Author

Sorry, I don't know. Up until this point I didn't even know what flush did.

@cjdoris
Copy link
Collaborator

cjdoris commented Feb 18, 2024

No worries it was a simple fix - fixed on main.

@cjdoris cjdoris closed this as completed Feb 18, 2024
@MilesCranmer
Copy link
Contributor Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants