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

[WIP] New widget : RemoteFileSelector #6301

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions examples/reference/widgets/RemoteFileSelector.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import panel as pn\n",
"pn.extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``RemoteFileSelector`` widget allows browsing a distant filesystem and selecting one or more files in a directory.\n",
"\n",
"A ``RemoteFileSelector`` always relies on a ``RemoteFileProvider``, that is responsible for fetching data from the distant filesystem, handling the connection. The ``RemoteFileSelector`` is responsible for showing the distant filesystem and allow for a selection of files. Its behavior is similar to ``FileSelector``\n",
"\n",
"\n",
"#### Parameters:\n",
"\n",
"// TODO\n",
"\n",
"\n",
"___"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
20 changes: 20 additions & 0 deletions panel/tests/widgets/test_remote_file_selector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# to fake delays in DummyRemoteFileProvider
import time

from pathlib import PurePosixPath

from panel.widgets import RemoteFileProvider


class DummyRemoteFileProvider(RemoteFileProvider):

def __init__(self):
super().__init__()

async def ls(self, path:PurePosixPath):
time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
time.sleep(1)
asyncio.sleep(1)

So it makes sense with async.

if str(path) == '/':
return [f'dir_{l}' for l in 'ABCDEF' ], [f'file_{n}' for n in '123456' ]
else:
last_letter = path.parts[-1].replace("dir_", "")
return [f'dir_{last_letter}{l}' for l in 'ABCDEF' ], [f'file_{last_letter + n}' for n in '123456' ]
4 changes: 4 additions & 0 deletions panel/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
)
from .misc import FileDownload, JSONEditor, VideoStream # noqa
from .player import DiscretePlayer, Player # noqa
from .remote_file_selector import ( # noqa
RemoteFileProvider, RemoteFileSelector, S3RemoteFileProvider,
)
from .select import ( # noqa
AutocompleteInput, CheckBoxGroup, CheckButtonGroup, ColorMap,
CrossSelector, MultiChoice, MultiSelect, NestedSelect, RadioBoxGroup,
Expand Down Expand Up @@ -127,6 +130,7 @@
"RadioBoxGroup",
"RadioButtonGroup",
"RangeSlider",
"RemoteFileSelector",
"Select",
"SpeechToText",
"Spinner",
Expand Down
Loading
Loading