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

Validate filebrowser/upload fields #288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

nbenn
Copy link
Collaborator

@nbenn nbenn commented Feb 8, 2024

Fixes #284.

@DivadNojnarg I'm using validate_field() to

  1. extract the relevant bits in order to get a file name
  2. reset if the file for some reason does not exists

what do you think? It makes for very compact blocks.

@JohnCoene you did not provide a reprex, so I could not check whether this fixes your issue. I think it might though. Could you check?

@nbenn nbenn requested a review from DivadNojnarg as a code owner February 8, 2024 19:01
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (933c692) 78.61% compared to head (2b85645) 78.41%.

Files Patch % Lines
R/field.R 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #288      +/-   ##
==========================================
- Coverage   78.61%   78.41%   -0.20%     
==========================================
  Files          17       17              
  Lines        2001     1997       -4     
==========================================
- Hits         1573     1566       -7     
- Misses        428      431       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DivadNojnarg
Copy link
Collaborator

@nbenn: I started to check this one. I saved a copy of my workspace and tried to restore it, which gave to the same error @JohnCoene found. I'll check further tomorrow what's going on (if we can fix that in this PR).

@DivadNojnarg
Copy link
Collaborator

DivadNojnarg commented Feb 9, 2024

@JohnCoene @nbenn: there seem to be a timing issue, the validation is not called at the right time (too late) and the parser block receives the old path:

Warning in file(file, "rt") :
  cannot open file '/var/folders/jn/sm28k_jn5fn873pbmw709hj00000gn/T//Rtmp9NCYKa/9b8d6906e4c9d8126b72cf0a/0.csv': No such file or directory
Warning: Error in file: cannot open the connection
  3: runApp
  2: print.shiny.appobj
  1: <Anonymous>
UPDADING WORKSPACE with stack mystack
Called from: validate_field.upload_field(x)
Browse[1]>

Can we validate the parsers instead? We'd need to setup a field containing the path passed from the upload block and check it.

@nbenn
Copy link
Collaborator Author

nbenn commented Feb 9, 2024

@JohnCoene @DivadNojnarg could we please make it a habit to provide an example if you run into an error? I'm happy to try and fix this, but I cannot reproduce. For me,

  1. I create a workspace as

    serve_workspace(my_stack = new_stack(upload_block, csv_block, filter_block))
  2. upload iris.csv, fill in some filter options and download the json (workspace-2024-02-09.json)

  3. shut down the app and restart as

    serve_workspace(
      clear = FALSE,
      workspace = restore_workspace("workspace-2024-02-09.json")
    )

For this I get a reasonable result:

Screenshot 2024-02-09 at 08 45 41

@nbenn
Copy link
Collaborator Author

nbenn commented Feb 9, 2024

With workspace.json from #291 and app startup as

serve_workspace(clear = FALSE, workspace = restore_workspace("workspace.json")

I can reproduce the following issue

[DEBUG][2024-02-09 09:13:04] Adding "add block" UI with ID myworkspace-thxrarxjbhhulqk-add
Loading required package: shiny

Listening on http://127.0.0.1:7629
[DEBUG][2024-02-09 09:13:04] Setting up "add block" listener with ID thxrarxjbhhulqk-add
Warning in file(file, "rt") :
  cannot open file '/home/john/Downloads/cars.csv': No such file or directory
Warning: Error in file: cannot open the connection
  3: runApp
  2: print.shiny.appobj
  1: <Anonymous>
UPDADING WORKSPACE with stack thxrarxjbhhulqk
[DEBUG][2024-02-09 09:13:04] Updating block filesbrowser_block
[DEBUG][2024-02-09 09:13:04] Updating UI of block filesbrowser_block
[DEBUG][2024-02-09 09:13:04] Validating block filesbrowser_block
[DEBUG][2024-02-09 09:13:04] Updating block csv_block
[DEBUG][2024-02-09 09:13:04] Updating UI of block csv_block
[DEBUG][2024-02-09 09:13:04] Validating block csv_block
[DEBUG][2024-02-09 09:13:05] Updating block filesbrowser_block
[DEBUG][2024-02-09 09:13:05] Updating UI of block filesbrowser_block
[DEBUG][2024-02-09 09:13:05] Updating block csv_block
[DEBUG][2024-02-09 09:13:05] Updating UI of block csv_block
UPDADING WORKSPACE with stack thxrarxjbhhulqk

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.

Upload block breaks restoration
2 participants