-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
928 upload snapshot file #929
Conversation
Code Coverage Summary
Diff against main
Results for commit: 8250dfb Minimum allowed coverage is ♻️ This comment has been updated with latest results |
I have two questions:
Note that (1) and (2) are mutually exclusive. |
Thanks for working on this so quickly, Aleks.
I agree that naming is important. Let's stick with uploading one file at a time for now and show this to the user. If a valid business case arises for loading multiple files, then we can consider it.
I did expect the newly loaded snapshot to be automatically uploaded, especially since we're uploading one file at a time. Is it a simple fix to enable this? If so, I would prefer/vote for the snapshot to be automatically uploaded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me.
Maybe adding NEWS.md and test cases?
It is. Will do. |
R/teal_slices.R
Outdated
#' @noRd | ||
#' @keywords internal | ||
#' | ||
slices_restore <- function(file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chlebowa should we remove from teal.slice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe teal.slice
should contain everything that can be done with a teal_slice
or a teal_slices
. The fact that we need a copy in teal
is an unfortunate consequence of the teal
extension of the teal_slices
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, good to know. slices_restore will be extended by insightsengineering/teal.slice#432 so it's good to keep that in mind, which I know you had!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will copy the changes as soon as they are merged into teal.slice
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add an argument to the function in teal.slices::slices_restore()
where the function is passed. This way the method on {teal}
would only have to call teal.slices::slices_restore
with teal::teal_slices
?
I'm not sure if this is less convoluted than having duplicated code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by adding an argument? Can you give some example code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{teal.slices}
slices_restore <- function(file, teal_slices_fun = teal_slices) {
....
}
{teal}
slices_restore <- function(file) {
teal.slices::slices_restore(file, teal_slices)
}
edit: or keep the same parameters to maintain API consistency for the function across teal and teal.slices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As neat as it is, it does not resolve the underlying problem (which I had missed). Consider this:
There are two versions of teal_slices
and two respective versions slices_restore
. Start a fresh session.
A teal_slices
object created under teal.slice
can be restored by both restore
funcitons.
x <- teal.slice::teal_slices(
teal.slice::teal_slice("iris", "Species")
)
teal.slice::slices_store(x, "testfile.json")
y <- teal.slice::slices_restore("testfile.json")
z <- teal:::slices_restore("testfile.json")
However, a similar object created under teal
can only be loaded by the function from teal
.
X <- teal::teal_slices(
teal.slice::teal_slice("iris", "Species")
)
teal.slice::slices_store(X, "testfile.json")
Y <- teal.slice::slices_restore("testfile.json") # FAILS
Z <- teal:::slices_restore("testfile.json")
After some discussion with @gogonzo and @m7pr we decided to move slices_store
and slices_restore
to teal
. Only then will there be no opportunity for error.
Thank you for raising this @averissimo 👍
@donyunardi What is missing is ensuring that the uploaded |
One way to provide an app id (from @gogonzo) is to have I imagine something like
The hash could be added to the There could be trouble, e.g. due to the We don't even have to go that far, that line up there gives me a different string every time I run the same example app. I guess it might be caused by the fact that we use environments and they are never identical. |
As I suspected, the different hash results from the fact that
Naturally, the second line will change once new |
I experimented with a JSON file, making manual changes such as modifying and deleting fields or incorrect field name. When an invalid JSON file is uploaded, it causes the application to crash. Is it feasible to implement a mechanism to verify the presence of required fields and, if they are missing, display a notification indicating what's wrong with the JSON file? |
Please be more specific. |
This is what I was asking about 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It felt solid to me. 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone also review the related PR #930 |
Thanks to @m7pr for testing with a file sent over email. I believe the requested functionality is satisfied. |
|
Signed-off-by: Aleksander Chlebowski <[email protected]>
Closes #928
Added possibility to upload a snapshot file to the snapshot manager module.
The snapshot manager control bar (top row in table) receives a third button. Clicking it opens a modal dialog that allows for selecting a
.json
file to upload and naming the snapshot.The new snapshot is added to the snapshot list and the filter manager dialog is reopened so that the user may immediately apply the new snapshot.
To ensure that the uploaded snapshot matches the app,
teal_slices
class receives theapp_id
attribute, which can be set with theapp_id
argument toteal::teal_slices
. The attribute will be set byinit
to stamp ateal_slices
. The attribute will be stored along with other attributes. Upon uploading a snapshot, the app id of the upload will be compared to that of the app.slices_restore
had to be re-defined in theteal
namespace because it callsteal_slices
and that must be the one fromteal
.TESTING