SCasanova / f1dataR

An R package to access Formula 1 Data from the Ergast API and the unofficial F1 data stream via the fastf1 python library.
https://scasanova.github.io/f1dataR/
Other
52 stars 5 forks source link

No such file or directory #166

Closed VitoFanelli closed 1 year ago

VitoFanelli commented 1 year ago

Hi, thank you for this package. But I'm not able to use it because every functions I use I get this error. Fo example,

load_results(2023, 4)

Error in gzfile(file, mode) : cannot open the connection In addition: Warning message: In gzfile(file, mode) : cannot open compressed file 'D://f1dataR_http_cache/948140ffb44381f90077cc96050d2d5b.rds', probable reason 'No such file or directory'

load_pitstops(2023,1)

Error in gzfile(file, mode) : cannot open the connection In addition: Warning message: In gzfile(file, mode) : cannot open compressed file 'D://f1dataR_http_cache/03450e79b4e92363d94773d150821d90.rds', probable reason 'No such file or directory'

Only last results or pitstops is ok.

Can you help me?

I downloaded github version of the packages because there is no package available for my R version (4.3.1).

Thank you!

SCasanova commented 1 year ago

Hi Vito,

This sounds like something that should be fixed either today or tomorrow. We've been working on it

As for the CRAN version, that's also coming very soon.

Please try again tomorrow and let us know if the problem persists

SCasanova commented 1 year ago

Please re-download and see if you still ger the error

VitoFanelli commented 1 year ago

Hi, I've tried and it works! But some other functions not. For example,

data <- load_driver_telemetry()

Error in py_run_string_impl(code, local, convert) : File "", line 1 fastf1.Cache.enable_cache('C:\Users\vito\AppData\Local\Temp\RtmpGwdSEw') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

or

data <- load_session_laps(2023,1)

Error in py_run_string_impl(code, local, convert) : File "", line 1 fastf1.Cache.enable_cache('C:\Users\vito\AppData\Local\Temp\RtmpGwdSEw') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I hope this is useful for you to fix if it is a bug.

Thank you very much!

SCasanova commented 1 year ago

It's very useful thanks @VitoFanelli

Hey @pbulsink looks like a practical case of normalizePath(). Looks like we need to add the winslash option everywhere

pbulsink commented 1 year ago

Is these are both FastF1 functions.

I guess we didn't test with cache set to "memory", so I can possibly do that this afternoon/early evening.

As for the bug though, winslash should have been set up already in load_session_data() which is where this error likely comes out of. I think for the fastf1 call itself we need to use default winslash instead of just "/"?

SCasanova commented 1 year ago

The thing is that is see the backslashes in the error message, which is the same I was dealing with when we first used normalize path

pbulsink commented 1 year ago

You sometimes have to escape the slash from R - so // is what's needed. Else C:/Users looks like a failed /Uxxxxxx Unicode character. Sometimes we might even need to double escape it: //// turns into // in R, then in Python it turns into / for a proper path pointer.

pbulsink commented 1 year ago

Not an issue on *nix because they use \ paths instead.

SCasanova commented 1 year ago

Hmm, looking closer at the code it might be a direct issue with tempdir() as it doesn't get normalized when the option is memory. I believe it should be fixed with just that normalization with winslash

SCasanova commented 1 year ago

@VitoFanelli please try in about an hour if possible

VitoFanelli commented 1 year ago

Hey, now it works. Next days I'll try other things and I'll report to you if I find bugs. Thank you @SCasanova @pbulsink for this beautifull package. Very impressive!

SCasanova commented 1 year ago

Good to hear! Let us know if you have any other problems. Enjoy

@pbulsink sadly the fix came after CRAN so we might have to re-submit immediately.

pbulsink commented 1 year ago

Yeah resubmit if you can, this is a bug that shouldn't get rolled out to CRAN if at all possible.

I'll add tests to try make sure we better handle different cache styles soon. They don't need to ship with the CRAN version though.

Phil

On Wed, Aug 16, 2023, 11:29 Santiago Casanova @.***> wrote:

Closed #166 https://github.com/SCasanova/f1dataR/issues/166 as completed.

— Reply to this email directly, view it on GitHub https://github.com/SCasanova/f1dataR/issues/166#event-10111565335, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJLHRSR4NSRDMPGJM6HI3LXVUGQZANCNFSM6AAAAAA3RJYK5I . You are receiving this because you were mentioned.Message ID: @.***>

SCasanova commented 1 year ago

Done. Don't know how CRAN will handle the double submission...