Upload API Core items
Interface for core data uploading.
APIUploadCore
Bases: APIUploadInternal
Exposes functions for uploading local data to the server.
Source code in src/rmlab/api/upload/core.py
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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
upload_aircrafts(scen_id, items)
async
Upload a set of aircrafts defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
Where items
can refer to:
a CSV file, for instance:
Model,Seat capacity Airbus A320-a,174 Airbus A320-b,180
a JSON file, for instance:
[ {"model": "Airbus A320-a", "seat_capacity": 174}, {"model": "Airbus A320-b", "seat_capacity": 180}, ] * a **JSON list** like the previous.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
Source code in src/rmlab/api/upload/core.py
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 |
|
upload_airlines(scen_id, items)
async
Upload a set of airlines defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
Where items
can refer to:
a CSV file, for instance:
Name,Type MyCarrier,low-cost AnotherCarrier,low-cost MyLegacyCarrier,legacy
a JSON file, for instance:
[ {"name": "MyCarrier", "type": "low-cost"}, {"name": "AnotherCarrier", "type": "low-cost"}, {"name": "MyLegacyCarrier", "type": "legacy"}, ] * a **JSON list** like the previous.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
Source code in src/rmlab/api/upload/core.py
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 |
|
upload_airports(scen_id, items)
async
Upload a set of airports defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
Where items
can refer to:
a CSV file, for instance:
Name,City,Altitude,Latitude,Longitude,ICAO,IATA Geneva,Geneva,431,46.238,6.109,LSGG,GVA Madrid,Madrid,619,40.294,-3.724,LEMD,MAD London Gatwick,London,60,51.148,-0.19,EGKK,LGW London Heathrow,London,25,51.477,-0.461,EGLL,LHR
a JSON file, for instance:
[ {"name": "Geneva", "city": "Geneva", "altitude": 431, "latitude": 46.238, "longitude": 6.109, "icao": "LSGG", "iata": "GVA"}, {"name": "Madrid", "city": "Madrid", "altitude": 619, "latitude": 40.294, "longitude": -3.724, "icao": "LEMD", "iata": "MAD"}, {"name": "London Gatwick", "city": "London", "altitude": 60, "latitude": 51.148, "longitude": -0.19, "icao": "EGKK", "iata": "LGW"}, {"name": "London Heathrow", "city": "London", "altitude": 25, "latitude": 51.477, "longitude": -0.461, "icao": "EGLL", "iata": "LHR"}, ] * a **JSON list** like the previous.
NOTE: Airport cities must reference previously uploaded
City
items with the sameCity.name
.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
rmlab_errors.ClientError | If any of the referenced cities does not exist in server |
Source code in src/rmlab/api/upload/core.py
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 |
|
upload_batch_core(scen_id, *, aircraft_items=None, airline_items=None, airport_items=None, city_items=None, country_items=None, schedule_items=None)
async
Upload a set of items defined in files to server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
aircraft_items | Optional[Union[str, list]] | Aircraft items. Defaults to None. | None |
airline_items | Optional[Union[str, list]] | Airline items. Defaults to None. | None |
airport_items | Optional[Union[str, list]] | Airport items. Defaults to None. | None |
city_items | Optional[Union[str, list]] | City items. Defaults to None. | None |
country_items | Optional[Union[str, list]] | Country items. Defaults to None. | None |
schedule_items | Optional[Union[str, list]] | Flights schedule items. Defaults to None. | None |
Raises:
Type | Description |
---|---|
FileNotFoundError | If a file with items doesn't exist |
TypeError | If non-file items are not list-typed. |
MultipleError | If several errors happened. |
Source code in src/rmlab/api/upload/core.py
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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
upload_cities(scen_id, items)
async
Upload a set of cities defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
Where items
can refer to:
a CSV file, for instance:
Name,Country Geneva,Swizterland Madrid,Spain London,United Kingdom
a JSON file, for instance:
[ {"name": "Geneva", "country": "Switzerland"}, {"name": "Madrid", "country": "Spain"}, {"name": "London", "country": "United Kingdom"}, ] * a **JSON list** like the previous.
NOTE: City countries must reference previously uploaded
Country
items with the sameCountry.name
.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
rmlab_errors.ClientError | If any of the referenced countries does not exist in server |
Source code in src/rmlab/api/upload/core.py
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 |
|
upload_countries(scen_id, items)
async
Upload a set of countries defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
Where items
can refer to:
a CSV file, for instance:
Name,Currency Swizterland,chf Spain,eur United Kingdom,gbp
a JSON file, for instance:
[ {"name": "Switzerland", "currency": "chf"}, {"name": "Spain", "currency": "eur"}, {"name": "United Kingdom", "currency": "gbp"}, ] * a **JSON list** like the previous.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
Source code in src/rmlab/api/upload/core.py
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 |
|
upload_schedules(scen_id, items, *, citysector_id=None, sector_id=None)
async
Upload a set of flights schedules defined in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scen_id | int | Scenario ID | required |
items | str | Filename | required |
citysector_id | Optional[str] | A citysector ID if all schedules belong to the same citysector. Defaults to None. | None |
sector_id | Optional[str] | A sector ID if all schedules belong to the same sector. Defaults to None. | None |
Arguments citysector_id
and sector_id
are always optional. If provided, concurrent uploads of schedules files belonging to different citysectors/sectors are allowed.
Where items
can refer to:
a CSV file, for instance:
Airline,Aircraft,Origin,Destination,Days of Week,Departure time,Duration,Flight number,Sell before days,From Date,To Date MyCarrier,Airbus A320-b,MAD,GVA,-2-4-6-,T08:00,T02:00,2277,15,2022-04-01,2022-05-31 MyCarrier,Airbus A320-a,MAD,GVA,1-3-5-7,T16:00,T02:00,2278,15,2022-04-01,2022-05-31 MyCarrier,Airbus A320-b,GVA,MAD,-2-4-6-,T10:30,T01:30,2377,15,2022-04-01,2022-05-31 MyCarrier,Airbus A320-a,GVA,MAD,1-3-5-7,T18:30,T01:30,2378,15,2022-04-01,2022-05-31
a JSON file, for instance:
[ {"airline": "MyCarrier", "aircraft": "Airbus A320-b", "origin": "MAD", "destination": "GVA", "days_of_week": "-2-4-6-", "departure_time": "T08:00", "duration": "T02:00", "flight_number": "2277", "sell_before_days": 45, "from_date": "2022-04-01", "to_date": "2022-05-31"}, {"airline": "MyCarrier", "aircraft": "Airbus A320-b", "origin": "MAD", "destination": "GVA", "days_of_week": "1-3-5-7", "departure_time": "T16:00", "duration": "T02:00", "flight_number": "2278", "sell_before_days": 45, "from_date": "2022-04-01", "to_date": "2022-05-31"}, {"airline": "MyCarrier", "aircraft": "Airbus A320-b", "origin": "GVA", "destination": "MAD", "days_of_week": "-2-4-6-", "departure_time": "T10:30", "duration": "T01:30", "flight_number": "2377", "sell_before_days": 45, "from_date": "2022-04-01", "to_date": "2022-05-31"}, {"airline": "MyCarrier", "aircraft": "Airbus A320-b", "origin": "GVA", "destination": "MAD", "days_of_week": "1-3-5-7", "departure_time": "T10:30", "duration": "T01:30", "flight_number": "2378", "sell_before_days": 45, "from_date": "2022-04-01", "to_date": "2022-05-31"}, ] * a **JSON list** like the previous.
NOTE: Schedule airlines must reference previously uploaded
Airline
items with the sameAirline.name
.- NOTE: Schedule aircrafts must reference previously uploaded
Aircraft
items with the sameAircraft.model
. - NOTE: Schedule origins must reference previously uploaded
Airport
items with the sameAirport.iata
. - NOTE: Schedule destinations must reference previously uploaded
Airport
items with the sameAirport.iata
. - NOTE: No two schedules with overlapping date ranges (from_date, to_date), and overlapping days of week, with the same flight_number are allowed.
Raises:
Type | Description |
---|---|
ValueError | If file extension is invalid |
FileNotFoundError | If file does not exist |
rmlab_errors.ClientError | If any of the previous Notes are not satisfied |
Source code in src/rmlab/api/upload/core.py
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 |
|