ropensci / git2rdata

An R package for storing and retrieving data.frames in git repositories.
https://ropensci.github.io/git2rdata/
GNU General Public License v3.0
99 stars 13 forks source link

Fix problem on data hashes (#49) #53

Closed ElsLommelen closed 5 years ago

ElsLommelen commented 5 years ago

Description

Related Issue

fix #49

Example

included in unit tests

ElsLommelen commented 5 years ago
codecov-io commented 5 years ago

Codecov Report

Merging #53 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #53   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          11     12    +1     
  Lines         696    754   +58     
=====================================
+ Hits          696    754   +58
Impacted Files Coverage Δ
R/relabel.R 100% <ø> (ø) :arrow_up:
R/recent_commit.R 100% <ø> (ø) :arrow_up:
R/is_git2rdata.R 100% <ø> (ø) :arrow_up:
R/prune.R 100% <ø> (ø) :arrow_up:
R/upgrade_data.R 100% <100%> (ø) :arrow_up:
R/datahash.R 100% <100%> (ø)
R/is_git2rmeta.R 100% <100%> (ø) :arrow_up:
R/read_vc.R 100% <100%> (ø) :arrow_up:
R/write_vc.R 100% <100%> (ø) :arrow_up:
R/meta.R 100% <100%> (ø) :arrow_up:
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4c49807...e02e802. Read the comment docs.

ElsLommelen commented 5 years ago

Problem solved! Trial and error learned that in Windows:

In Linux, conversion does not influence the result, as characters are typically in UTF-8

florisvdh commented 5 years ago

The datahashes do match now (see #49); great!

I explored the behaviour of read_vc(), write_vc() and upgrade_data() with existing vc-data written by git2rdata 0.1.0.

df <- read_vc("df_vc")
# Warning message:
# Mismatching data hash. Data altered outside of git2rdata. 

Maybe the current case can be distinguished more clearly.

ThierryO commented 5 years ago

Thanks @florisvdh for noticing the upgrade_data() issue. This should be solved in 646d60c

florisvdh commented 5 years ago

Great solutions! read_vc() and write_vc() now refuse to work with version 0.1.0 data. They clearly show the need to upgrade the data first.

> library(git2rdata)
> x <- seq(1:26)
> y <- letters
> df <- data.frame(x,y)
> df2 <- read_vc("df_vc") # stored earlier with 0.1.0
 Error: Data stored using an older version of `git2rdata`.
See `?upgrade_data()`. 
> write_vc(df, "df_vc", sorting = c("x"), strict =  FALSE)
 Error: Existing metadata file is invalid.
Data stored using an older version of `git2rdata`.
See `?upgrade_data()`. 
> upgrade_data("df_vc")
[...]/df_vc.yml updated
meta_file 
  "df_vc" 
> df2 <- read_vc("df_vc")
> all.equal(df, df2, check.attributes = FALSE)
[1] TRUE
# Now write_vc() works again (in this example, nothing changed):
> write_vc(df, "df_vc", sorting = c("x"), strict =  FALSE)
b2658819ed189ec4496b4b25c55404f7d0918b6a 3514e919bcca45b232268c650a04db36a18aa6b5 
                             "df_vc.tsv"                              "df_vc.yml"
ElsLommelen commented 5 years ago

@ThierryO : Seems to work now, but could you please try your original code again on your Linux pc to exclude OS-based differences in reading googlesheets-files? I have difficulties using googlesheets4 on Docker...