Skip to content

Commit 056a283

Browse files
kysrpexmvdbeek
authored andcommitted
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 393e005 commit 056a283

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
@@ -3062,6 +3062,44 @@ export interface paths {
30623062
patch?: never;
30633063
trace?: never;
30643064
};
3065+
"/api/jobs/{job_id}/files": {
3066+
parameters: {
3067+
query?: never;
3068+
header?: never;
3069+
path?: never;
3070+
cookie?: never;
3071+
};
3072+
/**
3073+
* Get a file required to staging a job.
3074+
* @description Get a file required to staging a job (proper datasets, extra inputs, task-split inputs, working directory
3075+
* files).
3076+
*
3077+
* This API method is intended only for consumption by job runners, not end users.
3078+
*/
3079+
get: operations["index_api_jobs__job_id__files_get"];
3080+
put?: never;
3081+
/**
3082+
* Populate an output file.
3083+
* @description Populate an output file (formal dataset, task split part, working directory file (such as those related to
3084+
* metadata). This should be a multipart POST with a 'file' parameter containing the contents of the actual file to
3085+
* create.
3086+
*
3087+
* This API method is intended only for consumption by job runners, not end users.
3088+
*/
3089+
post: operations["create_api_jobs__job_id__files_post"];
3090+
delete?: never;
3091+
options?: never;
3092+
/**
3093+
* Get a file required to staging a job.
3094+
* @description Get a file required to staging a job (proper datasets, extra inputs, task-split inputs, working directory
3095+
* files).
3096+
*
3097+
* This API method is intended only for consumption by job runners, not end users.
3098+
*/
3099+
head: operations["index_api_jobs__job_id__files_get"];
3100+
patch?: never;
3101+
trace?: never;
3102+
};
30653103
"/api/jobs/{job_id}/inputs": {
30663104
parameters: {
30673105
query?: never;
@@ -6731,6 +6769,34 @@ export interface components {
67316769
/** Name */
67326770
name?: unknown;
67336771
};
6772+
/** Body_create_api_jobs__job_id__files_post */
6773+
Body_create_api_jobs__job_id__files_post: {
6774+
/**
6775+
* File
6776+
* Format: binary
6777+
*/
6778+
__file?: string;
6779+
/** File Path */
6780+
__file_path?: string;
6781+
/**
6782+
* File
6783+
* Format: binary
6784+
* @description Contents of the file to create.
6785+
*/
6786+
file?: string;
6787+
/**
6788+
* Job Key
6789+
* @description A key used to authenticate this request as acting on behalf or a job runner for the specified job.
6790+
*/
6791+
job_key: string;
6792+
/**
6793+
* Path
6794+
* @description Path to file to create.
6795+
*/
6796+
path: string;
6797+
/** Session Id */
6798+
session_id?: string;
6799+
};
67346800
/** Body_create_form_api_libraries__library_id__contents_post */
67356801
Body_create_form_api_libraries__library_id__contents_post: {
67366802
/** Create Type */
@@ -31688,6 +31754,166 @@ export interface operations {
3168831754
};
3168931755
};
3169031756
};
31757+
index_api_jobs__job_id__files_get: {
31758+
parameters: {
31759+
query: {
31760+
/** @description Path to file. */
31761+
path: string;
31762+
/** @description A key used to authenticate this request as acting on behalf or a job runner for the specified job. */
31763+
job_key: string;
31764+
};
31765+
header?: {
31766+
/** @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. */
31767+
"run-as"?: string | null;
31768+
};
31769+
path: {
31770+
/** @description Encoded id string of the job. */
31771+
job_id: string;
31772+
};
31773+
cookie?: never;
31774+
};
31775+
requestBody?: never;
31776+
responses: {
31777+
/** @description Contents of file. */
31778+
200: {
31779+
headers: {
31780+
[name: string]: unknown;
31781+
};
31782+
content: {
31783+
"application/octet-stream": unknown;
31784+
};
31785+
};
31786+
/** @description File not found, path does not refer to a file, or input dataset(s) for job have been purged. */
31787+
400: {
31788+
headers: {
31789+
[name: string]: unknown;
31790+
};
31791+
content?: never;
31792+
};
31793+
/** @description Request Error */
31794+
"4XX": {
31795+
headers: {
31796+
[name: string]: unknown;
31797+
};
31798+
content: {
31799+
"application/json": components["schemas"]["MessageExceptionModel"];
31800+
};
31801+
};
31802+
/** @description Server Error */
31803+
"5XX": {
31804+
headers: {
31805+
[name: string]: unknown;
31806+
};
31807+
content: {
31808+
"application/json": components["schemas"]["MessageExceptionModel"];
31809+
};
31810+
};
31811+
};
31812+
};
31813+
create_api_jobs__job_id__files_post: {
31814+
parameters: {
31815+
query?: never;
31816+
header?: {
31817+
/** @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. */
31818+
"run-as"?: string | null;
31819+
};
31820+
path: {
31821+
/** @description Encoded id string of the job. */
31822+
job_id: string;
31823+
};
31824+
cookie?: never;
31825+
};
31826+
requestBody: {
31827+
content: {
31828+
"multipart/form-data": components["schemas"]["Body_create_api_jobs__job_id__files_post"];
31829+
};
31830+
};
31831+
responses: {
31832+
/** @description An okay message. */
31833+
200: {
31834+
headers: {
31835+
[name: string]: unknown;
31836+
};
31837+
content: {
31838+
"application/json": unknown;
31839+
};
31840+
};
31841+
/** @description Request Error */
31842+
"4XX": {
31843+
headers: {
31844+
[name: string]: unknown;
31845+
};
31846+
content: {
31847+
"application/json": components["schemas"]["MessageExceptionModel"];
31848+
};
31849+
};
31850+
/** @description Server Error */
31851+
"5XX": {
31852+
headers: {
31853+
[name: string]: unknown;
31854+
};
31855+
content: {
31856+
"application/json": components["schemas"]["MessageExceptionModel"];
31857+
};
31858+
};
31859+
};
31860+
};
31861+
index_api_jobs__job_id__files_get: {
31862+
parameters: {
31863+
query: {
31864+
/** @description Path to file. */
31865+
path: string;
31866+
/** @description A key used to authenticate this request as acting on behalf or a job runner for the specified job. */
31867+
job_key: string;
31868+
};
31869+
header?: {
31870+
/** @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. */
31871+
"run-as"?: string | null;
31872+
};
31873+
path: {
31874+
/** @description Encoded id string of the job. */
31875+
job_id: string;
31876+
};
31877+
cookie?: never;
31878+
};
31879+
requestBody?: never;
31880+
responses: {
31881+
/** @description Contents of file. */
31882+
200: {
31883+
headers: {
31884+
[name: string]: unknown;
31885+
};
31886+
content: {
31887+
"application/octet-stream": unknown;
31888+
};
31889+
};
31890+
/** @description File not found, path does not refer to a file, or input dataset(s) for job have been purged. */
31891+
400: {
31892+
headers: {
31893+
[name: string]: unknown;
31894+
};
31895+
content?: never;
31896+
};
31897+
/** @description Request Error */
31898+
"4XX": {
31899+
headers: {
31900+
[name: string]: unknown;
31901+
};
31902+
content: {
31903+
"application/json": components["schemas"]["MessageExceptionModel"];
31904+
};
31905+
};
31906+
/** @description Server Error */
31907+
"5XX": {
31908+
headers: {
31909+
[name: string]: unknown;
31910+
};
31911+
content: {
31912+
"application/json": components["schemas"]["MessageExceptionModel"];
31913+
};
31914+
};
31915+
};
31916+
};
3169131917
get_inputs_api_jobs__job_id__inputs_get: {
3169231918
parameters: {
3169331919
query?: never;

0 commit comments

Comments
 (0)