Skip to content

Commit f0df4fb

Browse files
committed
Migrate JobFilesAPIController to FastAPI (excluding TUS uploads)
`FastAPIJobFiles` is the new, FastAPI version of `JobFilesAPIController`. The endpoints that have been migrated should exhibit exactly the same behavior as the old ones from `FastAPIJobFiles`. Something to keep in mind is that while FastAPI has some extra built-in features that the legacy WSGI system did not have, such as answering HEAD requests, those do not work because of the way legacy WSGI endpoints are injected into the FastAPI app (using `app.mount("/", wsgi_handler)`), meaning that for example, HEAD requests are passed to the `wsgi_handler` sub-application. Endpoints dedicated to TUS uploads work in tandem with the WSGI middleware `TusMiddleware` from the `tuswsgi` package. As explained above, WSGI middlewares and endpoints are injected into the FastAPI app after FastAPI routes as a single sub-application `wsgi_handler` using `app.mount("/", wsgi_handler)`, meaning that requests are passed to the `wsgi_handler` sub-application (and thus to `TusMiddleware`) only if there was no FastAPI endpoint defined to handle them. Therefore, they cannot be migrated to FastAPI unless `TusMiddleware` is also migrated to ASGI.
1 parent c6bc71f commit f0df4fb

File tree

4 files changed

+556
-167
lines changed

4 files changed

+556
-167
lines changed

client/src/api/schema/schema.ts

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,44 @@ export interface paths {
29972997
patch?: never;
29982998
trace?: never;
29992999
};
3000+
"/api/jobs/{job_id}/files": {
3001+
parameters: {
3002+
query?: never;
3003+
header?: never;
3004+
path?: never;
3005+
cookie?: never;
3006+
};
3007+
/**
3008+
* Get a file required to staging a job.
3009+
* @description Get a file required to staging a job (proper datasets, extra inputs, task-split inputs, working directory
3010+
* files).
3011+
*
3012+
* This API method is intended only for consumption by job runners, not end users.
3013+
*/
3014+
get: operations["index_api_jobs__job_id__files_get"];
3015+
put?: never;
3016+
/**
3017+
* Populate an output file.
3018+
* @description Populate an output file (formal dataset, task split part, working directory file (such as those related to
3019+
* metadata). This should be a multipart POST with a 'file' parameter containing the contents of the actual file to
3020+
* create.
3021+
*
3022+
* This API method is intended only for consumption by job runners, not end users.
3023+
*/
3024+
post: operations["create_api_jobs__job_id__files_post"];
3025+
delete?: never;
3026+
options?: never;
3027+
/**
3028+
* Get a file required to staging a job.
3029+
* @description Get a file required to staging a job (proper datasets, extra inputs, task-split inputs, working directory
3030+
* files).
3031+
*
3032+
* This API method is intended only for consumption by job runners, not end users.
3033+
*/
3034+
head: operations["index_api_jobs__job_id__files_get"];
3035+
patch?: never;
3036+
trace?: never;
3037+
};
30003038
"/api/jobs/{job_id}/inputs": {
30013039
parameters: {
30023040
query?: never;
@@ -6628,6 +6666,34 @@ export interface components {
66286666
/** Name */
66296667
name?: unknown;
66306668
};
6669+
/** Body_create_api_jobs__job_id__files_post */
6670+
Body_create_api_jobs__job_id__files_post: {
6671+
/**
6672+
* File
6673+
* Format: binary
6674+
*/
6675+
__file?: string;
6676+
/** File Path */
6677+
__file_path?: string;
6678+
/**
6679+
* File
6680+
* Format: binary
6681+
* @description Contents of the file to create.
6682+
*/
6683+
file?: string;
6684+
/**
6685+
* Job Key
6686+
* @description A key used to authenticate this request as acting on behalf or a job runner for the specified job.
6687+
*/
6688+
job_key: string;
6689+
/**
6690+
* Path
6691+
* @description Path to file to create.
6692+
*/
6693+
path: string;
6694+
/** Session Id */
6695+
session_id?: string;
6696+
};
66316697
/** Body_create_form_api_libraries__library_id__contents_post */
66326698
Body_create_form_api_libraries__library_id__contents_post: {
66336699
/** Create Type */
@@ -31164,6 +31230,166 @@ export interface operations {
3116431230
};
3116531231
};
3116631232
};
31233+
index_api_jobs__job_id__files_get: {
31234+
parameters: {
31235+
query: {
31236+
/** @description Path to file. */
31237+
path: string;
31238+
/** @description A key used to authenticate this request as acting on behalf or a job runner for the specified job. */
31239+
job_key: string;
31240+
};
31241+
header?: {
31242+
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
31243+
"run-as"?: string | null;
31244+
};
31245+
path: {
31246+
/** @description Encoded id string of the job. */
31247+
job_id: string;
31248+
};
31249+
cookie?: never;
31250+
};
31251+
requestBody?: never;
31252+
responses: {
31253+
/** @description Contents of file. */
31254+
200: {
31255+
headers: {
31256+
[name: string]: unknown;
31257+
};
31258+
content: {
31259+
"application/octet-stream": unknown;
31260+
};
31261+
};
31262+
/** @description File not found, path does not refer to a file, or input dataset(s) for job have been purged. */
31263+
400: {
31264+
headers: {
31265+
[name: string]: unknown;
31266+
};
31267+
content?: never;
31268+
};
31269+
/** @description Request Error */
31270+
"4XX": {
31271+
headers: {
31272+
[name: string]: unknown;
31273+
};
31274+
content: {
31275+
"application/json": components["schemas"]["MessageExceptionModel"];
31276+
};
31277+
};
31278+
/** @description Server Error */
31279+
"5XX": {
31280+
headers: {
31281+
[name: string]: unknown;
31282+
};
31283+
content: {
31284+
"application/json": components["schemas"]["MessageExceptionModel"];
31285+
};
31286+
};
31287+
};
31288+
};
31289+
create_api_jobs__job_id__files_post: {
31290+
parameters: {
31291+
query?: never;
31292+
header?: {
31293+
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
31294+
"run-as"?: string | null;
31295+
};
31296+
path: {
31297+
/** @description Encoded id string of the job. */
31298+
job_id: string;
31299+
};
31300+
cookie?: never;
31301+
};
31302+
requestBody: {
31303+
content: {
31304+
"multipart/form-data": components["schemas"]["Body_create_api_jobs__job_id__files_post"];
31305+
};
31306+
};
31307+
responses: {
31308+
/** @description An okay message. */
31309+
200: {
31310+
headers: {
31311+
[name: string]: unknown;
31312+
};
31313+
content: {
31314+
"application/json": unknown;
31315+
};
31316+
};
31317+
/** @description Request Error */
31318+
"4XX": {
31319+
headers: {
31320+
[name: string]: unknown;
31321+
};
31322+
content: {
31323+
"application/json": components["schemas"]["MessageExceptionModel"];
31324+
};
31325+
};
31326+
/** @description Server Error */
31327+
"5XX": {
31328+
headers: {
31329+
[name: string]: unknown;
31330+
};
31331+
content: {
31332+
"application/json": components["schemas"]["MessageExceptionModel"];
31333+
};
31334+
};
31335+
};
31336+
};
31337+
index_api_jobs__job_id__files_get: {
31338+
parameters: {
31339+
query: {
31340+
/** @description Path to file. */
31341+
path: string;
31342+
/** @description A key used to authenticate this request as acting on behalf or a job runner for the specified job. */
31343+
job_key: string;
31344+
};
31345+
header?: {
31346+
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
31347+
"run-as"?: string | null;
31348+
};
31349+
path: {
31350+
/** @description Encoded id string of the job. */
31351+
job_id: string;
31352+
};
31353+
cookie?: never;
31354+
};
31355+
requestBody?: never;
31356+
responses: {
31357+
/** @description Contents of file. */
31358+
200: {
31359+
headers: {
31360+
[name: string]: unknown;
31361+
};
31362+
content: {
31363+
"application/octet-stream": unknown;
31364+
};
31365+
};
31366+
/** @description File not found, path does not refer to a file, or input dataset(s) for job have been purged. */
31367+
400: {
31368+
headers: {
31369+
[name: string]: unknown;
31370+
};
31371+
content?: never;
31372+
};
31373+
/** @description Request Error */
31374+
"4XX": {
31375+
headers: {
31376+
[name: string]: unknown;
31377+
};
31378+
content: {
31379+
"application/json": components["schemas"]["MessageExceptionModel"];
31380+
};
31381+
};
31382+
/** @description Server Error */
31383+
"5XX": {
31384+
headers: {
31385+
[name: string]: unknown;
31386+
};
31387+
content: {
31388+
"application/json": components["schemas"]["MessageExceptionModel"];
31389+
};
31390+
};
31391+
};
31392+
};
3116731393
get_inputs_api_jobs__job_id__inputs_get: {
3116831394
parameters: {
3116931395
query?: never;

0 commit comments

Comments
 (0)