Skip to content

Conversation

@hkayabilisim
Copy link
Contributor

Added multiple file support to file_drop component.
Same as the original component, directories are simply ignored. Multiple file support was actually embedded in the underlying VUE scripts. I've done minor changes.

Compatibility:
on_file callback function now accepts List[FileInfo] as opposed to single FileInfo object. This may bring some problems for existing codes. As a remedy, if the number of files is just one, we can return a single FileInfo. If not, we return list. I leave it up to you to decide.

This is related to: #260

Copy link
Contributor

@mariobuikhuizen mariobuikhuizen left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @hkayabilisim!

We would like to keep this component backward compatible. We could accomplish this by adding an argument multiple with a default value of False and have on_file also work with a single file (see this for an example of the typing, note the argument optional: Literal[False])

Copy link
Contributor Author

@hkayabilisim hkayabilisim left a comment

Choose a reason for hiding this comment

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

missing ';' at the end of the "padding:" line was causing CSS problem.

Copy link
Contributor Author

@hkayabilisim hkayabilisim left a comment

Choose a reason for hiding this comment

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

Changes required for backward compatibility:

  1. multiple property is added to FileDrop
  2. Two different on_file callback signature used: FileInfo and List[FileInfo]
  3. FileDrop is overloaded to match two different on_file signatures.
  4. FileDrop apidoc is updated
  5. FileDrop example is updated
  6. bullet list in VUE template is removed
  7. isFile property is always set to True (this was a hidden bug)
  8. app/scatter.py is reverted to original version

Copy link
Contributor Author

@hkayabilisim hkayabilisim left a comment

Choose a reason for hiding this comment

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

@maartenbreddels
Copy link
Contributor

Looking good!
A few issues

Looking forward to see this green in CI, and get this merged 🥳

@hkayabilisim
Copy link
Contributor Author

hkayabilisim commented Mar 21, 2024

  • Used "multiple" option in file_drop.vue to list single file in drop zone when multiple is not selected. However, I couldn't propogate "multiple" to further inside Vue to prevent processing multiple file when multiple is not selected. I don't think this is a big issue.
  • I could select a wrong return type from FileDrop. I guess, it must have been reacton.core.something but couldn't find it properly.
  • I used pre-commit to clean style issues but couldn't solve the following one. So, I had to disable pre-commit right before commit:
image

@hkayabilisim
Copy link
Contributor Author

Hi @maartenbreddels

There is only one error I couldn't resolve. Help needed!

image

@maartenbreddels
Copy link
Contributor

Hi Huseyin,

we had quite a long discussion internally on this PR.
For ToggleButton https://github.com/widgetti/solara/blob/master/solara/components/togglebuttons.py we had two different components

  • ToggleButtonsSingle
  • ToggleButtonsMultiple

This is because otherwise the typing becomes quite complex (as you can see now for FileDrop), and it only works for literals. So if you want to take advantage of the typing you need to do:

if multiple:
  FileDrop(..., multiple=True)
else:
  FileDrop(..., multiple=False)

Which is a bit odd. For this reason, it might be better to have
FileDrop and FileDropMultiple (they can call the same internal component btw, it's just the public API)

However, also that would be inconsistent in the naming, so either solution is not perfect.

Two questions:

  1. What do you think about the typing and one vs two components
  2. If you also prefer FileDropMultiple, are you willing to do the changes? If not, we're happy to help.

Let us know, and thanks you for your help on this.

Regards,

Maarten

@hkayabilisim
Copy link
Contributor Author

Hi Maarten,

Getting rid of some complexity by creating two variants (FileDrop and FileDropMultiple) seems a good idea.

I've just created FileDropMultiple and commited to the branch and tested little bit (fa6cd23). It seems ok, and CI checks are green. Yet, you should revise my implementation in case if I missed some points.

Sincerely
Huseyin

@maartenbreddels
Copy link
Contributor

Hi Huseyin,

whow, many thank for doing all this work!
CI looks green (ignore that failing one, that's not related to what you do)
Will review after the weekend probably. Have a good weekend.

Regards,

Maarten

Copy link
Contributor

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

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

Awesome work.
Let me know if you have the energy to do these last changes. I know we're asking a lot from you, so we are happy to do the last mile.

@hkayabilisim
Copy link
Contributor Author

No problem Maarten! I've added _FileDrop to prevent code repetitions. I hope this is what you have in your mind!

Copy link
Contributor Author

@hkayabilisim hkayabilisim left a comment

Choose a reason for hiding this comment

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

It may not fit 100% to the code styling requirements but I think my last commit e5e6f40 solves most of the highlighted issues.

One of the checks keeps failing but I couldn't understand why.

@iisakkirotko
Copy link
Collaborator

Hi @hkayabilisim! Just wanted to let you know that the CI failure is still unrelated, it should be fixed by #574. We'll try to get this PR in soon™️ :)

hkayabilisim and others added 2 commits March 27, 2024 12:17
Co-authored-by: Iisakki Rotko <iisakki.rotko@gmail.com>
"Navigation to X is interrupted to another navigation to Y"

In the logs we see:
```
FAILED tests/integration/ssg_test.py::test_ssg[starlette-chromium] - playwright._impl._errors.Error: Navigation to "http://localhost:18768/" is interrupted by another navigation to "http://localhost:18768/"
FAILED tests/integration/starlette_test.py::test_starlette_mount[starlette-chromium] - playwright._impl._errors.Error: Navigation to "http://localhost:18770/solara_mount/" is interrupted by another navigation to "http://localhost:18768/"
ERROR tests/integration/widget_test.py::test_widget_button_solara[starlette-chromium] - playwright._impl._errors.Error: Navigation to "http://localhost:18768/?id=4004e29b-a9e6-4b1e-9652-7b1c61ef86cd" is interrupted by another navigation to "http://localhost:18770/solara_mount/"
ERROR tests/integration/widget_test.py::test_solara_button_all[starlette-solara-chromium] - playwright._impl._errors.Error: Navigation to "http://localhost:18768/?id=c8f0b1fb-abdb-4969-b340-1156d2699783" is interrupted by another navigation to "http://localhost:18768/?id=4004e29b-a9e6-4b1e-9652-7b1c61ef86cd"
ERROR tests/integration/widget_test.py::test_slider_all[starlette-solara-chromium] - playwright._impl._errors.Error: Navigation to "http://localhost:18768/?id=680f1fc7-5a19-4e1c-a382-088f2ec96b78" is interrupted by another navigation to "http://localhost:18768/?id=c8f0b1fb-abdb-4969-b340-1156d2699783"
```
@maartenbreddels maartenbreddels merged commit c8ab5f6 into widgetti:master Mar 27, 2024
@maartenbreddels
Copy link
Contributor

This branch had some flakiness that we wanted to attack (see the last commit) before merging it. Thanks for your patience!

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.

4 participants