internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: holoviz/panel

Issue:
'str' object has no attribute 'items' when visualising Vega plot of network using Panel
When running `pn.pane.Vega(spec)` on a network spec (from the vega example showing a force-directed network of the Miserables characters), I get an error in line 21 of the `pane.py` source file. The error:

```
~/anaconda3/envs/i0u19a_jupyter/lib/python3.7/site-packages/panel/pane/vega.py in ds_as_cds(dataset)
     19     if len(dataset) == 0:
     20         return {}
---> 21     data = {k: [] for k, v in dataset[0].items()}
     22     for item in dataset:
     23         for k, v in item.items():

AttributeError: 'str' object has no attribute 'items'
```

See the image for a screenshot of the complete error message. The command used was `pn.pane.Vega(spec)`, the error what is shown above, and the output was `Vega(dict)`.

![Image 2: Bug after `pn.pane.Vega(spec)`](https://discourse.holoviz.org/uploads/default/optimized/1X/535d10eca1d1b97d6839c9d0b08d8c9af87e5ade_2_1274x1000.png)


Discussion:

Resolving patch:
diff --git a/panel/pane/vega.py b/panel/pane/vega.py
--- a/panel/pane/vega.py
+++ b/panel/pane/vega.py
@@ -94,10 +94,10 @@ def _get_sources(self, json, sources):
                 sources['data'] = ColumnDataSource(data=ds_as_cds(data))
         elif isinstance(data, list):
             for d in data:
-                sources[d['name']] = ColumnDataSource(data=ds_as_cds(d['values']))
+                if 'values' in d:
+                    sources[d['name']] = ColumnDataSource(data=ds_as_cds(d.pop('values')))
             
 
-
     @classmethod
     def _get_dimensions(cls, json, props):
         if json is None:


Test patch:
Repository: holoviz/panel

Issue:
Fileinput widget always returns `None` for name of uploaded file
As of panel 0.7.0 (with bokeh 1.4.0), the Fileinput widget does not set the name of the uploaded file.

E.g. in the following code
```python
import panel as pn

inp = pn.widgets.FileInput(name='Upload')
btn = pn.widgets.Button(name='Upload', button_type='primary')
r= pn.Column(pn.Row(inp, btn),)

def on_click_parse(event):
    #print(inp.get_param_values())
    print(inp.filename)
btn.on_click(on_click_parse)

r.servable()
```
it always prints `None` to the terminal.

I can already see where the issue is and will open a PR.


Discussion:

Resolving patch:
diff --git a/panel/widgets/input.py b/panel/widgets/input.py
--- a/panel/widgets/input.py
+++ b/panel/widgets/input.py
@@ -72,7 +72,7 @@ def _process_param_change(self, msg):
 
     def _filter_properties(self, properties):
         properties = super(FileInput, self)._filter_properties(properties)
-        return properties + ['value', 'mime_type']
+        return properties + ['value', 'mime_type', 'filename']
 
     def _process_property_change(self, msg):
         msg = super(FileInput, self)._process_property_change(msg)


Test patch:
diff --git a/panel/tests/widgets/test_input.py b/panel/tests/widgets/test_input.py
--- a/panel/tests/widgets/test_input.py
+++ b/panel/tests/widgets/test_input.py
@@ -59,10 +59,11 @@ def test_file_input(document, comm):
 
     assert isinstance(widget, BkFileInput)
 
-    file_input._comm_change({'mime_type': 'text/plain', 'value': 'U29tZSB0ZXh0Cg=='})
+    file_input._comm_change({'mime_type': 'text/plain', 'value': 'U29tZSB0ZXh0Cg==', 'filename': 'testfile'})
     assert file_input.value == b'Some text\n'
     assert file_input.mime_type == 'text/plain'
     assert file_input.accept == '.txt'
+    assert file_input.filename == 'testfile'
 
 
 def test_literal_input(document, comm):
Repository: holoviz/panel

Issue:
Support src urls and alt texts on Images
#### My Pain

I would like to use images in Panel via `pn.pane.Markdown` and/ or `pn.pane.PNG`.

Currently the Bokeh layout engine does not layout markdown with images well. See https://github.com/holoviz/panel/issues/835.

So I need to stick to `pn.pane.PNG` for images.

But the `ImageBase` class does not support parameters like the `src` url and `alt` text from the the HTML `img` tag. So I cannot provide image links or alt texts.

#### Solution

Add `src` and `alt` parameters to the `BaseImage` class.


Discussion:
Sounds great!  This seems like an easy extension for someone to make a first PR on panel, by editing https://github.com/holoviz/panel/blob/master/panel/pane/image.py#L124 .
Hmm, not sure what you mean by `src` URL. The src URL is how the Image panes work in the first place and either contain the embedded base64 image or a URL to the image, do you mean you want to make the image clickable and link to some other URL?
Yes. I mean I would like the image to be clickable and link to some other URL.

Currently the workaround is to use Markdown or HTML pane.
I can confirm that the link works. 

But you forgot to handle width, height and sizing_mode I believe :-) Or maybe you (@philippjfr ) made some secret AI code to always maximize images of your self :-)

-----

![image](https://user-images.githubusercontent.com/42288570/73423175-9fb02f80-432b-11ea-9d40-7d60f2034bbb.png)

```python
import panel as pn

pn.config.sizing_mode = "stretch_width"

image = pn.pane.PNG(
    "https://pbs.twimg.com/profile_images/1133352188225437696/r0KfYITe_400x400.png",
    alt="Philip",
    link_url="https://github.com/philippjfr",
    height=300,
)


app = pn.Column(image, height=300, background="blue", sizing_mode="stretch_width")
app.servable()
```



Resolving patch:
diff --git a/panel/pane/image.py b/panel/pane/image.py
--- a/panel/pane/image.py
+++ b/panel/pane/image.py
@@ -114,7 +114,7 @@ def _get_properties(self):
             w, h = '%spx' % width, '%spx' % height
         elif smode == 'stretch_both':
             w, h = '100%', '100%'
-        elif smode == 'stretch_height':
+        elif smode == 'stretch_width':
             w, h = '%spx' % width, '100%'
         elif smode == 'stretch_height':
             w, h = '100%', '%spx' % height


Test patch:
Repository: holoviz/panel

Issue:
outdated param dependency
it seems panel 0.8 uses `CalendarDateRange` from param. This [was introduced in param 1.9.2](https://github.com/holoviz/param/releases/tag/v1.9.2), but the param dependency is still at >=1.9.0
https://github.com/holoviz/panel/blob/master/setup.py#L93

This can lead to errors like 
```
    param.CalendarDateRange: DateRangeSlider,
AttributeError: module 'param' has no attribute 'CalendarDateRange'
```
when upgrading to panel 0.8.0.
Will make a simple PR to fix this


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -142,7 +142,7 @@ def run(self):
 # non-python dependencies). Note that setup_requires isn't used
 # because it doesn't work well with pip.
 extras_require['build'] = [
-    'param >=1.9.0',
+    'param >=1.9.2',
     'pyct >=0.4.4',
     'setuptools >=30.3.0',
     'bokeh >=1.4.0',


Test patch:
Repository: holoviz/panel

Issue:
Panel widgets with unit of measurement
There is no unambiguous approach how to work with different unit of measurement in one panel application. As a workaround, the symbols can be added in "brackets" after the widget name/description. For example:

_Float Slider name [kg/s]: 1.23 
Another Float Slider name [kg/s]: 1.24 
Yet another Float Slider name [kg/s]: 3.2_ 

But this results in a cluttered user interface. Although the use of brackets is not the standard-conform way to write si-unit based symbols!

A clear representation could look like this:
`float_slider = pn.widgets.FloatSlider(name=‘Float Slider’, value=1.23, symbol=‘kg/s’)
`
![example screenshot](https://discourse.holoviz.org/uploads/default/original/1X/38b6768bc7f983faafb0db332adf609fdf91ac50.png)

The symbols and (widget value) are aligned to the right.
The result would be an uncluttered and clear unser interface with the possibility to add units of measurement.





Discussion:

Resolving patch:
diff --git a/panel/widgets/slider.py b/panel/widgets/slider.py
--- a/panel/widgets/slider.py
+++ b/panel/widgets/slider.py
@@ -11,6 +11,7 @@
 import numpy as np
 
 from bokeh.models import CustomJS
+from bokeh.models.formatters import TickFormatter
 from bokeh.models.widgets import (
     DateSlider as _BkDateSlider, DateRangeSlider as _BkDateRangeSlider,
     RangeSlider as _BkRangeSlider, Slider as _BkSlider)
@@ -24,6 +25,7 @@
 from .input import StaticText
 
 
+
 class _SliderBase(Widget):
 
     bar_color = param.Color(default="#e6e6e6", doc="""
@@ -50,6 +52,9 @@ class _SliderBase(Widget):
 
 class ContinuousSlider(_SliderBase):
 
+    format = param.ClassSelector(class_=string_types+(TickFormatter,), doc="""
+        Allows defining a custom format string or bokeh TickFormatter.""")
+
     _supports_embed = True
 
     __abstract = True
@@ -275,6 +280,9 @@ def values(self):
 
 class RangeSlider(_SliderBase):
 
+    format = param.ClassSelector(class_=string_types+(TickFormatter,), doc="""
+        Allows defining a custom format string or bokeh TickFormatter.""")
+
     value = param.NumericTuple(default=(0, 1), length=2)
 
     value_throttled = param.NumericTuple(default=None, length=2)


Test patch:
Repository: holoviz/panel

Issue:
Panel.serve does not work for panel.Templates without instantiation
#### System Info

- Panel: 0.8.0
- Bokeh: 1.4.0
- Tornado 6.0.3
- Python: 3.7.4
- OS: Windows 8.1
- Browser: Chrome

#### My Pain

I'm trying to serve a list of apps and one of them uses the Panel Templating System.

If I provide a function that returns a Template to `pn.Serve` the app is not shown.

#### Additional Info

If I provide a function that returns a Column to `pn.Serve` the app is shown
If I provide an instance of the Template to `pn.Serve` the app is shown

#### Screenshot

![image](https://user-images.githubusercontent.com/42288570/76757319-ab46a100-6787-11ea-9c49-8508bbaad4a8.png)

#### Code

````bash
import holoviews as hv
import panel as pn

TEMPLATE = """
<!-- This template is inspired by
- Bokeh Template. See https://panel.pyviz.org/user_guide/Templates.html
-->
{% extends base %}

<!-- goes in head -->
{% block postamble %}
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% endblock %}

<!-- goes in body -->
{% block contents %}

<section id="page">
    <header>
        {{ embed(roots.header) }}
    </header>
    <main>
        {{ embed(roots.main) }}
    </main>
</section>

{% endblock %}
"""


class DashboardTemplate(pn.Template):
    """A Basic App Template"""

    def __init__(self, **params):
        template = TEMPLATE

        self.header = pn.Row()
        self.main = pn.Column()

        items = {
            "header": self.header,
            "main": self.main,
        }
        super().__init__(template=template, items=items, **params)


def app_template():
    app = DashboardTemplate()
    component = pn.Column("# App Template",)
    app.main[:] = [component]
    return app


def app_column():
    return pn.Column("# App Column")


APP_ROUTES = {
    "app_column": app_column,
    "app_template": app_template,
    "app_template_instance": app_template(),
}

pn.serve(APP_ROUTES, port=14033, dev=True)
````



Discussion:

Resolving patch:
diff --git a/panel/io/server.py b/panel/io/server.py
--- a/panel/io/server.py
+++ b/panel/io/server.py
@@ -41,10 +41,10 @@ def _eval_panel(panel, server_id, title, doc):
     from ..template import Template
     from ..pane import panel as as_panel
 
+    if isinstance(panel, FunctionType):
+        panel = panel()
     if isinstance(panel, Template):
         return panel._modify_doc(server_id, title, doc)
-    elif isinstance(panel, FunctionType):
-        panel = panel()
     return as_panel(panel)._modify_doc(server_id, title, doc)
     
 #---------------------------------------------------------------------


Test patch:
Repository: holoviz/panel

Issue:
panel.serve only accepts functions, not methods
#### panel version info
0.9.6

#### Description of expected behavior and the observed behavior
```
server = MyServer()
panel.serve(server.gui_instance)
```
Should serve a template returned by `MyServer.gui_nstance()`, but it only produces a `>` int he browser and no error message.

Replaced by the following, it produces the expected behavior:
```
server = MyServer()
def instance():
    return server.gui_instance()
panel.serve(instance)
```


Discussion:

Resolving patch:
diff --git a/panel/io/server.py b/panel/io/server.py
--- a/panel/io/server.py
+++ b/panel/io/server.py
@@ -11,7 +11,7 @@
 
 from contextlib import contextmanager
 from functools import partial
-from types import FunctionType
+from types import FunctionType, MethodType
 
 from bokeh.document.events import ModelChangedEvent
 from bokeh.server.server import Server
@@ -53,7 +53,7 @@ def _eval_panel(panel, server_id, title, location, doc):
     from ..pane import panel as as_panel
 
     with set_curdoc(doc):
-        if isinstance(panel, FunctionType):
+        if isinstance(panel, (FunctionType, MethodType)):
             panel = panel()
         if isinstance(panel, BaseTemplate):
             doc = panel._modify_doc(server_id, title, doc, location)


Test patch:
Repository: holoviz/panel

Issue:
Panel show not working in chrome
![image](https://user-images.githubusercontent.com/18531147/96686273-9b76e700-137e-11eb-9904-6da02e2f8b31.png)

MRE:
```python
import panel as pn
pn.extension()

pn.widgets.FloatSlider().show()
```

tested on linux and windows 10


Discussion:
however if i make the example servable and I use panel cli it works correctly
![image](https://user-images.githubusercontent.com/18531147/96689851-3d003780-1383-11eb-89cb-11643be7a9f4.png)


I can reproduce this error from this commit https://github.com/holoviz/panel/commit/3824d7b782bf4e95bdac71670f6fa6c67373cc72

so I suppose it's linked to this one https://github.com/holoviz/panel/commit/3961571aecf125e642bdfd092e99189a18ba551d
but I can't build it
I think this was an issue with bokeh 2.2.2, could you try upgrading to 2.2.3?
Already tested with bokeh 2.2.1, 2.2.2 and 2.2.3

Hmm odd, I had the same issue but wasn't able to reproduce after upgrading to 2.2.3. will have to try again.
I succed to make it works using bokeh origin/branch-2.3
Hmm, I actually pip installed it. Wonder if it's something about the conda packages.
I never use conda
using
pip install bokeh==2.3.0.dev2
it works

Resolving patch:
diff --git a/panel/io/notebook.py b/panel/io/notebook.py
--- a/panel/io/notebook.py
+++ b/panel/io/notebook.py
@@ -25,7 +25,7 @@
 from bokeh.embed.wrappers import wrap_in_script_tag
 from bokeh.models import LayoutDOM, Model
 from bokeh.resources import CDN, INLINE
-from bokeh.settings import settings
+from bokeh.settings import settings, _Unset
 from bokeh.util.serialization import make_id
 from pyviz_comms import (
     PYVIZ_PROXY, Comm, JupyterCommManager as _JupyterCommManager, nb_mime_js
@@ -208,16 +208,20 @@ def load_notebook(inline=True, load_timeout=5000):
     from IPython.display import publish_display_data
 
     resources = INLINE if inline else CDN
-    prev_resources = settings.resources()
+    prev_resources = settings.resources(default="server")
+    user_resources = settings.resources._user_value is not _Unset
     try:
-        settings.resources = 'cdn'
+        settings.resources = 'inline' if inline else 'cdn'
         bundle = bundle_for_objs_and_resources(None, resources)
         configs, requirements, exports, skip_imports = require_components()
         ipywidget = 'ipywidgets_bokeh' in sys.modules
         bokeh_js = _autoload_js(bundle, configs, requirements, exports,
                                 skip_imports, ipywidget, load_timeout)
     finally:
-        settings.resources = prev_resources
+        if user_resources:
+            settings.resources = prev_resources
+        else:
+            settings.resources.unset_value()
 
     publish_display_data({
         'application/javascript': bokeh_js,


Test patch:
Repository: holoviz/panel

Issue:
BytesIO/StringIO break pn.pane.image if called second time
#### ALL software version info
Panel: 0.10.0.post7+gb5cf6928

#### Description of expected behavior and the observed behavior
When having a BytesIO/StringIO object as input to pn.pane.image it will crash the second time a widget is called.
I don´t know if it a feature or a bug... I have made a simple implementation of a fix, if it is a bug [here](https://github.com/Hoxbro/panel/commit/af03e001a23d1e1cea065f85abfb4e0176d0d688).


#### Complete, minimal, self-contained example code that reproduces the issue

```python
import os

import param
import panel as pn


class ImageExample(param.Parameterized):
    def __init__(self, **params):
        self.button = pn.widgets.Button(name="Create Animation", button_type="primary")
        self.break_ = pn.widgets.Button(name="Break Animation", button_type="primary")
        super().__init__(**params)
        self.gif = None

    @param.depends(pn.state.param.busy)
    def animation(self, busy):
        return None if busy else self.gif

    @param.depends("button.clicks")
    def _create_animation(self):
        # it could be any gif... :)
        self.gif = pn.pane.GIF(open(os.path.join(os.path.dirname(__file__),'index.gif'), 'rb'))

    @param.depends("break_.clicks")
    def _break_animation(self):
        pass


ie = ImageExample()
pn.Column(
    ie.button,
    ie.break_,
    ie.animation,
    ie._create_animation,
).servable()


```


#### Screenshots or screencasts of the bug in action
![bug](https://user-images.githubusercontent.com/19758978/97351723-6e509a00-1892-11eb-802f-af19e6ed1e98.gif)


Discussion:

Resolving patch:
diff --git a/panel/pane/image.py b/panel/pane/image.py
--- a/panel/pane/image.py
+++ b/panel/pane/image.py
@@ -78,6 +78,8 @@ def _img(self):
                 with open(self.object, 'rb') as f:
                     return f.read()
         if hasattr(self.object, 'read'):
+            if hasattr(self.object, 'seek'):
+                self.object.seek(0)
             return self.object.read()
         if isurl(self.object, None):
             import requests


Test patch:
diff --git a/panel/tests/pane/test_image.py b/panel/tests/pane/test_image.py
--- a/panel/tests/pane/test_image.py
+++ b/panel/tests/pane/test_image.py
@@ -70,7 +70,7 @@ def test_load_from_byteio():
     path = os.path.dirname(__file__)
     with open(os.path.join(path, '../test_data/logo.png'), 'rb') as image_file:
         memory.write(image_file.read())
-    memory.seek(0)
+
     image_pane = PNG(memory)
     image_data = image_pane._img()
     assert b'PNG' in image_data
@@ -79,11 +79,11 @@ def test_load_from_byteio():
 def test_load_from_stringio():
     """Testing a loading a image from a StringIO"""
     memory = StringIO()
-    
+
     path = os.path.dirname(__file__)
     with open(os.path.join(path, '../test_data/logo.png'), 'rb') as image_file:
         memory.write(str(image_file.read()))
-    memory.seek(0)
+
     image_pane = PNG(memory)
     image_data = image_pane._img()
     assert 'PNG' in image_data
Repository: holoviz/panel

Issue:
Pyvista tests breaking
Looks like latest pyvista 0.27.2 changed some internal APIs:

```python
    def pyvista_render_window():
        """
        Allow to download and create a more complex example easily
        """
        from pyvista import examples
        sphere = pv.Sphere() #test actor
        globe = examples.load_globe() #test texture
        head = examples.download_head() #test volume
        uniform = examples.load_uniform() #test structured grid
    
        scalars=sphere.points[:, 2]
>       sphere._add_point_array(scalars, 'test', set_active=True) #allow to test scalars
E       AttributeError: 'PolyData' object has no attribute '_add_point_array'
```

Cc @xavArtley 


Discussion:
I'll try to fix it this afternoon
Okay, just unpin pyvista in the setup.py when you do.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -137,7 +137,7 @@ def run(self):
         'jupyter_bokeh',
         'django',
         'channels',
-        'pyvista <0.27', # temporary fix for tests 
+        'pyvista',
         'ipywidgets',
         'ipywidgets_bokeh',
         'ipyvolume',


Test patch:
diff --git a/panel/tests/pane/test_vtk.py b/panel/tests/pane/test_vtk.py
--- a/panel/tests/pane/test_vtk.py
+++ b/panel/tests/pane/test_vtk.py
@@ -68,7 +68,8 @@ def pyvista_render_window():
     uniform = examples.load_uniform() #test structured grid
 
     scalars=sphere.points[:, 2]
-    sphere._add_point_array(scalars, 'test', set_active=True) #allow to test scalars
+    sphere.point_arrays['test'] = scalars #allow to test scalars
+    sphere.set_active_scalars('test')
 
     uniform.set_active_scalars("Spatial Cell Data")
Repository: holoviz/panel

Issue:
Image not scaling dynamically
#### ALL software version info

```
Python 3.9.0

bokeh==2.2.3
notebook==5.7.9
panel==0.10.1

macOS Catalina 10.15.7

Chrome 85.0.4183.121
```

#### Description of expected behavior and the observed behavior

##### Expected

I should be able to scale image up and down dynamically in Jupyter Notebook and using the standalone server.

##### Observed

In the notebook, I'm able to scale up and down <= 300 width. I can't make the image larger than 300 pixels wide.

Using the standalone server, it looks like it scales just once (either up or down) and then gets stuck.

#### Complete, minimal, self-contained example code that reproduces the issue

```python
import panel as pn

def panel_logo(width=300):
    # also happens with .jpg
    return pn.panel("https://panel.holoviz.org/_static/logo_stacked.png", width=width)

pn.interact(panel_logo)
```


Discussion:
I can reproduce in Jupyter:

![image](https://user-images.githubusercontent.com/1695496/99000842-84e82980-24ff-11eb-9e6b-81f02b4563b0.png)
![image](https://user-images.githubusercontent.com/1695496/99000873-90d3eb80-24ff-11eb-91f3-4a85846e6ffd.png)
![image](https://user-images.githubusercontent.com/1695496/99000916-9df0da80-24ff-11eb-9fe6-06cf4098204c.png)

If I increase the initial width to 1000 it works up to 1000, so this seems like the same issue as for the Bokeh layout of a single-digit number, where there's no room left for the number to increase in size.
It's probably worth adding that in the original use case, I was changing the URL too. Not sure if that makes it different from the single-digit number case layout-wise.

Using this code
```python
import panel as pn

logo_urls = {
    "panel": "https://panel.holoviz.org/_static/logo_stacked.png",
    "hvplot": "https://hvplot.holoviz.org/assets/hvplot-wm.png",
}

def panel_logo(logo="panel", width=300):
    return pn.panel(logo_urls[logo], width=width)

pn.interact(panel_logo, logo=logo_urls.keys())
```

You have the case
1. Load default (Panel logo, width 300)
2. Change width to 600 (no change in image size)
3. Change logo to hvPlot (image width is 600!)

Resolving patch:
diff --git a/panel/pane/image.py b/panel/pane/image.py
--- a/panel/pane/image.py
+++ b/panel/pane/image.py
@@ -42,7 +42,7 @@ class ImageBase(DivPaneBase):
 
     imgtype = 'None'
 
-    _rerender_params = ['alt_text', 'link_url', 'embed', 'object', 'style']
+    _rerender_params = ['alt_text', 'link_url', 'embed', 'object', 'style', 'width', 'height']
 
     _target_transforms = {'object': """'<img src="' + value + '"></img>'"""}
 


Test patch: