-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtroubleshooting.Rmd
130 lines (96 loc) · 4.57 KB
/
troubleshooting.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
title: "Troubleshooting"
author: "Tom Yu"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Troubleshooting}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
## Troubleshooting
### Build Synapser
When You install Synapser, You may encounter a similar error:
```{console}
$ R CMD BUILD .
Execution halted
ERROR: configuration failed for package ‘synapser’
* removing ‘/private/var/folders/2n/xwh21m9s3sq_mhnkbc6n6z_c0000gn/T/RtmpZ47UPP/Rinstf55478c3f09/synapser’
```
For this error, You can try first remove $HOME\.virtualenvs then run the build command again.
### Build Synapser when creating vignettes
When you build synapser, you may encounter the following error:
```{console}
$ R CMD BUILD .
Error: processing vignette 'upload.Rmd' failed with diagnostics:
No credentials provided.
--- failed re-building ‘upload.Rmd’
```
First, create a file named `.synapseConfig` in your home directory. Then add the following lines to the file:
```{console}
[authentication]
authtoken = <authtoken>
```
Now, you should be able to build Synapser.
### Using Synapser with reticulate
Synapser is compatible with [reticulate](https://rstudio.github.io/reticulate/) and the two packages can be used together in the same R session.
If you are getting this kind error:
```
synStore(tmp2)
Error in value[[3L]](cond) : 'concreteType'
```
As of synapser v2.0.0, it is still only compatible with reticulate v1.28 due to a miscellaneous update in [reticulate v1.29](https://rstudio.github.io/reticulate/news/index.html#misc-1-29). Specifically, `py_to_r()` now succeeds when converting subtypes of the built-in Python types (e.g. list, dict, str). Please install reticulate v1.28.
```
remotes::install_github('rstudio/reticulate@v1.28')
```
As a workaround, if you wish to communicate with Synapse in an R session that also uses reticulate, you can use the [Synapse Python client](https://python-docs.synapse.org/build/html/index.html) direclty through reticulate.
### Type Conversions
The core of the Synapser library is the [python client](https://python-docs.synapse.org/). [Reticulate](https://rstudio.github.io/reticulate/) is used to translate R to Python and back.
These are the documented conversions from R to Python: [Reticulate Type Conversions](https://rstudio.github.io/reticulate/articles/calling_python.html#type-conversions)
`NA` values in R do not have a direct equivalent in Python. This has been a topic of great discussion. Synapser is not trying to solve this. `NA` values in R are handled by Reticulate per the implementation defined in Reticulate.
When working with R and Reticulate, NA values in types tables are converted by Reticulate depending on the data type.
For numeric data types, NA values are converted to the corresponding R value `NA_real_`.
For integer data types, NA values are converted to `NA_integer_`.
For logical data types, NA values are converted to `NA_logical_`.
For character data types, NA values are converted to `NA_character_`.
In addition, Reticulate also converts any values that cannot be coerced to the specified data type to `NA_character_`.
Reticulate performs these conversions automatically.
When Reticulate converts R objects to Python objects, the NA values in R types tables are converted to Python's `None`.
R's `NA` is a logical constant of length 1 which is used to represent the absence of a value. In Python, the equivalent of `NA` is `None`, which is a special constant used to indicate the absence of a value.
Reticulate automatically converts `NA` values in R types tables to `None` when converting R objects to Python. This ensures that the data types and values remain consistent between the two languages.
Examples:
* Reticulate converts logical `NA`s to Python `True`, which convert back to `TRUE` in R
```{r collapse = TRUE}
na_logical = NA
class(na_logical)
na_py <- reticulate::r_to_py(na_logical)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
```{r collapse = TRUE}
na_logical = c(T, F, NA)
class(na_logical)
na_py <- reticulate::r_to_py(na_logical)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
* Reticulate converts character `NA`s to Python strings, which convert back to characters in R
```{r collapse = TRUE}
na_char = c("T", "F", NA)
class(na_char)
na_py <- reticulate::r_to_py(na_char)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
* Reticulate converts numeric `NA`s to Python `np.nan`, which convert back to `NA` in R
```{r collapse = TRUE}
na_num = c(1538006762583, 1538006762584, NA)
class(na_num)
na_py <- reticulate::r_to_py(na_num)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```