AbstractRecordsAndFilesAPI
Bases: AbstractAPI
Abstract class to interact with both the records and the data stored in the file
field.
The return for this class must be records, against the /export
endpoint when retrieve_files
is False. When retrieve_files
is True, the cache
should be checked first. If the file doesn’t exist there, it should be retrieved
from the database against the /record_table_and_files
endpoint. The file should
be a tarball with the metadata.csv and the file associated with the record,
where the file is named according to the id
field in metadata.csv. Data files
should be .csv.gz
.
Source code in yeastdnnexplorer/interface/AbstractRecordsAndFilesAPI.py
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
export_files_url_suffix: str
property
writable
¶
The URL suffix for exporting files.
export_url_suffix: str
property
writable
¶
The URL suffix for exporting records.
__init__(**kwargs)
¶
Initialize the AbstractRecordsAndFilesAPI object. This will serve as an interface to an endpoint that can serve both records and files, and cache the file/retrieve from the cache if it exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
parameters to pass to AbstractAPI. |
{}
|
Source code in yeastdnnexplorer/interface/AbstractRecordsAndFilesAPI.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
read(callback=lambda , , : {'metadata': metadata, 'data': data}, retrieve_files=False, **kwargs)
async
¶
Retrieve data from the endpoint according to the retrieve_files
parameter. If
retrieve_files
is False, the records will be returned as a dataframe. If
retrieve_files
is True, the files associated with the records will be
retrieved either from the local cache or from the database. Note that a user can
select which effect_colname and pvalue_colname is used for a genomicfile (see
database documentation for more details). If one or both of those are present in
the params, and retrieve_file is true, then that column name is added to the
cache_key. Eg if record 1 is being retrieved from mcisaac data with
effect_colname “log2_raio”, then the cache_key for that data will be
“1_log2_ratio”. The default effect colname, which is set by the database, will
be stored with only the record id as the cache_key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[DataFrame, dict[str, Any] | None, Any], Any]
|
The function to call with the metadata. Signature must include |
lambda , , : {'metadata': metadata, 'data': data}
|
retrieve_files |
bool
|
Boolean. Whether to retrieve the files associated with the records. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Any
|
The result of the callback function. |
Raises:
Type | Description |
---|---|
ValueError
|
If the callback function does not have the correct signature. |
aiohttp.ClientError
|
If there is an error in the GET request. |
pd.errors.ParserError
|
If there is an error reading the request |
Source code in yeastdnnexplorer/interface/AbstractRecordsAndFilesAPI.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|