Giter Club home page Giter Club logo

Comments (29)

philippjfr avatar philippjfr commented on May 18, 2024

The issues seem to be fixed according to my testing, if you can confirm could you close this?

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

I updated param and panel to master and now I can't get the panel to display. I'm getting a javascript error:

panel

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Could you report the versions you've got for each? I can't reproduce that.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

JupyterLab and jupyterlab_pyviz versions may also be useful.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

param 1.8.0a8.post5+ga97c18b
panel 0.1.0a11.post3+ge8e0f6d.dirty
jupyter 1.0.0
jupyter_client 5.2.3
jupyter_console 5.2.0
jupyter_core 4.4.0
jupyterlab 0.34.6
jupyterlab_launcher 0.13.1
@pyviz/jupyterlab_pyviz v0.6.1

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Thank you!

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Okay updated JupyterLab and can now reproduce the issue. I'll try to get an updated jupyterlab_pyviz release out with a fix.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Okay nevermind, it's not an issue with the jlab extension, it's merely down to the fact that you haven't loaded the extension in the notebook. So try clearing the output, reloading the jlab and then loading the panel (or holoviews) extension:

panel.extension()

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

Not sure how I was missing that before when this was working. At any rate, panel.extension() doesn't seem to fix it for me.

panel2

I'm heading out for the day, I'll pick back up with this tomorrow.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

I had to clear the notebook and reload the page for some reason.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Not sure how I was missing that before when this was working. At any rate, panel.extension() doesn't seem to fix it for me.

I suspect at that point you had another tab open which did load an extension, which is sufficient.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

Got it working. My guess is that the other tab was hanging on to a previous build.

Now, is this expected behavior given how I have this coded?:
solve_on

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

And can you confirm that this:

loc = foo.location(name='')    
adv = foo.advanced(name='')  
Tabs(('INPUT', loc), ('Advanced', adv))  
  
foo.launch(loc.solve_on, adv.notebook)    

Is the cleanest and most efficient way to apply my code?

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Now, is this expected behavior given how I have this coded?:

No, appears to be a bug, I can see an error on the console.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Fixed in holoviz/param#289, I'll tag new param and panel dev releases once ready.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Now merged, should be fixed if you pull param master.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Is the cleanest and most efficient way to apply my code?

If you don't need separate instances then this is fine too:

Tabs(('INPUT', foo.location), ('Advanced', foo.advanced ))  

foo.launch(foo.location.solve_on, foo.advanced.notebook) 

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

What I was hoping for (and what I think worked in a previous iteration of my code without panel and possibly with a different class setup) was this:

Tabs(('INPUT', foo.location), ('Advanced', foo.advanced ))  

foo.launch(foo.location, foo.advanced) 

And something like this:

def launch(location, advanced):  
   v = solve_on  
   g = notebook  

Where basically because launch was inheriting param.Parameterized classes and I could just use the objects from those classes directly inside the method (e.g. solve_on above). It felt weird at first because its not clear what's going on, but I eventually liked it because it made my code so clean. Is this not possible now with the way I have it set up above?

If this isn't clear, I can demo what I have on a call next week.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

Orrrr.... could I write a subfunction in each param.Parameterized class that simply returned all the objects. Then I could call launch like this:

foo.launch(foo.location.return_objs(), foo.advanced.return_objs())

And then I'd just have to unpack the input.

And for reference... this is what I currently have based on your last suggestion, which is a nightmare:

solve_obj = solve2.solve(loc_param.solve_on, loc_param.solve_from, loc_param.local_architecture, 
                         login_param.hpc_login_node, submit_param.hpc_subproject, submit_param.workdir,
                         submit_param.nodes, submit_param.wall_time, submit_param.queue, 
                         submit_param.submit_script_filename, adv_param.notebook, input_param.sim_files, 
                         input_param.model, input_param.adh_rootname, input_param.adh_root_filename, 
                         input_param.adh_directory)

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Could you describe what exactly about this isn't working? I can't reproduce any problem with what you're describing. I don't quite follow the difference between foo.launch and the launch function. The other thing I don't follow is this:

foo.launch(foo.location, foo.advanced) 

There is no reason to pass those parameters to the launch method since they are available on self. I think what you really want is a classmethod?!

class location(param.Parameterized):
    solve_on = param.ObjectSelector(default='topaz', objects=['topaz', 'desktop'], precedence=1)
    
class advanced(param.Parameterized):
    notebook = param.Boolean(default=True, precedence=9)
    
class solve(location, advanced):
    @classmethod
    def launch(cls):
        if cls.solve_on == 'desktop':
            print('bar')
        if cls.notebook:
            print('notebook')

Tabs(('INPUT', location), ('Advanced', advanced ))  

solve.launch()

If this isn't what you want let's discuss next week.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

OoOoOo I didn't know that I was a thing (engineer != programmer). That seems like it might be what I'm looking for. Let me work on this a bit and get back with you.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

And to answer your question. Its all working, its just much less clean than it was before I implemented Panel so I want to make sure that I'm streamlining things as much as possible.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

So param actually also provides a bothmethod decorator, which means you can use the method on the class or an instance of the class which may also be useful:

class solve(location, advanced):
    @param.parameterized.bothmethod
    def launch(self_or_cls):
        if self_or_cls.solve_on == 'desktop':
            print('bar')
        if self_or_cls.notebook:
            print('notebook')

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

Nice! I'll look into that too. Thanks!

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

And to answer your question. Its all working, its just much less clean than it was before I implemented Panel so I want to make sure that I'm streamlining things as much as possible.

It would be good to see the comparison, as that's exactly the opposite of what I expect.

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

@philippjfr Have you had a chance to look at the solve code I sent yet? I have a soft deadline for a demo at the end of the week and I'd love to use the more streamlined version of that code.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

Looking at this now, hope to get back to you very soon.

from panel.

philippjfr avatar philippjfr commented on May 18, 2024

The best way to achieve what you want is to make an instance of your multiple inheritance class and then declare a number of Param panes each with the subset of parameters you want:

solver = solve.solve(name='')
location = pn.Pane(solver, parameters=list(solve.location.params()), name='Location')
hpc_submit = pn.Pane(solver, parameters=list(solve.hpc_submit.params()), name='HPC Options')
advanced = pn.Pane(solver, parameters=list(solve.advanced.params()), name='Advanced')
Tabs(location, hpc_submit, advanced, height=500)

from panel.

kcpevey avatar kcpevey commented on May 18, 2024

works great! thanks!!

from panel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.