From ecddd94667a92bc161d93d6c9dcdb83983582505 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 5 Sep 2023 15:30:25 +0200 Subject: [PATCH 001/116] Generate client from https://github.com/i-VRESSE/bartender/pull/78/commits/3189ba7dea8ea2514e76604ed1aaf67d9016fe58 --- app/bartender-client/.openapi-generator/FILES | 2 + .../.openapi-generator/VERSION | 2 +- app/bartender-client/apis/ApplicationApi.ts | 308 ++-- app/bartender-client/apis/DefaultApi.ts | 72 +- app/bartender-client/apis/JobApi.ts | 1346 ++++++++--------- app/bartender-client/apis/UserApi.ts | 93 +- app/bartender-client/apis/index.ts | 8 +- app/bartender-client/index.ts | 6 +- .../models/ApplicatonConfiguration.ts | 114 +- app/bartender-client/models/DirectoryItem.ts | 137 +- .../models/HTTPValidationError.ts | 81 +- .../models/InteractiveAppResult.ts | 89 ++ .../InteractiveApplicationConfiguration.ts | 131 ++ app/bartender-client/models/JobModelDTO.ts | 171 +-- app/bartender-client/models/LocationInner.ts | 25 +- app/bartender-client/models/User.ts | 96 +- .../models/ValidationError.ts | 110 +- app/bartender-client/models/index.ts | 16 +- app/bartender-client/runtime.ts | 664 ++++---- 19 files changed, 1708 insertions(+), 1763 deletions(-) create mode 100644 app/bartender-client/models/InteractiveAppResult.ts create mode 100644 app/bartender-client/models/InteractiveApplicationConfiguration.ts diff --git a/app/bartender-client/.openapi-generator/FILES b/app/bartender-client/.openapi-generator/FILES index ff495456..7edd6bc6 100644 --- a/app/bartender-client/.openapi-generator/FILES +++ b/app/bartender-client/.openapi-generator/FILES @@ -7,6 +7,8 @@ index.ts models/ApplicatonConfiguration.ts models/DirectoryItem.ts models/HTTPValidationError.ts +models/InteractiveAppResult.ts +models/InteractiveApplicationConfiguration.ts models/JobModelDTO.ts models/LocationInner.ts models/User.ts diff --git a/app/bartender-client/.openapi-generator/VERSION b/app/bartender-client/.openapi-generator/VERSION index cd802a1e..e7e42a4b 100644 --- a/app/bartender-client/.openapi-generator/VERSION +++ b/app/bartender-client/.openapi-generator/VERSION @@ -1 +1 @@ -6.6.0 \ No newline at end of file +6.3.0 \ No newline at end of file diff --git a/app/bartender-client/apis/ApplicationApi.ts b/app/bartender-client/apis/ApplicationApi.ts index d8b5be0e..de7a33f6 100644 --- a/app/bartender-client/apis/ApplicationApi.ts +++ b/app/bartender-client/apis/ApplicationApi.ts @@ -5,214 +5,166 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import * as runtime from "../runtime"; -import type { ApplicatonConfiguration, HTTPValidationError } from "../models"; + +import * as runtime from '../runtime'; +import type { + ApplicatonConfiguration, + HTTPValidationError, +} from '../models'; import { - ApplicatonConfigurationFromJSON, - ApplicatonConfigurationToJSON, - HTTPValidationErrorFromJSON, - HTTPValidationErrorToJSON, -} from "../models"; + ApplicatonConfigurationFromJSON, + ApplicatonConfigurationToJSON, + HTTPValidationErrorFromJSON, + HTTPValidationErrorToJSON, +} from '../models'; export interface GetApplicationRequest { - application: string; + application: string; } export interface UploadJobRequest { - application: string; - upload: Blob; + application: string; + upload: Blob; } /** - * + * */ export class ApplicationApi extends runtime.BaseAPI { - /** - * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. - * Get Application - */ - async getApplicationRaw( - requestParameters: GetApplicationRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.application === null || - requestParameters.application === undefined - ) { - throw new runtime.RequiredError( - "application", - "Required parameter requestParameters.application was null or undefined when calling getApplication." - ); - } - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request( - { - path: `/api/application/{application}`.replace( - `{${"application"}}`, - encodeURIComponent(String(requestParameters.application)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response, (jsonValue) => - ApplicatonConfigurationFromJSON(jsonValue) - ); - } - - /** - * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. - * Get Application - */ - async getApplication( - requestParameters: GetApplicationRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.getApplicationRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * List application names. Args: config: Config with applications. Returns: The list. - * List Applications - */ - async listApplicationsRaw( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request( - { - path: `/api/application/`, - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response); - } - - /** - * List application names. Args: config: Config with applications. Returns: The list. - * List Applications - */ - async listApplications( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - const response = await this.listApplicationsRaw(initOverrides); - return await response.value(); - } - - /** - * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. - * Upload Job - */ - async uploadJobRaw( - requestParameters: UploadJobRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.application === null || - requestParameters.application === undefined - ) { - throw new runtime.RequiredError( - "application", - "Required parameter requestParameters.application was null or undefined when calling uploadJob." - ); + /** + * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. + * Get Application + */ + async getApplicationRaw(requestParameters: GetApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.application === null || requestParameters.application === undefined) { + throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling getApplication.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/api/application/{application}`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ApplicatonConfigurationFromJSON(jsonValue)); } - if ( - requestParameters.upload === null || - requestParameters.upload === undefined - ) { - throw new runtime.RequiredError( - "upload", - "Required parameter requestParameters.upload was null or undefined when calling uploadJob." - ); + /** + * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. + * Get Application + */ + async getApplication(requestParameters: GetApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getApplicationRaw(requestParameters, initOverrides); + return await response.value(); } - const queryParameters: any = {}; + /** + * List application names. Args: config: Config with applications. Returns: The list. + * List Applications + */ + async listApplicationsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; - const headerParameters: runtime.HTTPHeaders = {}; + const headerParameters: runtime.HTTPHeaders = {}; - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); + const response = await this.request({ + path: `/api/application/`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } + return new runtime.JSONApiResponse(response); } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + + /** + * List application names. Args: config: Config with applications. Returns: The list. + * List Applications + */ + async listApplications(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.listApplicationsRaw(initOverrides); + return await response.value(); } - const consumes: runtime.Consume[] = [ - { contentType: "multipart/form-data" }, - ]; - // @ts-ignore: canConsumeForm may be unused - const canConsumeForm = runtime.canConsumeForm(consumes); - - let formParams: { append(param: string, value: any): any }; - let useForm = false; - // use FormData to transmit files using content-type "multipart/form-data" - useForm = canConsumeForm; - if (useForm) { - formParams = new FormData(); - } else { - formParams = new URLSearchParams(); + /** + * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. + * Upload Job + */ + async uploadJobRaw(requestParameters: UploadJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.application === null || requestParameters.application === undefined) { + throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling uploadJob.'); + } + + if (requestParameters.upload === null || requestParameters.upload === undefined) { + throw new runtime.RequiredError('upload','Required parameter requestParameters.upload was null or undefined when calling uploadJob.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const consumes: runtime.Consume[] = [ + { contentType: 'multipart/form-data' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + // use FormData to transmit files using content-type "multipart/form-data" + useForm = canConsumeForm; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters.upload !== undefined) { + formParams.append('upload', requestParameters.upload as any); + } + + const response = await this.request({ + path: `/api/application/{application}/job`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: formParams, + }, initOverrides); + + return new runtime.VoidApiResponse(response); } - if (requestParameters.upload !== undefined) { - formParams.append("upload", requestParameters.upload as any); + /** + * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. + * Upload Job + */ + async uploadJob(requestParameters: UploadJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.uploadJobRaw(requestParameters, initOverrides); } - const response = await this.request( - { - path: `/api/application/{application}/job`.replace( - `{${"application"}}`, - encodeURIComponent(String(requestParameters.application)) - ), - method: "PUT", - headers: headerParameters, - query: queryParameters, - body: formParams, - }, - initOverrides - ); - - return new runtime.VoidApiResponse(response); - } - - /** - * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. - * Upload Job - */ - async uploadJob( - requestParameters: UploadJobRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - await this.uploadJobRaw(requestParameters, initOverrides); - } } diff --git a/app/bartender-client/apis/DefaultApi.ts b/app/bartender-client/apis/DefaultApi.ts index db29161c..365dfce9 100644 --- a/app/bartender-client/apis/DefaultApi.ts +++ b/app/bartender-client/apis/DefaultApi.ts @@ -5,55 +5,47 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import * as runtime from "../runtime"; + +import * as runtime from '../runtime'; /** - * + * */ export class DefaultApi extends runtime.BaseAPI { - /** - * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. - * Health Check - */ - async healthCheckRaw( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request( - { - path: `/api/health`, - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; + + /** + * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. + * Health Check + */ + async healthCheckRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/api/health`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; } - } - - /** - * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. - * Health Check - */ - async healthCheck( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.healthCheckRaw(initOverrides); - return await response.value(); - } + + /** + * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. + * Health Check + */ + async healthCheck(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.healthCheckRaw(initOverrides); + return await response.value(); + } + } diff --git a/app/bartender-client/apis/JobApi.ts b/app/bartender-client/apis/JobApi.ts index b64ea5c5..5af57619 100644 --- a/app/bartender-client/apis/JobApi.ts +++ b/app/bartender-client/apis/JobApi.ts @@ -5,787 +5,687 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import * as runtime from "../runtime"; + +import * as runtime from '../runtime'; import type { DirectoryItem, HTTPValidationError, + InteractiveAppResult, + InteractiveApplicationConfiguration, JobModelDTO, -} from "../models"; +} from '../models'; import { - DirectoryItemFromJSON, - DirectoryItemToJSON, - HTTPValidationErrorFromJSON, - HTTPValidationErrorToJSON, - JobModelDTOFromJSON, - JobModelDTOToJSON, -} from "../models"; + DirectoryItemFromJSON, + DirectoryItemToJSON, + HTTPValidationErrorFromJSON, + HTTPValidationErrorToJSON, + InteractiveAppResultFromJSON, + InteractiveAppResultToJSON, + InteractiveApplicationConfigurationFromJSON, + InteractiveApplicationConfigurationToJSON, + JobModelDTOFromJSON, + JobModelDTOToJSON, +} from '../models'; + +export interface GetInteractiveAppRequest { + application: string; + jobid: number; +} + +export interface ListInteractiveAppsRequest { + jobid: number; +} export interface RetrieveJobRequest { - jobid: number; + jobid: number; } export interface RetrieveJobDirectoriesRequest { - jobid: number; - maxDepth?: number; + jobid: number; + maxDepth?: number; } export interface RetrieveJobDirectoriesFromPathRequest { - path: string; - jobid: number; - maxDepth?: number; + path: string; + jobid: number; + maxDepth?: number; } export interface RetrieveJobDirectoryAsArchiveRequest { - jobid: number; - archiveFormat?: RetrieveJobDirectoryAsArchiveArchiveFormatEnum; - exclude?: Array; - excludeDirs?: Array; + jobid: number; + archiveFormat?: RetrieveJobDirectoryAsArchiveArchiveFormatEnum; + exclude?: Array; + excludeDirs?: Array; } export interface RetrieveJobFilesRequest { - path: string; - jobid: number; + path: string; + jobid: number; } export interface RetrieveJobStderrRequest { - jobid: number; + jobid: number; } export interface RetrieveJobStdoutRequest { - jobid: number; + jobid: number; } export interface RetrieveJobSubdirectoryAsArchiveRequest { - path: string; - jobid: number; - archiveFormat?: RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum; - exclude?: Array; - excludeDirs?: Array; + path: string; + jobid: number; + archiveFormat?: RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum; + exclude?: Array; + excludeDirs?: Array; } export interface RetrieveJobsRequest { - limit?: number; - offset?: number; + limit?: number; + offset?: number; +} + +export interface RunInteractiveAppRequest { + jobid: number; + application: string; + body?: object; } /** - * + * */ export class JobApi extends runtime.BaseAPI { - /** - * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. - * Retrieve Job - */ - async retrieveJobRaw( - requestParameters: RetrieveJobRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJob." - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}`.replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response, (jsonValue) => - JobModelDTOFromJSON(jsonValue) - ); - } - - /** - * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. - * Retrieve Job - */ - async retrieveJob( - requestParameters: RetrieveJobRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories - */ - async retrieveJobDirectoriesRaw( - requestParameters: RetrieveJobDirectoriesRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectories." - ); - } - - const queryParameters: any = {}; - - if (requestParameters.maxDepth !== undefined) { - queryParameters["max_depth"] = requestParameters.maxDepth; - } - const headerParameters: runtime.HTTPHeaders = {}; + /** + * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. + * Get Interactive App + */ + async getInteractiveAppRaw(requestParameters: GetInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.application === null || requestParameters.application === undefined) { + throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling getInteractiveApp.'); + } + + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling getInteractiveApp.'); + } - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/api/job/{jobid}/interactive/{application}`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => InteractiveApplicationConfigurationFromJSON(jsonValue)); + } + + /** + * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. + * Get Interactive App + */ + async getInteractiveApp(requestParameters: GetInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getInteractiveAppRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. + * List Interactive Apps + */ + async listInteractiveAppsRaw(requestParameters: ListInteractiveAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling listInteractiveApps.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/api/job/{jobid}/interactive`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. + * List Interactive Apps + */ + async listInteractiveApps(requestParameters: ListInteractiveAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.listInteractiveAppsRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. + * Retrieve Job + */ + async retrieveJobRaw(requestParameters: RetrieveJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJob.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => JobModelDTOFromJSON(jsonValue)); + } + + /** + * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. + * Retrieve Job + */ + async retrieveJob(requestParameters: RetrieveJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories + */ + async retrieveJobDirectoriesRaw(requestParameters: RetrieveJobDirectoriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectories.'); + } + + const queryParameters: any = {}; + + if (requestParameters.maxDepth !== undefined) { + queryParameters['max_depth'] = requestParameters.maxDepth; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/directories`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DirectoryItemFromJSON(jsonValue)); + } + + /** + * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories + */ + async retrieveJobDirectories(requestParameters: RetrieveJobDirectoriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobDirectoriesRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories From Path + */ + async retrieveJobDirectoriesFromPathRaw(requestParameters: RetrieveJobDirectoriesFromPathRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.path === null || requestParameters.path === undefined) { + throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobDirectoriesFromPath.'); + } + + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoriesFromPath.'); + } + + const queryParameters: any = {}; + + if (requestParameters.maxDepth !== undefined) { + queryParameters['max_depth'] = requestParameters.maxDepth; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/directories/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DirectoryItemFromJSON(jsonValue)); + } + + /** + * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories From Path + */ + async retrieveJobDirectoriesFromPath(requestParameters: RetrieveJobDirectoriesFromPathRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobDirectoriesFromPathRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir + * Retrieve Job Directory As Archive + */ + async retrieveJobDirectoryAsArchiveRaw(requestParameters: RetrieveJobDirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoryAsArchive.'); + } + + const queryParameters: any = {}; + + if (requestParameters.archiveFormat !== undefined) { + queryParameters['archive_format'] = requestParameters.archiveFormat; + } + + if (requestParameters.exclude) { + queryParameters['exclude'] = requestParameters.exclude; + } + + if (requestParameters.excludeDirs) { + queryParameters['exclude_dirs'] = requestParameters.excludeDirs; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/archive`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir + * Retrieve Job Directory As Archive + */ + async retrieveJobDirectoryAsArchive(requestParameters: RetrieveJobDirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobDirectoryAsArchiveRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. + * Retrieve Job Files + */ + async retrieveJobFilesRaw(requestParameters: RetrieveJobFilesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.path === null || requestParameters.path === undefined) { + throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobFiles.'); + } + + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobFiles.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/files/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. + * Retrieve Job Files + */ + async retrieveJobFiles(requestParameters: RetrieveJobFilesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobFilesRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. + * Retrieve Job Stderr + */ + async retrieveJobStderrRaw(requestParameters: RetrieveJobStderrRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStderr.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/stderr`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. + * Retrieve Job Stderr + */ + async retrieveJobStderr(requestParameters: RetrieveJobStderrRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobStderrRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. + * Retrieve Job Stdout + */ + async retrieveJobStdoutRaw(requestParameters: RetrieveJobStdoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStdout.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/stdout`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. + * Retrieve Job Stdout + */ + async retrieveJobStdout(requestParameters: RetrieveJobStdoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobStdoutRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir + * Retrieve Job Subdirectory As Archive + */ + async retrieveJobSubdirectoryAsArchiveRaw(requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.path === null || requestParameters.path === undefined) { + throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobSubdirectoryAsArchive.'); + } + + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobSubdirectoryAsArchive.'); + } + + const queryParameters: any = {}; + + if (requestParameters.archiveFormat !== undefined) { + queryParameters['archive_format'] = requestParameters.archiveFormat; + } + + if (requestParameters.exclude) { + queryParameters['exclude'] = requestParameters.exclude; + } + + if (requestParameters.excludeDirs) { + queryParameters['exclude_dirs'] = requestParameters.excludeDirs; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/archive/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir + * Retrieve Job Subdirectory As Archive + */ + async retrieveJobSubdirectoryAsArchive(requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.retrieveJobSubdirectoryAsArchiveRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. + * Retrieve Jobs + */ + async retrieveJobsRaw(requestParameters: RetrieveJobsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + if (requestParameters.limit !== undefined) { + queryParameters['limit'] = requestParameters.limit; + } + + if (requestParameters.offset !== undefined) { + queryParameters['offset'] = requestParameters.offset; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(JobModelDTOFromJSON)); + } + + /** + * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. + * Retrieve Jobs + */ + async retrieveJobs(requestParameters: RetrieveJobsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.retrieveJobsRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. + * Run Interactive App + */ + async runInteractiveAppRaw(requestParameters: RunInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.jobid === null || requestParameters.jobid === undefined) { + throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling runInteractiveApp.'); + } + + if (requestParameters.application === null || requestParameters.application === undefined) { + throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling runInteractiveApp.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/job/{jobid}/interactive/{application}`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))).replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: requestParameters.body as any, + }, initOverrides); - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } + return new runtime.JSONApiResponse(response, (jsonValue) => InteractiveAppResultFromJSON(jsonValue)); } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/directories`.replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response, (jsonValue) => - DirectoryItemFromJSON(jsonValue) - ); - } - - /** - * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories - */ - async retrieveJobDirectories( - requestParameters: RetrieveJobDirectoriesRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobDirectoriesRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories From Path - */ - async retrieveJobDirectoriesFromPathRaw( - requestParameters: RetrieveJobDirectoriesFromPathRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.path === null || - requestParameters.path === undefined - ) { - throw new runtime.RequiredError( - "path", - "Required parameter requestParameters.path was null or undefined when calling retrieveJobDirectoriesFromPath." - ); - } - - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoriesFromPath." - ); - } - - const queryParameters: any = {}; - if (requestParameters.maxDepth !== undefined) { - queryParameters["max_depth"] = requestParameters.maxDepth; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/directories/{path}` - .replace( - `{${"path"}}`, - encodeURIComponent(String(requestParameters.path)) - ) - .replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response, (jsonValue) => - DirectoryItemFromJSON(jsonValue) - ); - } - - /** - * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories From Path - */ - async retrieveJobDirectoriesFromPath( - requestParameters: RetrieveJobDirectoriesFromPathRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobDirectoriesFromPathRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir - * Retrieve Job Directory As Archive - */ - async retrieveJobDirectoryAsArchiveRaw( - requestParameters: RetrieveJobDirectoryAsArchiveRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoryAsArchive." - ); - } - - const queryParameters: any = {}; - - if (requestParameters.archiveFormat !== undefined) { - queryParameters["archive_format"] = requestParameters.archiveFormat; - } - - if (requestParameters.exclude) { - queryParameters["exclude"] = requestParameters.exclude; - } - - if (requestParameters.excludeDirs) { - queryParameters["exclude_dirs"] = requestParameters.excludeDirs; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/archive`.replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } - } - - /** - * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir - * Retrieve Job Directory As Archive - */ - async retrieveJobDirectoryAsArchive( - requestParameters: RetrieveJobDirectoryAsArchiveRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobDirectoryAsArchiveRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. - * Retrieve Job Files - */ - async retrieveJobFilesRaw( - requestParameters: RetrieveJobFilesRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.path === null || - requestParameters.path === undefined - ) { - throw new runtime.RequiredError( - "path", - "Required parameter requestParameters.path was null or undefined when calling retrieveJobFiles." - ); - } - - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobFiles." - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/files/{path}` - .replace( - `{${"path"}}`, - encodeURIComponent(String(requestParameters.path)) - ) - .replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } - } - - /** - * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. - * Retrieve Job Files - */ - async retrieveJobFiles( - requestParameters: RetrieveJobFilesRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobFilesRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. - * Retrieve Job Stderr - */ - async retrieveJobStderrRaw( - requestParameters: RetrieveJobStderrRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStderr." - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/stderr`.replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } - } - - /** - * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. - * Retrieve Job Stderr - */ - async retrieveJobStderr( - requestParameters: RetrieveJobStderrRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobStderrRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. - * Retrieve Job Stdout - */ - async retrieveJobStdoutRaw( - requestParameters: RetrieveJobStdoutRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStdout." - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/stdout`.replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } - } - - /** - * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. - * Retrieve Job Stdout - */ - async retrieveJobStdout( - requestParameters: RetrieveJobStdoutRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobStdoutRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir - * Retrieve Job Subdirectory As Archive - */ - async retrieveJobSubdirectoryAsArchiveRaw( - requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - if ( - requestParameters.path === null || - requestParameters.path === undefined - ) { - throw new runtime.RequiredError( - "path", - "Required parameter requestParameters.path was null or undefined when calling retrieveJobSubdirectoryAsArchive." - ); - } - - if ( - requestParameters.jobid === null || - requestParameters.jobid === undefined - ) { - throw new runtime.RequiredError( - "jobid", - "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobSubdirectoryAsArchive." - ); - } - - const queryParameters: any = {}; - - if (requestParameters.archiveFormat !== undefined) { - queryParameters["archive_format"] = requestParameters.archiveFormat; - } - - if (requestParameters.exclude) { - queryParameters["exclude"] = requestParameters.exclude; - } - - if (requestParameters.excludeDirs) { - queryParameters["exclude_dirs"] = requestParameters.excludeDirs; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - const response = await this.request( - { - path: `/api/job/{jobid}/archive/{path}` - .replace( - `{${"path"}}`, - encodeURIComponent(String(requestParameters.path)) - ) - .replace( - `{${"jobid"}}`, - encodeURIComponent(String(requestParameters.jobid)) - ), - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - if (this.isJsonMime(response.headers.get("content-type"))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } - } - - /** - * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir - * Retrieve Job Subdirectory As Archive - */ - async retrieveJobSubdirectoryAsArchive( - requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.retrieveJobSubdirectoryAsArchiveRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } - - /** - * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. - * Retrieve Jobs - */ - async retrieveJobsRaw( - requestParameters: RetrieveJobsRequest, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise>> { - const queryParameters: any = {}; - - if (requestParameters.limit !== undefined) { - queryParameters["limit"] = requestParameters.limit; - } - - if (requestParameters.offset !== undefined) { - queryParameters["offset"] = requestParameters.offset; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + /** + * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. + * Run Interactive App + */ + async runInteractiveApp(requestParameters: RunInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.runInteractiveAppRaw(requestParameters, initOverrides); + return await response.value(); } - const response = await this.request( - { - path: `/api/job/`, - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); - - return new runtime.JSONApiResponse(response, (jsonValue) => - jsonValue.map(JobModelDTOFromJSON) - ); - } - - /** - * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. - * Retrieve Jobs - */ - async retrieveJobs( - requestParameters: RetrieveJobsRequest = {}, - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - const response = await this.retrieveJobsRaw( - requestParameters, - initOverrides - ); - return await response.value(); - } } /** * @export */ export const RetrieveJobDirectoryAsArchiveArchiveFormatEnum = { - Zip: ".zip", - Tar: ".tar", - TarXz: ".tar.xz", - TarGz: ".tar.gz", - TarBz2: ".tar.bz2", + Zip: '.zip', + Tar: '.tar', + TarXz: '.tar.xz', + TarGz: '.tar.gz', + TarBz2: '.tar.bz2' } as const; -export type RetrieveJobDirectoryAsArchiveArchiveFormatEnum = - (typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum)[keyof typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum]; +export type RetrieveJobDirectoryAsArchiveArchiveFormatEnum = typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum[keyof typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum]; /** * @export */ export const RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = { - Zip: ".zip", - Tar: ".tar", - TarXz: ".tar.xz", - TarGz: ".tar.gz", - TarBz2: ".tar.bz2", + Zip: '.zip', + Tar: '.tar', + TarXz: '.tar.xz', + TarGz: '.tar.gz', + TarBz2: '.tar.bz2' } as const; -export type RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = - (typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum)[keyof typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum]; +export type RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum[keyof typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum]; diff --git a/app/bartender-client/apis/UserApi.ts b/app/bartender-client/apis/UserApi.ts index 5d982e0c..94626dda 100644 --- a/app/bartender-client/apis/UserApi.ts +++ b/app/bartender-client/apis/UserApi.ts @@ -5,67 +5,66 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import * as runtime from "../runtime"; -import type { User } from "../models"; -import { UserFromJSON, UserToJSON } from "../models"; + +import * as runtime from '../runtime'; +import type { + User, +} from '../models'; +import { + UserFromJSON, + UserToJSON, +} from '../models'; /** - * + * */ export class UserApi extends runtime.BaseAPI { - /** - * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. - * Whoami - */ - async whoamiRaw( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise> { - const queryParameters: any = {}; - const headerParameters: runtime.HTTPHeaders = {}; + /** + * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. + * Whoami + */ + async whoamiRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); + const headerParameters: runtime.HTTPHeaders = {}; - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } - const response = await this.request( - { - path: `/api/whoami`, - method: "GET", - headers: headerParameters, - query: queryParameters, - }, - initOverrides - ); + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); - return new runtime.JSONApiResponse(response, (jsonValue) => - UserFromJSON(jsonValue) - ); - } + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/api/whoami`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. + * Whoami + */ + async whoami(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.whoamiRaw(initOverrides); + return await response.value(); + } - /** - * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. - * Whoami - */ - async whoami( - initOverrides?: RequestInit | runtime.InitOverrideFunction - ): Promise { - const response = await this.whoamiRaw(initOverrides); - return await response.value(); - } } diff --git a/app/bartender-client/apis/index.ts b/app/bartender-client/apis/index.ts index e3ef3240..77cd312e 100644 --- a/app/bartender-client/apis/index.ts +++ b/app/bartender-client/apis/index.ts @@ -1,6 +1,6 @@ /* tslint:disable */ /* eslint-disable */ -export * from "./ApplicationApi"; -export * from "./DefaultApi"; -export * from "./JobApi"; -export * from "./UserApi"; +export * from './ApplicationApi'; +export * from './DefaultApi'; +export * from './JobApi'; +export * from './UserApi'; diff --git a/app/bartender-client/index.ts b/app/bartender-client/index.ts index 749c57fa..be9d1ede 100644 --- a/app/bartender-client/index.ts +++ b/app/bartender-client/index.ts @@ -1,5 +1,5 @@ /* tslint:disable */ /* eslint-disable */ -export * from "./runtime"; -export * from "./apis"; -export * from "./models"; +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/app/bartender-client/models/ApplicatonConfiguration.ts b/app/bartender-client/models/ApplicatonConfiguration.ts index 318cbcfe..32f3e64b 100644 --- a/app/bartender-client/models/ApplicatonConfiguration.ts +++ b/app/bartender-client/models/ApplicatonConfiguration.ts @@ -5,95 +5,89 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; +import { exists, mapValues } from '../runtime'; /** * Command to run application. - * + * * `$config` in command string will be replaced with value of * ApplicatonConfiguration.config. - * + * * The config value must be a path relative to the job directory. - * + * * .. code-block:: yaml - * + * * command: wc $config * config: README.md * @export * @interface ApplicatonConfiguration */ export interface ApplicatonConfiguration { - /** - * - * @type {string} - * @memberof ApplicatonConfiguration - */ - command: string; - /** - * - * @type {string} - * @memberof ApplicatonConfiguration - */ - config: string; - /** - * - * @type {Array} - * @memberof ApplicatonConfiguration - */ - allowedRoles?: Array; + /** + * + * @type {string} + * @memberof ApplicatonConfiguration + */ + command: string; + /** + * + * @type {string} + * @memberof ApplicatonConfiguration + */ + config: string; + /** + * + * @type {Array} + * @memberof ApplicatonConfiguration + */ + allowedRoles?: Array; } /** * Check if a given object implements the ApplicatonConfiguration interface. */ export function instanceOfApplicatonConfiguration(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "command" in value; - isInstance = isInstance && "config" in value; + let isInstance = true; + isInstance = isInstance && "command" in value; + isInstance = isInstance && "config" in value; - return isInstance; + return isInstance; } -export function ApplicatonConfigurationFromJSON( - json: any -): ApplicatonConfiguration { - return ApplicatonConfigurationFromJSONTyped(json, false); +export function ApplicatonConfigurationFromJSON(json: any): ApplicatonConfiguration { + return ApplicatonConfigurationFromJSONTyped(json, false); } -export function ApplicatonConfigurationFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): ApplicatonConfiguration { - if (json === undefined || json === null) { - return json; - } - return { - command: json["command"], - config: json["config"], - allowedRoles: !exists(json, "allowed_roles") - ? undefined - : json["allowed_roles"], - }; +export function ApplicatonConfigurationFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicatonConfiguration { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'command': json['command'], + 'config': json['config'], + 'allowedRoles': !exists(json, 'allowed_roles') ? undefined : json['allowed_roles'], + }; } -export function ApplicatonConfigurationToJSON( - value?: ApplicatonConfiguration | null -): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - command: value.command, - config: value.config, - allowed_roles: value.allowedRoles, - }; +export function ApplicatonConfigurationToJSON(value?: ApplicatonConfiguration | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'command': value.command, + 'config': value.config, + 'allowed_roles': value.allowedRoles, + }; } + diff --git a/app/bartender-client/models/DirectoryItem.ts b/app/bartender-client/models/DirectoryItem.ts index 39c38228..e845d01d 100644 --- a/app/bartender-client/models/DirectoryItem.ts +++ b/app/bartender-client/models/DirectoryItem.ts @@ -5,102 +5,97 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; +import { exists, mapValues } from '../runtime'; /** * An entry in a directory. * @export * @interface DirectoryItem */ export interface DirectoryItem { - /** - * - * @type {string} - * @memberof DirectoryItem - */ - name: string; - /** - * - * @type {string} - * @memberof DirectoryItem - */ - path: string; - /** - * - * @type {boolean} - * @memberof DirectoryItem - */ - isDir: boolean; - /** - * - * @type {boolean} - * @memberof DirectoryItem - */ - isFile: boolean; - /** - * - * @type {Array} - * @memberof DirectoryItem - */ - children?: Array; + /** + * + * @type {string} + * @memberof DirectoryItem + */ + name: string; + /** + * + * @type {string} + * @memberof DirectoryItem + */ + path: string; + /** + * + * @type {boolean} + * @memberof DirectoryItem + */ + isDir: boolean; + /** + * + * @type {boolean} + * @memberof DirectoryItem + */ + isFile: boolean; + /** + * + * @type {Array} + * @memberof DirectoryItem + */ + children?: Array; } /** * Check if a given object implements the DirectoryItem interface. */ export function instanceOfDirectoryItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "path" in value; - isInstance = isInstance && "isDir" in value; - isInstance = isInstance && "isFile" in value; + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "path" in value; + isInstance = isInstance && "isDir" in value; + isInstance = isInstance && "isFile" in value; - return isInstance; + return isInstance; } export function DirectoryItemFromJSON(json: any): DirectoryItem { - return DirectoryItemFromJSONTyped(json, false); + return DirectoryItemFromJSONTyped(json, false); } -export function DirectoryItemFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): DirectoryItem { - if (json === undefined || json === null) { - return json; - } - return { - name: json["name"], - path: json["path"], - isDir: json["is_dir"], - isFile: json["is_file"], - children: !exists(json, "children") - ? undefined - : (json["children"] as Array).map(DirectoryItemFromJSON), - }; +export function DirectoryItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): DirectoryItem { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'path': json['path'], + 'isDir': json['is_dir'], + 'isFile': json['is_file'], + 'children': !exists(json, 'children') ? undefined : ((json['children'] as Array).map(DirectoryItemFromJSON)), + }; } export function DirectoryItemToJSON(value?: DirectoryItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - name: value.name, - path: value.path, - is_dir: value.isDir, - is_file: value.isFile, - children: - value.children === undefined - ? undefined - : (value.children as Array).map(DirectoryItemToJSON), - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'path': value.path, + 'is_dir': value.isDir, + 'is_file': value.isFile, + 'children': value.children === undefined ? undefined : ((value.children as Array).map(DirectoryItemToJSON)), + }; } + diff --git a/app/bartender-client/models/HTTPValidationError.ts b/app/bartender-client/models/HTTPValidationError.ts index 37e580da..ac281ea0 100644 --- a/app/bartender-client/models/HTTPValidationError.ts +++ b/app/bartender-client/models/HTTPValidationError.ts @@ -5,75 +5,68 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; -import type { ValidationError } from "./ValidationError"; +import { exists, mapValues } from '../runtime'; +import type { ValidationError } from './ValidationError'; import { - ValidationErrorFromJSON, - ValidationErrorFromJSONTyped, - ValidationErrorToJSON, -} from "./ValidationError"; + ValidationErrorFromJSON, + ValidationErrorFromJSONTyped, + ValidationErrorToJSON, +} from './ValidationError'; /** - * + * * @export * @interface HTTPValidationError */ export interface HTTPValidationError { - /** - * - * @type {Array} - * @memberof HTTPValidationError - */ - detail?: Array; + /** + * + * @type {Array} + * @memberof HTTPValidationError + */ + detail?: Array; } /** * Check if a given object implements the HTTPValidationError interface. */ export function instanceOfHTTPValidationError(value: object): boolean { - let isInstance = true; + let isInstance = true; - return isInstance; + return isInstance; } export function HTTPValidationErrorFromJSON(json: any): HTTPValidationError { - return HTTPValidationErrorFromJSONTyped(json, false); + return HTTPValidationErrorFromJSONTyped(json, false); } -export function HTTPValidationErrorFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): HTTPValidationError { - if (json === undefined || json === null) { - return json; - } - return { - detail: !exists(json, "detail") - ? undefined - : (json["detail"] as Array).map(ValidationErrorFromJSON), - }; +export function HTTPValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): HTTPValidationError { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'detail': !exists(json, 'detail') ? undefined : ((json['detail'] as Array).map(ValidationErrorFromJSON)), + }; } -export function HTTPValidationErrorToJSON( - value?: HTTPValidationError | null -): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - detail: - value.detail === undefined - ? undefined - : (value.detail as Array).map(ValidationErrorToJSON), - }; +export function HTTPValidationErrorToJSON(value?: HTTPValidationError | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'detail': value.detail === undefined ? undefined : ((value.detail as Array).map(ValidationErrorToJSON)), + }; } + diff --git a/app/bartender-client/models/InteractiveAppResult.ts b/app/bartender-client/models/InteractiveAppResult.ts new file mode 100644 index 00000000..5f43f9b1 --- /dev/null +++ b/app/bartender-client/models/InteractiveAppResult.ts @@ -0,0 +1,89 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * bartender + * Job middleware for i-VRESSE + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Represents the result of running a InteractiveApp. + * + * Attributes: + * returncode: The return code of the InteractiveApp process. + * stderr: The standard error output of the InteractiveApp process. + * stdout: The standard output of the InteractiveApp process. + * @export + * @interface InteractiveAppResult + */ +export interface InteractiveAppResult { + /** + * + * @type {number} + * @memberof InteractiveAppResult + */ + returncode: number; + /** + * + * @type {string} + * @memberof InteractiveAppResult + */ + stderr: string; + /** + * + * @type {string} + * @memberof InteractiveAppResult + */ + stdout: string; +} + +/** + * Check if a given object implements the InteractiveAppResult interface. + */ +export function instanceOfInteractiveAppResult(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "returncode" in value; + isInstance = isInstance && "stderr" in value; + isInstance = isInstance && "stdout" in value; + + return isInstance; +} + +export function InteractiveAppResultFromJSON(json: any): InteractiveAppResult { + return InteractiveAppResultFromJSONTyped(json, false); +} + +export function InteractiveAppResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): InteractiveAppResult { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'returncode': json['returncode'], + 'stderr': json['stderr'], + 'stdout': json['stdout'], + }; +} + +export function InteractiveAppResultToJSON(value?: InteractiveAppResult | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'returncode': value.returncode, + 'stderr': value.stderr, + 'stdout': value.stdout, + }; +} + diff --git a/app/bartender-client/models/InteractiveApplicationConfiguration.ts b/app/bartender-client/models/InteractiveApplicationConfiguration.ts new file mode 100644 index 00000000..008d2b39 --- /dev/null +++ b/app/bartender-client/models/InteractiveApplicationConfiguration.ts @@ -0,0 +1,131 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * bartender + * Job middleware for i-VRESSE + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Configuration for an interactive application. + * + * Interactive apps that can be run on a completed job. + * + * Interactive apps are small interactive calculations that + * can be run within a request-response cycle (<30s). + * + * A interactive app should + * + * * be quick to run (<60s) + * * produce very little output (stdout, stderr, files) + * * in the job directory only write new files and overwrite its own files. + * * not have any arguments that can leak information, + * for example paths to files outside the job directory. + * + * Example: + * + * Given completed job 123 run interactive app rescore with: + * + * ```python + * response = client.post('/api/job/123/interactiveapp/rescore', json={ + * 'module': 1, + * 'w_elec': 0.2, + * 'w_vdw': 0.2, + * 'w_desolv': 0.2, + * 'w_bsa': 0.1, + * 'w_air': 0.3, + * }) + * if response.json()['returncode'] == 0: + * # Find the results in the job directory somewhere + * files = client.get('/api/job/123/files') + * ``` + * + * Attributes: + * command: Shell command template to run in job directory. + * Use Python string template syntax to substitute variables from request body. + * input: JSON schema of request body. + * Dialect of JSON Schema should be draft 2020-12. + * Root should be an object and its properties should be scalar. + * description: Description of the interactive app. + * timeout: Maximum time in seconds to wait for command to finish. + * @export + * @interface InteractiveApplicationConfiguration + */ +export interface InteractiveApplicationConfiguration { + /** + * + * @type {string} + * @memberof InteractiveApplicationConfiguration + */ + command: string; + /** + * + * @type {object} + * @memberof InteractiveApplicationConfiguration + */ + input: object; + /** + * + * @type {string} + * @memberof InteractiveApplicationConfiguration + */ + description?: string; + /** + * + * @type {number} + * @memberof InteractiveApplicationConfiguration + */ + timeout?: number; +} + +/** + * Check if a given object implements the InteractiveApplicationConfiguration interface. + */ +export function instanceOfInteractiveApplicationConfiguration(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "command" in value; + isInstance = isInstance && "input" in value; + + return isInstance; +} + +export function InteractiveApplicationConfigurationFromJSON(json: any): InteractiveApplicationConfiguration { + return InteractiveApplicationConfigurationFromJSONTyped(json, false); +} + +export function InteractiveApplicationConfigurationFromJSONTyped(json: any, ignoreDiscriminator: boolean): InteractiveApplicationConfiguration { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'command': json['command'], + 'input': json['input'], + 'description': !exists(json, 'description') ? undefined : json['description'], + 'timeout': !exists(json, 'timeout') ? undefined : json['timeout'], + }; +} + +export function InteractiveApplicationConfigurationToJSON(value?: InteractiveApplicationConfiguration | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'command': value.command, + 'input': value.input, + 'description': value.description, + 'timeout': value.timeout, + }; +} + diff --git a/app/bartender-client/models/JobModelDTO.ts b/app/bartender-client/models/JobModelDTO.ts index 065b647d..7c4f8f58 100644 --- a/app/bartender-client/models/JobModelDTO.ts +++ b/app/bartender-client/models/JobModelDTO.ts @@ -5,123 +5,124 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; +import { exists, mapValues } from '../runtime'; /** * DTO for job models. - * + * * It returned when accessing job models from the API. * @export * @interface JobModelDTO */ export interface JobModelDTO { - /** - * - * @type {number} - * @memberof JobModelDTO - */ - id: number; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - name: string; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - application: string; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - state: JobModelDTOStateEnum; - /** - * - * @type {Date} - * @memberof JobModelDTO - */ - createdOn: Date; - /** - * - * @type {Date} - * @memberof JobModelDTO - */ - updatedOn: Date; + /** + * + * @type {number} + * @memberof JobModelDTO + */ + id: number; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + name: string; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + application: string; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + state: JobModelDTOStateEnum; + /** + * + * @type {Date} + * @memberof JobModelDTO + */ + createdOn: Date; + /** + * + * @type {Date} + * @memberof JobModelDTO + */ + updatedOn: Date; } + /** * @export */ export const JobModelDTOStateEnum = { - New: "new", - Queued: "queued", - Running: "running", - StagingOut: "staging_out", - Ok: "ok", - Error: "error", + New: 'new', + Queued: 'queued', + Running: 'running', + StagingOut: 'staging_out', + Ok: 'ok', + Error: 'error' } as const; -export type JobModelDTOStateEnum = - (typeof JobModelDTOStateEnum)[keyof typeof JobModelDTOStateEnum]; +export type JobModelDTOStateEnum = typeof JobModelDTOStateEnum[keyof typeof JobModelDTOStateEnum]; + /** * Check if a given object implements the JobModelDTO interface. */ export function instanceOfJobModelDTO(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "application" in value; - isInstance = isInstance && "state" in value; - isInstance = isInstance && "createdOn" in value; - isInstance = isInstance && "updatedOn" in value; + let isInstance = true; + isInstance = isInstance && "id" in value; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "application" in value; + isInstance = isInstance && "state" in value; + isInstance = isInstance && "createdOn" in value; + isInstance = isInstance && "updatedOn" in value; - return isInstance; + return isInstance; } export function JobModelDTOFromJSON(json: any): JobModelDTO { - return JobModelDTOFromJSONTyped(json, false); + return JobModelDTOFromJSONTyped(json, false); } -export function JobModelDTOFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): JobModelDTO { - if (json === undefined || json === null) { - return json; - } - return { - id: json["id"], - name: json["name"], - application: json["application"], - state: json["state"], - createdOn: new Date(json["created_on"]), - updatedOn: new Date(json["updated_on"]), - }; +export function JobModelDTOFromJSONTyped(json: any, ignoreDiscriminator: boolean): JobModelDTO { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': json['id'], + 'name': json['name'], + 'application': json['application'], + 'state': json['state'], + 'createdOn': (new Date(json['created_on'])), + 'updatedOn': (new Date(json['updated_on'])), + }; } export function JobModelDTOToJSON(value?: JobModelDTO | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - id: value.id, - name: value.name, - application: value.application, - state: value.state, - created_on: value.createdOn.toISOString(), - updated_on: value.updatedOn.toISOString(), - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'name': value.name, + 'application': value.application, + 'state': value.state, + 'created_on': (value.createdOn.toISOString()), + 'updated_on': (value.updatedOn.toISOString()), + }; } + diff --git a/app/bartender-client/models/LocationInner.ts b/app/bartender-client/models/LocationInner.ts index 1bc62f1b..c044159c 100644 --- a/app/bartender-client/models/LocationInner.ts +++ b/app/bartender-client/models/LocationInner.ts @@ -5,41 +5,40 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; +import { exists, mapValues } from '../runtime'; /** - * + * * @export * @interface LocationInner */ -export interface LocationInner {} +export interface LocationInner { +} /** * Check if a given object implements the LocationInner interface. */ export function instanceOfLocationInner(value: object): boolean { - let isInstance = true; + let isInstance = true; - return isInstance; + return isInstance; } export function LocationInnerFromJSON(json: any): LocationInner { - return LocationInnerFromJSONTyped(json, false); + return LocationInnerFromJSONTyped(json, false); } -export function LocationInnerFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): LocationInner { - return json; +export function LocationInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): LocationInner { + return json; } export function LocationInnerToJSON(value?: LocationInner | null): any { - return value; + return value; } + diff --git a/app/bartender-client/models/User.ts b/app/bartender-client/models/User.ts index 1aae08c9..6b65dc17 100644 --- a/app/bartender-client/models/User.ts +++ b/app/bartender-client/models/User.ts @@ -5,79 +5,79 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; +import { exists, mapValues } from '../runtime'; /** * User model. * @export * @interface User */ export interface User { - /** - * - * @type {string} - * @memberof User - */ - username: string; - /** - * - * @type {Array} - * @memberof User - */ - roles?: Array; - /** - * - * @type {string} - * @memberof User - */ - apikey: string; + /** + * + * @type {string} + * @memberof User + */ + username: string; + /** + * + * @type {Array} + * @memberof User + */ + roles?: Array; + /** + * + * @type {string} + * @memberof User + */ + apikey: string; } /** * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "username" in value; - isInstance = isInstance && "apikey" in value; + let isInstance = true; + isInstance = isInstance && "username" in value; + isInstance = isInstance && "apikey" in value; - return isInstance; + return isInstance; } export function UserFromJSON(json: any): User { - return UserFromJSONTyped(json, false); + return UserFromJSONTyped(json, false); } -export function UserFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): User { - if (json === undefined || json === null) { - return json; - } - return { - username: json["username"], - roles: !exists(json, "roles") ? undefined : json["roles"], - apikey: json["apikey"], - }; +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'username': json['username'], + 'roles': !exists(json, 'roles') ? undefined : json['roles'], + 'apikey': json['apikey'], + }; } export function UserToJSON(value?: User | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - username: value.username, - roles: value.roles, - apikey: value.apikey, - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'username': value.username, + 'roles': value.roles, + 'apikey': value.apikey, + }; } + diff --git a/app/bartender-client/models/ValidationError.ts b/app/bartender-client/models/ValidationError.ts index 6ec249a7..f2ccd93e 100644 --- a/app/bartender-client/models/ValidationError.ts +++ b/app/bartender-client/models/ValidationError.ts @@ -5,87 +5,87 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from "../runtime"; -import type { LocationInner } from "./LocationInner"; +import { exists, mapValues } from '../runtime'; +import type { LocationInner } from './LocationInner'; import { - LocationInnerFromJSON, - LocationInnerFromJSONTyped, - LocationInnerToJSON, -} from "./LocationInner"; + LocationInnerFromJSON, + LocationInnerFromJSONTyped, + LocationInnerToJSON, +} from './LocationInner'; /** - * + * * @export * @interface ValidationError */ export interface ValidationError { - /** - * - * @type {Array} - * @memberof ValidationError - */ - loc: Array; - /** - * - * @type {string} - * @memberof ValidationError - */ - msg: string; - /** - * - * @type {string} - * @memberof ValidationError - */ - type: string; + /** + * + * @type {Array} + * @memberof ValidationError + */ + loc: Array; + /** + * + * @type {string} + * @memberof ValidationError + */ + msg: string; + /** + * + * @type {string} + * @memberof ValidationError + */ + type: string; } /** * Check if a given object implements the ValidationError interface. */ export function instanceOfValidationError(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "loc" in value; - isInstance = isInstance && "msg" in value; - isInstance = isInstance && "type" in value; + let isInstance = true; + isInstance = isInstance && "loc" in value; + isInstance = isInstance && "msg" in value; + isInstance = isInstance && "type" in value; - return isInstance; + return isInstance; } export function ValidationErrorFromJSON(json: any): ValidationError { - return ValidationErrorFromJSONTyped(json, false); + return ValidationErrorFromJSONTyped(json, false); } -export function ValidationErrorFromJSONTyped( - json: any, - ignoreDiscriminator: boolean -): ValidationError { - if (json === undefined || json === null) { - return json; - } - return { - loc: (json["loc"] as Array).map(LocationInnerFromJSON), - msg: json["msg"], - type: json["type"], - }; +export function ValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ValidationError { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'loc': ((json['loc'] as Array).map(LocationInnerFromJSON)), + 'msg': json['msg'], + 'type': json['type'], + }; } export function ValidationErrorToJSON(value?: ValidationError | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - loc: (value.loc as Array).map(LocationInnerToJSON), - msg: value.msg, - type: value.type, - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'loc': ((value.loc as Array).map(LocationInnerToJSON)), + 'msg': value.msg, + 'type': value.type, + }; } + diff --git a/app/bartender-client/models/index.ts b/app/bartender-client/models/index.ts index 90b138a5..6435368c 100644 --- a/app/bartender-client/models/index.ts +++ b/app/bartender-client/models/index.ts @@ -1,9 +1,11 @@ /* tslint:disable */ /* eslint-disable */ -export * from "./ApplicatonConfiguration"; -export * from "./DirectoryItem"; -export * from "./HTTPValidationError"; -export * from "./JobModelDTO"; -export * from "./LocationInner"; -export * from "./User"; -export * from "./ValidationError"; +export * from './ApplicatonConfiguration'; +export * from './DirectoryItem'; +export * from './HTTPValidationError'; +export * from './InteractiveAppResult'; +export * from './InteractiveApplicationConfiguration'; +export * from './JobModelDTO'; +export * from './LocationInner'; +export * from './User'; +export * from './ValidationError'; diff --git a/app/bartender-client/runtime.ts b/app/bartender-client/runtime.ts index 8e2c814b..b2e15098 100644 --- a/app/bartender-client/runtime.ts +++ b/app/bartender-client/runtime.ts @@ -5,91 +5,83 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // override for fetch implementation - middleware?: Middleware[]; // middleware to apply before/after fetch requests - queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: - | string - | Promise - | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security - headers?: HTTPHeaders; //header params we want to use on every request - credentials?: RequestCredentials; //value for the credentials param we want to use on each request + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} - - set config(configuration: Configuration) { - this.configuration = configuration; - } - - get basePath(): string { - return this.configuration.basePath != null - ? this.configuration.basePath - : BASE_PATH; - } - - get fetchApi(): FetchAPI | undefined { - return this.configuration.fetchApi; - } - - get middleware(): Middleware[] { - return this.configuration.middleware || []; - } - - get queryParamsStringify(): (params: HTTPQuery) => string { - return this.configuration.queryParamsStringify || querystring; - } - - get username(): string | undefined { - return this.configuration.username; - } - - get password(): string | undefined { - return this.configuration.password; - } - - get apiKey(): ((name: string) => string) | undefined { - const apiKey = this.configuration.apiKey; - if (apiKey) { - return typeof apiKey === "function" ? apiKey : () => apiKey; + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; } - return undefined; - } - - get accessToken(): - | ((name?: string, scopes?: string[]) => string | Promise) - | undefined { - const accessToken = this.configuration.accessToken; - if (accessToken) { - return typeof accessToken === "function" - ? accessToken - : async () => accessToken; + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; } - return undefined; - } - get headers(): HTTPHeaders | undefined { - return this.configuration.headers; - } + get username(): string | undefined { + return this.configuration.username; + } - get credentials(): RequestCredentials | undefined { - return this.configuration.credentials; - } + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } } export const DefaultConfig = new Configuration(); @@ -98,325 +90,232 @@ export const DefaultConfig = new Configuration(); * This is the base class for all generated API classes. */ export class BaseAPI { - private static readonly jsonRegex = new RegExp( - "^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", - "i" - ); - private middleware: Middleware[]; - - constructor(protected configuration = DefaultConfig) { - this.middleware = configuration.middleware; - } - - withMiddleware(this: T, ...middlewares: Middleware[]) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - - withPreMiddleware( - this: T, - ...preMiddlewares: Array - ) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - - withPostMiddleware( - this: T, - ...postMiddlewares: Array - ) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - protected isJsonMime(mime: string | null | undefined): boolean { - if (!mime) { - return false; + + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; } - return BaseAPI.jsonRegex.test(mime); - } - - protected async request( - context: RequestOpts, - initOverrides?: RequestInit | InitOverrideFunction - ): Promise { - const { url, init } = await this.createFetchParams(context, initOverrides); - const response = await this.fetchApi(url, init); - if (response && response.status >= 200 && response.status < 300) { - return response; + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; } - throw new ResponseError(response, "Response returned an error code"); - } - - private async createFetchParams( - context: RequestOpts, - initOverrides?: RequestInit | InitOverrideFunction - ) { - let url = this.configuration.basePath + context.path; - if ( - context.query !== undefined && - Object.keys(context.query).length !== 0 - ) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += "?" + this.configuration.queryParamsStringify(context.query); + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); } - const headers = Object.assign( - {}, - this.configuration.headers, - context.headers - ); - Object.keys(headers).forEach((key) => - headers[key] === undefined ? delete headers[key] : {} - ); - - const initOverrideFn = - typeof initOverrides === "function" - ? initOverrides - : async () => initOverrides; - - const initParams = { - method: context.method, - headers, - body: context.body, - credentials: this.configuration.credentials, - }; + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } - const overriddenInit: RequestInit = { - ...initParams, - ...(await initOverrideFn({ - init: initParams, - context, - })), - }; + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response && (response.status >= 200 && response.status < 300)) { + return response; + } + throw new ResponseError(response, 'Response returned an error code'); + } - const init: RequestInit = { - ...overriddenInit, - body: - isFormData(overriddenInit.body) || - overriddenInit.body instanceof URLSearchParams || - isBlob(overriddenInit.body) - ? overriddenInit.body - : JSON.stringify(overriddenInit.body), - }; + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + this.configuration.queryParamsStringify(context.query); + } - return { url, init }; - } - - private fetchApi = async (url: string, init: RequestInit) => { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = - (await middleware.pre({ - fetch: this.fetchApi, - ...fetchParams, - })) || fetchParams; - } + const headers = Object.assign({}, this.configuration.headers, context.headers); + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; + + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + }; + + const init: RequestInit = { + ...overriddenInit, + body: + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), + }; + + return { url, init }; } - let response: Response | undefined = undefined; - try { - response = await (this.configuration.fetchApi || fetch)( - fetchParams.url, - fetchParams.init - ); - } catch (e) { - for (const middleware of this.middleware) { - if (middleware.onError) { - response = - (await middleware.onError({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - error: e, - response: response ? response.clone() : undefined, - })) || response; + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } } - } - if (response === undefined) { - if (e instanceof Error) { - throw new FetchError( - e, - "The request failed and the interceptors did not return an alternative response" - ); - } else { - throw e; + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + }) || response; + } } - } + return response; } - for (const middleware of this.middleware) { - if (middleware.post) { - response = - (await middleware.post({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - response: response.clone(), - })) || response; - } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; } - return response; - }; - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone(this: T): T { - const constructor = this.constructor as any; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -} +}; function isBlob(value: any): value is Blob { - return typeof Blob !== "undefined" && value instanceof Blob; + return typeof Blob !== 'undefined' && value instanceof Blob; } function isFormData(value: any): value is FormData { - return typeof FormData !== "undefined" && value instanceof FormData; + return typeof FormData !== "undefined" && value instanceof FormData; } export class ResponseError extends Error { - override name: "ResponseError" = "ResponseError"; - constructor(public response: Response, msg?: string) { - super(msg); - } + override name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } } export class FetchError extends Error { - override name: "FetchError" = "FetchError"; - constructor(public cause: Error, msg?: string) { - super(msg); - } + override name: "FetchError" = "FetchError"; + constructor(public cause: Error, msg?: string) { + super(msg); + } } export class RequiredError extends Error { - override name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } + override name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } } export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", }; -export type FetchAPI = WindowOrWorkerGlobalScope["fetch"]; +export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; export type Json = any; -export type HTTPMethod = - | "GET" - | "POST" - | "PUT" - | "PATCH" - | "DELETE" - | "OPTIONS" - | "HEAD"; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { - [key: string]: - | string - | number - | null - | boolean - | Array - | Set - | HTTPQuery; -}; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { - headers?: HTTPHeaders; - method: HTTPMethod; - credentials?: RequestCredentials; - body?: HTTPBody; -}; -export type ModelPropertyNaming = - | "camelCase" - | "snake_case" - | "PascalCase" - | "original"; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverrideFunction = (requestContext: { - init: HTTPRequestInit; - context: RequestOpts; -}) => Promise; +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise export interface FetchParams { - url: string; - init: RequestInit; + url: string; + init: RequestInit; } export interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; } export function exists(json: any, key: string) { - const value = json[key]; - return value !== null && value !== undefined; + const value = json[key]; + return value !== null && value !== undefined; } -export function querystring(params: HTTPQuery, prefix: string = ""): string { - return Object.keys(params) - .map((key) => querystringSingleKey(key, params[key], prefix)) - .filter((part) => part.length > 0) - .join("&"); +export function querystring(params: HTTPQuery, prefix: string = ''): string { + return Object.keys(params) + .map(key => querystringSingleKey(key, params[key], prefix)) + .filter(part => part.length > 0) + .join('&'); } -function querystringSingleKey( - key: string, - value: - | string - | number - | null - | undefined - | boolean - | Array - | Set - | HTTPQuery, - keyPrefix: string = "" -): string { - const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); - if (value instanceof Array) { - const multiValue = value - .map((singleValue) => encodeURIComponent(String(singleValue))) - .join(`&${encodeURIComponent(fullKey)}=`); - return `${encodeURIComponent(fullKey)}=${multiValue}`; - } - if (value instanceof Set) { - const valueAsArray = Array.from(value); - return querystringSingleKey(key, valueAsArray, keyPrefix); - } - if (value instanceof Date) { - return `${encodeURIComponent(fullKey)}=${encodeURIComponent( - value.toISOString() - )}`; - } - if (value instanceof Object) { - return querystring(value as HTTPQuery, fullKey); - } - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { + const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; } export function mapValues(data: any, fn: (item: any) => any) { @@ -427,85 +326,82 @@ export function mapValues(data: any, fn: (item: any) => any) { } export function canConsumeForm(consumes: Consume[]): boolean { - for (const consume of consumes) { - if ("multipart/form-data" === consume.contentType) { - return true; + for (const consume of consumes) { + if ('multipart/form-data' === consume.contentType) { + return true; + } } - } - return false; + return false; } export interface Consume { - contentType: string; + contentType: string; } export interface RequestContext { - fetch: FetchAPI; - url: string; - init: RequestInit; + fetch: FetchAPI; + url: string; + init: RequestInit; } export interface ResponseContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - response: Response; + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; } export interface ErrorContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - error: unknown; - response?: Response; + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; } export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; - onError?(context: ErrorContext): Promise; + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse { - raw: Response; - value(): Promise; + raw: Response; + value(): Promise; } export interface ResponseTransformer { - (json: any): T; + (json: any): T; } export class JSONApiResponse { - constructor( - public raw: Response, - private transformer: ResponseTransformer = (jsonValue: any) => jsonValue - ) {} - - async value(): Promise { - return this.transformer(await this.raw.json()); - } + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } } export class VoidApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return undefined; - } + async value(): Promise { + return undefined; + } } export class BlobApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return await this.raw.blob(); - } + async value(): Promise { + return await this.raw.blob(); + }; } export class TextApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return await this.raw.text(); - } + async value(): Promise { + return await this.raw.text(); + }; } From dc70fba6a21bcb6a6636d9e55dfa56ffb4c4002b Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 5 Sep 2023 16:40:02 +0200 Subject: [PATCH 002/116] Starting putting pieces together --- app/models/job.server.test.ts | 224 ++++++++++++++++++++++++++++++++ app/models/job.server.ts | 71 ++++++++++ app/routes/jobs.$id.rescore.tsx | 72 ++++++++++ 3 files changed, 367 insertions(+) create mode 100644 app/models/job.server.test.ts create mode 100644 app/routes/jobs.$id.rescore.tsx diff --git a/app/models/job.server.test.ts b/app/models/job.server.test.ts new file mode 100644 index 00000000..70042415 --- /dev/null +++ b/app/models/job.server.test.ts @@ -0,0 +1,224 @@ +import { describe, test, expect } from "vitest"; +import { getWeightsFromConfig } from "./job.server"; + +describe('getWeightsFromConfig', () => { + test('should return the correct weights', () => { + // Pruned config of + // output/data/configurations/enhanced_haddock_params.json + // from run of docking-antibody-antigen-ranairCDR-clt-test.cfg example + const config = { + "cns_exec": "", + "ncores": 8, + "max_cpus": true, + "mode": "local", + "batch_type": "slurm", + "queue": "", + "queue_limit": 100, + "concat": 1, + "self_contained": false, + "clean": false, + "preprocess": false, + "postprocess": true, + "run_dir": "output", + "molecules": [ + "data/4G6K_fv.pdb", + "data/4I1B-matched.pdb" + ], + "topoaa.1": { + }, + "rigidbody.1": { + }, + "caprieval.1": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + }, + "clustfcc.1": { + "threshold": 4, + "executable": "src/contact_fcc", + "contact_distance_cutoff": 5.0, + "fraction_cutoff": 0.6, + "strictness": 0.75 + }, + "seletopclusts.1": { + "top_models": 10, + "top_cluster": 1000 + }, + "caprieval.2": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + }, + "flexref.1": { + }, + "caprieval.3": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + }, + "emref.1": { + }, + "caprieval.4": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + }, + "emscoring.1": { + }, + "clustfcc.2": { + "executable": "src/contact_fcc", + "contact_distance_cutoff": 5.0, + "fraction_cutoff": 0.6, + "threshold": 4, + "strictness": 0.75 + }, + "seletopclusts.2": { + "top_cluster": 1000, + "top_models": NaN + }, + "caprieval.5": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + }, + "mdscoring.1": { + "w_air": 0.0, + "w_bsa": 0.0, + "w_cdih": 0.0, + "w_dani": 0.0, + "w_deint": 0.0, + "w_desolv": 1.0, + "w_elec": 0.2, + "w_lcc": -10000.0, + "w_rg": 0.0, + "w_sani": 0.0, + "w_sym": 0.0, + "w_vdw": 1.0, + "w_vean": 0.0, + "w_xpcs": 0.0, + "w_xrdc": 0.0, + "w_zres": 0.0, + "contactairs": false, + "kcont": 1.0, + "ssdihed": "", + "error_dih": 10, + "dnarest_on": false, + "ligand_param_fname": "", + "ligand_top_fname": "", + "elecflag": true, + "dielec": "cdie", + "epsilon": 1.0, + "dihedflag": true, + "individualize": true, + "solvent": "water", + "nemsteps": 200, + "timestep": 0.002, + "waterheatsteps": 100, + "watersteps": 1250, + "watercoolsteps": 500, + "iniseed": 917, + "keepwater": false, + "tolerance": 5, + "log_level": "quiet" + }, + "caprieval.6": { + "reference_fname": "data/4G6M-matched.pdb", + "irmsd": true, + "fnat": true, + "lrmsd": true, + "ilrmsd": true, + "dockq": true, + "irmsd_cutoff": 10.0, + "fnat_cutoff": 5.0, + "receptor_chain": "A", + "ligand_chains": [ + "B" + ], + "sortby": "score", + "sort_ascending": true, + "alignment_method": "sequence", + "lovoalign_exec": "", + "clt_threshold": 4 + } + } + const result = getWeightsFromConfig(config) + const expected = { + w_elec: 0.2, + w_vdw: 1, + w_desolv: 1, + w_bsa: 0, + w_air: 0, + } + expect(result).toEqual(expected) + }) +}) \ No newline at end of file diff --git a/app/models/job.server.ts b/app/models/job.server.ts index 4843e523..1b734b5e 100644 --- a/app/models/job.server.ts +++ b/app/models/job.server.ts @@ -3,6 +3,7 @@ import { JobApi } from "~/bartender-client/apis/JobApi"; import { buildConfig } from "./config.server"; import { JOB_OUTPUT_DIR } from "./constants"; import { ResponseError } from "~/bartender-client"; +import { object, number, Output } from "valibot"; const BOOK_KEEPING_FILES = [ "stderr.txt", @@ -150,3 +151,73 @@ export async function getSubDirectoryAsArchive( return response.raw; }); } + +export const WeightsSchema = object( + { + w_elec: number(), + w_vdw: number(), + w_desolv: number(), + w_bsa: number(), + w_air: number(), + } +); +export type Weights = Output; + +async function getConfig(jobid: number, bartenderToken: string) { + const path = 'output/data/configurations/enhanced_haddock_params.json' + const response = await getJobfile(jobid, path, bartenderToken); + const body = await response.json() + return body +} + +export function getWeightsFromConfig(config: any): Weights { + // Find last module with weights + const keys = Object.keys(config).reverse() + for (const key of keys) { + const module = config[key] + if ('w_elec' in module) { + return { + w_elec: module.w_elec, + w_vdw: module.w_vdw, + w_desolv: module.w_desolv, + w_bsa: module.w_bsa, + w_air: module.w_air, + } + } + } + throw new Error('No weights found in config') +} + +export async function getWeights(jobid: number, bartenderToken: string): Promise { + // TODO check if rescore has been run and return those weights + const config = await getConfig(jobid, bartenderToken) + return getWeightsFromConfig(config) +} + +export async function step2rescoreModule(jobid: number, bartenderToken: string): Promise { + return -1 +} + +export async function getScores(jobid: number, module: number, bartenderToken: string) { + const files = await listOutputFiles(jobid, bartenderToken); + +} + +export async function rescore(jobid: number, module: number, weights: Weights, bartenderToken: string) { + const body = { + module, + ...weights + } + const result = await safeApi(bartenderToken, async (api) => { + const response = await api.runInteractiveApp({ + jobid, + application: "rescore", + body, + }); + return response; + }); + if (result.returncode !== 0) { + throw new Error(`rescore failed with return code ${result.returncode}`); + } + return await getScores(jobid, module, bartenderToken); +} \ No newline at end of file diff --git a/app/routes/jobs.$id.rescore.tsx b/app/routes/jobs.$id.rescore.tsx new file mode 100644 index 00000000..da8c5a20 --- /dev/null +++ b/app/routes/jobs.$id.rescore.tsx @@ -0,0 +1,72 @@ +import type { LoaderArgs} from "@remix-run/node"; +import { json } from "@remix-run/node"; +import { Form, useLoaderData } from "@remix-run/react"; +import { safeParse } from "valibot"; +import { getBartenderToken } from "~/bartender_token.server"; +import { jobIdFromParams, getJobById, getWeights, WeightsSchema, getScores, step2rescoreModule, rescore } from "~/models/job.server"; +import { CompletedJobs } from "~/utils"; + + +export const loader = async ({ params, request }: LoaderArgs) => { + const jobId = jobIdFromParams(params); + const token = await getBartenderToken(request); + const job = await getJobById(jobId, token); + if (!CompletedJobs.has(job.state)) { + throw new Error("Job is not completed"); + } + const module = await step2rescoreModule(jobId, token); + const weights = await getWeights(jobId, token); + const scores = await getScores(jobId, module, token); + return json({ weights, scores }); +} + +export const action = async ({ request, params }: LoaderArgs) => { + const token = await getBartenderToken(request); + const jobId = jobIdFromParams(params); + const formData = await request.formData(); + const result = safeParse(WeightsSchema, Object.fromEntries(formData)); + if (!result.success) { + throw json({ error: "Invalid weights" }, { status: 400 }); + } + const weights = result.data; + const module = await step2rescoreModule(jobId, token); + const scores = await rescore(jobId, module, weights, token); + return json({ weights, scores }); +} + + +export default function RescorePage() { + const { weights, scores } = useLoaderData(); + + return ( + <> +
+            {JSON.stringify(scores, null, 2)}
+        
+
+

Rescore

+ + + + + + +
+ + ) +} \ No newline at end of file From 39436911a5e6d5dd069a8f2c9a41692375abf3eb Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Wed, 6 Sep 2023 12:08:22 +0200 Subject: [PATCH 003/116] Run format on generated code --- app/bartender-client/apis/ApplicationApi.ts | 310 ++-- app/bartender-client/apis/DefaultApi.ts | 70 +- app/bartender-client/apis/JobApi.ts | 1533 ++++++++++------- app/bartender-client/apis/UserApi.ts | 91 +- app/bartender-client/apis/index.ts | 8 +- app/bartender-client/index.ts | 6 +- .../models/ApplicatonConfiguration.ts | 114 +- app/bartender-client/models/DirectoryItem.ts | 137 +- .../models/HTTPValidationError.ts | 81 +- .../models/InteractiveAppResult.ts | 104 +- .../InteractiveApplicationConfiguration.ts | 140 +- app/bartender-client/models/JobModelDTO.ts | 171 +- app/bartender-client/models/LocationInner.ts | 25 +- app/bartender-client/models/User.ts | 96 +- .../models/ValidationError.ts | 110 +- app/bartender-client/models/index.ts | 18 +- app/bartender-client/runtime.ts | 645 ++++--- 17 files changed, 2065 insertions(+), 1594 deletions(-) diff --git a/app/bartender-client/apis/ApplicationApi.ts b/app/bartender-client/apis/ApplicationApi.ts index de7a33f6..57ac5b59 100644 --- a/app/bartender-client/apis/ApplicationApi.ts +++ b/app/bartender-client/apis/ApplicationApi.ts @@ -5,166 +5,214 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -import * as runtime from '../runtime'; -import type { - ApplicatonConfiguration, - HTTPValidationError, -} from '../models'; +import * as runtime from "../runtime"; +import type { ApplicatonConfiguration, HTTPValidationError } from "../models"; import { - ApplicatonConfigurationFromJSON, - ApplicatonConfigurationToJSON, - HTTPValidationErrorFromJSON, - HTTPValidationErrorToJSON, -} from '../models'; + ApplicatonConfigurationFromJSON, + ApplicatonConfigurationToJSON, + HTTPValidationErrorFromJSON, + HTTPValidationErrorToJSON, +} from "../models"; export interface GetApplicationRequest { - application: string; + application: string; } export interface UploadJobRequest { - application: string; - upload: Blob; + application: string; + upload: Blob; } /** - * + * */ export class ApplicationApi extends runtime.BaseAPI { - - /** - * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. - * Get Application - */ - async getApplicationRaw(requestParameters: GetApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.application === null || requestParameters.application === undefined) { - throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling getApplication.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/api/application/{application}`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => ApplicatonConfigurationFromJSON(jsonValue)); + /** + * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. + * Get Application + */ + async getApplicationRaw( + requestParameters: GetApplicationRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.application === null || + requestParameters.application === undefined + ) { + throw new runtime.RequiredError( + "application", + "Required parameter requestParameters.application was null or undefined when calling getApplication." + ); } - /** - * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. - * Get Application - */ - async getApplication(requestParameters: GetApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getApplicationRaw(requestParameters, initOverrides); - return await response.value(); + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request( + { + path: `/api/application/{application}`.replace( + `{${"application"}}`, + encodeURIComponent(String(requestParameters.application)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + ApplicatonConfigurationFromJSON(jsonValue) + ); + } + + /** + * Retrieve application configuration. Args: application: Name of application config: Config with applications. Returns: The application config. + * Get Application + */ + async getApplication( + requestParameters: GetApplicationRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.getApplicationRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * List application names. Args: config: Config with applications. Returns: The list. + * List Applications + */ + async listApplicationsRaw( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise>> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request( + { + path: `/api/application/`, + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response); + } + + /** + * List application names. Args: config: Config with applications. Returns: The list. + * List Applications + */ + async listApplications( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const response = await this.listApplicationsRaw(initOverrides); + return await response.value(); + } + + /** + * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. + * Upload Job + */ + async uploadJobRaw( + requestParameters: UploadJobRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.application === null || + requestParameters.application === undefined + ) { + throw new runtime.RequiredError( + "application", + "Required parameter requestParameters.application was null or undefined when calling uploadJob." + ); } - /** - * List application names. Args: config: Config with applications. Returns: The list. - * List Applications - */ - async listApplicationsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; + if ( + requestParameters.upload === null || + requestParameters.upload === undefined + ) { + throw new runtime.RequiredError( + "upload", + "Required parameter requestParameters.upload was null or undefined when calling uploadJob." + ); + } - const headerParameters: runtime.HTTPHeaders = {}; + const queryParameters: any = {}; - const response = await this.request({ - path: `/api/application/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); + const headerParameters: runtime.HTTPHeaders = {}; - return new runtime.JSONApiResponse(response); + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication } - /** - * List application names. Args: config: Config with applications. Returns: The list. - * List Applications - */ - async listApplications(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.listApplicationsRaw(initOverrides); - return await response.value(); - } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); - /** - * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. - * Upload Job - */ - async uploadJobRaw(requestParameters: UploadJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.application === null || requestParameters.application === undefined) { - throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling uploadJob.'); - } - - if (requestParameters.upload === null || requestParameters.upload === undefined) { - throw new runtime.RequiredError('upload','Required parameter requestParameters.upload was null or undefined when calling uploadJob.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const consumes: runtime.Consume[] = [ - { contentType: 'multipart/form-data' }, - ]; - // @ts-ignore: canConsumeForm may be unused - const canConsumeForm = runtime.canConsumeForm(consumes); - - let formParams: { append(param: string, value: any): any }; - let useForm = false; - // use FormData to transmit files using content-type "multipart/form-data" - useForm = canConsumeForm; - if (useForm) { - formParams = new FormData(); - } else { - formParams = new URLSearchParams(); - } - - if (requestParameters.upload !== undefined) { - formParams.append('upload', requestParameters.upload as any); - } - - const response = await this.request({ - path: `/api/application/{application}/job`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: formParams, - }, initOverrides); - - return new runtime.VoidApiResponse(response); + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const consumes: runtime.Consume[] = [ + { contentType: "multipart/form-data" }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + // use FormData to transmit files using content-type "multipart/form-data" + useForm = canConsumeForm; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); } - /** - * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. - * Upload Job - */ - async uploadJob(requestParameters: UploadJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.uploadJobRaw(requestParameters, initOverrides); + if (requestParameters.upload !== undefined) { + formParams.append("upload", requestParameters.upload as any); } + const response = await this.request( + { + path: `/api/application/{application}/job`.replace( + `{${"application"}}`, + encodeURIComponent(String(requestParameters.application)) + ), + method: "PUT", + headers: headerParameters, + query: queryParameters, + body: formParams, + }, + initOverrides + ); + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates job model in the database, stage archive locally and submit to scheduler. Args: application: Name of application to run job for. upload: Archive with config file for application. request: request object. job_dao: JobDAO object. submitter: User who submitted job. context: Context with applications and destinations. Raises: IndexError: When job could not created inside database or when config file was not found. KeyError: Application is invalid. Returns: redirect response. + * Upload Job + */ + async uploadJob( + requestParameters: UploadJobRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + await this.uploadJobRaw(requestParameters, initOverrides); + } } diff --git a/app/bartender-client/apis/DefaultApi.ts b/app/bartender-client/apis/DefaultApi.ts index 365dfce9..3b3dc3c9 100644 --- a/app/bartender-client/apis/DefaultApi.ts +++ b/app/bartender-client/apis/DefaultApi.ts @@ -5,47 +5,51 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -import * as runtime from '../runtime'; +import * as runtime from "../runtime"; /** - * + * */ export class DefaultApi extends runtime.BaseAPI { - - /** - * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. - * Health Check - */ - async healthCheckRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/api/health`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. - * Health Check - */ - async healthCheck(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.healthCheckRaw(initOverrides); - return await response.value(); - } - + /** + * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. + * Health Check + */ + async healthCheckRaw( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request( + { + path: `/api/health`, + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Checks the health of a project. It returns 200 if the project is healthy. Args: session: SQLAlchemy session. + * Health Check + */ + async healthCheck( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.healthCheckRaw(initOverrides); + return await response.value(); + } } diff --git a/app/bartender-client/apis/JobApi.ts b/app/bartender-client/apis/JobApi.ts index 5af57619..05858244 100644 --- a/app/bartender-client/apis/JobApi.ts +++ b/app/bartender-client/apis/JobApi.ts @@ -5,687 +5,996 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -import * as runtime from '../runtime'; +import * as runtime from "../runtime"; import type { DirectoryItem, HTTPValidationError, InteractiveAppResult, InteractiveApplicationConfiguration, JobModelDTO, -} from '../models'; +} from "../models"; import { - DirectoryItemFromJSON, - DirectoryItemToJSON, - HTTPValidationErrorFromJSON, - HTTPValidationErrorToJSON, - InteractiveAppResultFromJSON, - InteractiveAppResultToJSON, - InteractiveApplicationConfigurationFromJSON, - InteractiveApplicationConfigurationToJSON, - JobModelDTOFromJSON, - JobModelDTOToJSON, -} from '../models'; + DirectoryItemFromJSON, + DirectoryItemToJSON, + HTTPValidationErrorFromJSON, + HTTPValidationErrorToJSON, + InteractiveAppResultFromJSON, + InteractiveAppResultToJSON, + InteractiveApplicationConfigurationFromJSON, + InteractiveApplicationConfigurationToJSON, + JobModelDTOFromJSON, + JobModelDTOToJSON, +} from "../models"; export interface GetInteractiveAppRequest { - application: string; - jobid: number; + application: string; + jobid: number; } export interface ListInteractiveAppsRequest { - jobid: number; + jobid: number; } export interface RetrieveJobRequest { - jobid: number; + jobid: number; } export interface RetrieveJobDirectoriesRequest { - jobid: number; - maxDepth?: number; + jobid: number; + maxDepth?: number; } export interface RetrieveJobDirectoriesFromPathRequest { - path: string; - jobid: number; - maxDepth?: number; + path: string; + jobid: number; + maxDepth?: number; } export interface RetrieveJobDirectoryAsArchiveRequest { - jobid: number; - archiveFormat?: RetrieveJobDirectoryAsArchiveArchiveFormatEnum; - exclude?: Array; - excludeDirs?: Array; + jobid: number; + archiveFormat?: RetrieveJobDirectoryAsArchiveArchiveFormatEnum; + exclude?: Array; + excludeDirs?: Array; } export interface RetrieveJobFilesRequest { - path: string; - jobid: number; + path: string; + jobid: number; } export interface RetrieveJobStderrRequest { - jobid: number; + jobid: number; } export interface RetrieveJobStdoutRequest { - jobid: number; + jobid: number; } export interface RetrieveJobSubdirectoryAsArchiveRequest { - path: string; - jobid: number; - archiveFormat?: RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum; - exclude?: Array; - excludeDirs?: Array; + path: string; + jobid: number; + archiveFormat?: RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum; + exclude?: Array; + excludeDirs?: Array; } export interface RetrieveJobsRequest { - limit?: number; - offset?: number; + limit?: number; + offset?: number; } export interface RunInteractiveAppRequest { - jobid: number; - application: string; - body?: object; + jobid: number; + application: string; + body?: object; } /** - * + * */ export class JobApi extends runtime.BaseAPI { + /** + * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. + * Get Interactive App + */ + async getInteractiveAppRaw( + requestParameters: GetInteractiveAppRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.application === null || + requestParameters.application === undefined + ) { + throw new runtime.RequiredError( + "application", + "Required parameter requestParameters.application was null or undefined when calling getInteractiveApp." + ); + } + + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling getInteractiveApp." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request( + { + path: `/api/job/{jobid}/interactive/{application}` + .replace( + `{${"application"}}`, + encodeURIComponent(String(requestParameters.application)) + ) + .replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + InteractiveApplicationConfigurationFromJSON(jsonValue) + ); + } + + /** + * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. + * Get Interactive App + */ + async getInteractiveApp( + requestParameters: GetInteractiveAppRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.getInteractiveAppRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. + * List Interactive Apps + */ + async listInteractiveAppsRaw( + requestParameters: ListInteractiveAppsRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise>> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling listInteractiveApps." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request( + { + path: `/api/job/{jobid}/interactive`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response); + } + + /** + * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. + * List Interactive Apps + */ + async listInteractiveApps( + requestParameters: ListInteractiveAppsRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const response = await this.listInteractiveAppsRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. + * Retrieve Job + */ + async retrieveJobRaw( + requestParameters: RetrieveJobRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJob." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + JobModelDTOFromJSON(jsonValue) + ); + } + + /** + * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. + * Retrieve Job + */ + async retrieveJob( + requestParameters: RetrieveJobRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories + */ + async retrieveJobDirectoriesRaw( + requestParameters: RetrieveJobDirectoriesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectories." + ); + } + + const queryParameters: any = {}; + + if (requestParameters.maxDepth !== undefined) { + queryParameters["max_depth"] = requestParameters.maxDepth; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/directories`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + DirectoryItemFromJSON(jsonValue) + ); + } + + /** + * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories + */ + async retrieveJobDirectories( + requestParameters: RetrieveJobDirectoriesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobDirectoriesRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories From Path + */ + async retrieveJobDirectoriesFromPathRaw( + requestParameters: RetrieveJobDirectoriesFromPathRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.path === null || + requestParameters.path === undefined + ) { + throw new runtime.RequiredError( + "path", + "Required parameter requestParameters.path was null or undefined when calling retrieveJobDirectoriesFromPath." + ); + } + + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoriesFromPath." + ); + } + + const queryParameters: any = {}; + + if (requestParameters.maxDepth !== undefined) { + queryParameters["max_depth"] = requestParameters.maxDepth; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/directories/{path}` + .replace( + `{${"path"}}`, + encodeURIComponent(String(requestParameters.path)) + ) + .replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + DirectoryItemFromJSON(jsonValue) + ); + } + + /** + * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. + * Retrieve Job Directories From Path + */ + async retrieveJobDirectoriesFromPath( + requestParameters: RetrieveJobDirectoriesFromPathRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobDirectoriesFromPathRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir + * Retrieve Job Directory As Archive + */ + async retrieveJobDirectoryAsArchiveRaw( + requestParameters: RetrieveJobDirectoryAsArchiveRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoryAsArchive." + ); + } + + const queryParameters: any = {}; + + if (requestParameters.archiveFormat !== undefined) { + queryParameters["archive_format"] = requestParameters.archiveFormat; + } + + if (requestParameters.exclude) { + queryParameters["exclude"] = requestParameters.exclude; + } + + if (requestParameters.excludeDirs) { + queryParameters["exclude_dirs"] = requestParameters.excludeDirs; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/archive`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir + * Retrieve Job Directory As Archive + */ + async retrieveJobDirectoryAsArchive( + requestParameters: RetrieveJobDirectoryAsArchiveRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobDirectoryAsArchiveRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. + * Retrieve Job Files + */ + async retrieveJobFilesRaw( + requestParameters: RetrieveJobFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.path === null || + requestParameters.path === undefined + ) { + throw new runtime.RequiredError( + "path", + "Required parameter requestParameters.path was null or undefined when calling retrieveJobFiles." + ); + } - /** - * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. - * Get Interactive App - */ - async getInteractiveAppRaw(requestParameters: GetInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.application === null || requestParameters.application === undefined) { - throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling getInteractiveApp.'); - } - - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling getInteractiveApp.'); - } + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobFiles." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/files/{path}` + .replace( + `{${"path"}}`, + encodeURIComponent(String(requestParameters.path)) + ) + .replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. + * Retrieve Job Files + */ + async retrieveJobFiles( + requestParameters: RetrieveJobFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobFilesRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. + * Retrieve Job Stderr + */ + async retrieveJobStderrRaw( + requestParameters: RetrieveJobStderrRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStderr." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/stderr`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. + * Retrieve Job Stderr + */ + async retrieveJobStderr( + requestParameters: RetrieveJobStderrRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobStderrRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. + * Retrieve Job Stdout + */ + async retrieveJobStdoutRaw( + requestParameters: RetrieveJobStdoutRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStdout." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/stdout`.replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. + * Retrieve Job Stdout + */ + async retrieveJobStdout( + requestParameters: RetrieveJobStdoutRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobStdoutRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir + * Retrieve Job Subdirectory As Archive + */ + async retrieveJobSubdirectoryAsArchiveRaw( + requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.path === null || + requestParameters.path === undefined + ) { + throw new runtime.RequiredError( + "path", + "Required parameter requestParameters.path was null or undefined when calling retrieveJobSubdirectoryAsArchive." + ); + } + + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling retrieveJobSubdirectoryAsArchive." + ); + } - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/api/job/{jobid}/interactive/{application}`.replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => InteractiveApplicationConfigurationFromJSON(jsonValue)); - } - - /** - * Get interactive app configuration. Args: application: The interactive application. config: The bartender configuration. Returns: The interactive application configuration. - * Get Interactive App - */ - async getInteractiveApp(requestParameters: GetInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getInteractiveAppRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. - * List Interactive Apps - */ - async listInteractiveAppsRaw(requestParameters: ListInteractiveAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling listInteractiveApps.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/api/job/{jobid}/interactive`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response); - } - - /** - * List interactive apps that can be run on a completed job. Args: config: The bartender configuration. Returns: List of interactive apps. - * List Interactive Apps - */ - async listInteractiveApps(requestParameters: ListInteractiveAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.listInteractiveAppsRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. - * Retrieve Job - */ - async retrieveJobRaw(requestParameters: RetrieveJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJob.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => JobModelDTOFromJSON(jsonValue)); - } - - /** - * Retrieve specific job from the database. Args: jobid: identifier of job instance. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Raises: HTTPException: When job is not found or user is not allowed to see job. Returns: job models. - * Retrieve Job - */ - async retrieveJob(requestParameters: RetrieveJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories - */ - async retrieveJobDirectoriesRaw(requestParameters: RetrieveJobDirectoriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectories.'); - } - - const queryParameters: any = {}; - - if (requestParameters.maxDepth !== undefined) { - queryParameters['max_depth'] = requestParameters.maxDepth; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/directories`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => DirectoryItemFromJSON(jsonValue)); - } - - /** - * List directory contents of a job. Args: max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories - */ - async retrieveJobDirectories(requestParameters: RetrieveJobDirectoriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobDirectoriesRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories From Path - */ - async retrieveJobDirectoriesFromPathRaw(requestParameters: RetrieveJobDirectoriesFromPathRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.path === null || requestParameters.path === undefined) { - throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobDirectoriesFromPath.'); - } - - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoriesFromPath.'); - } - - const queryParameters: any = {}; - - if (requestParameters.maxDepth !== undefined) { - queryParameters['max_depth'] = requestParameters.maxDepth; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/directories/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => DirectoryItemFromJSON(jsonValue)); - } - - /** - * List directory contents of a job. Args: path: Sub directory inside job directory to start from. max_depth: Number of directories to traverse into. job_dir: The job directory. Returns: DirectoryItem: Listing of files and directories. - * Retrieve Job Directories From Path - */ - async retrieveJobDirectoriesFromPath(requestParameters: RetrieveJobDirectoriesFromPathRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobDirectoriesFromPathRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir - * Retrieve Job Directory As Archive - */ - async retrieveJobDirectoryAsArchiveRaw(requestParameters: RetrieveJobDirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobDirectoryAsArchive.'); - } - - const queryParameters: any = {}; - - if (requestParameters.archiveFormat !== undefined) { - queryParameters['archive_format'] = requestParameters.archiveFormat; - } - - if (requestParameters.exclude) { - queryParameters['exclude'] = requestParameters.exclude; - } - - if (requestParameters.excludeDirs) { - queryParameters['exclude_dirs'] = requestParameters.excludeDirs; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/archive`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Download contents of job directory as archive. Args: job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the content of job_dir - * Retrieve Job Directory As Archive - */ - async retrieveJobDirectoryAsArchive(requestParameters: RetrieveJobDirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobDirectoryAsArchiveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. - * Retrieve Job Files - */ - async retrieveJobFilesRaw(requestParameters: RetrieveJobFilesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.path === null || requestParameters.path === undefined) { - throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobFiles.'); - } - - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobFiles.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/files/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Retrieve files from a completed job. Args: path: Path to file that job has produced. job_dir: Directory with job output files. Raises: HTTPException: When file is not found or is outside job directory. Returns: The file content. - * Retrieve Job Files - */ - async retrieveJobFiles(requestParameters: RetrieveJobFilesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobFilesRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. - * Retrieve Job Stderr - */ - async retrieveJobStderrRaw(requestParameters: RetrieveJobStderrRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStderr.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/stderr`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Retrieve the jobs standard error. Args: logs: The standard output and error of a completed job. Returns: Content of standard error. - * Retrieve Job Stderr - */ - async retrieveJobStderr(requestParameters: RetrieveJobStderrRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobStderrRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. - * Retrieve Job Stdout - */ - async retrieveJobStdoutRaw(requestParameters: RetrieveJobStdoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobStdout.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/stdout`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Retrieve the jobs standard output. Args: logs: The standard output and error of a completed job. Returns: Content of standard output. - * Retrieve Job Stdout - */ - async retrieveJobStdout(requestParameters: RetrieveJobStdoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobStdoutRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir - * Retrieve Job Subdirectory As Archive - */ - async retrieveJobSubdirectoryAsArchiveRaw(requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.path === null || requestParameters.path === undefined) { - throw new runtime.RequiredError('path','Required parameter requestParameters.path was null or undefined when calling retrieveJobSubdirectoryAsArchive.'); - } - - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling retrieveJobSubdirectoryAsArchive.'); - } - - const queryParameters: any = {}; - - if (requestParameters.archiveFormat !== undefined) { - queryParameters['archive_format'] = requestParameters.archiveFormat; - } - - if (requestParameters.exclude) { - queryParameters['exclude'] = requestParameters.exclude; - } - - if (requestParameters.excludeDirs) { - queryParameters['exclude_dirs'] = requestParameters.excludeDirs; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/archive/{path}`.replace(`{${"path"}}`, encodeURIComponent(String(requestParameters.path))).replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.TextApiResponse(response) as any; - } - - /** - * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir - * Retrieve Job Subdirectory As Archive - */ - async retrieveJobSubdirectoryAsArchive(requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.retrieveJobSubdirectoryAsArchiveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. - * Retrieve Jobs - */ - async retrieveJobsRaw(requestParameters: RetrieveJobsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - if (requestParameters.limit !== undefined) { - queryParameters['limit'] = requestParameters.limit; - } - - if (requestParameters.offset !== undefined) { - queryParameters['offset'] = requestParameters.offset; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(JobModelDTOFromJSON)); - } - - /** - * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. - * Retrieve Jobs - */ - async retrieveJobs(requestParameters: RetrieveJobsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.retrieveJobsRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. - * Run Interactive App - */ - async runInteractiveAppRaw(requestParameters: RunInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.jobid === null || requestParameters.jobid === undefined) { - throw new runtime.RequiredError('jobid','Required parameter requestParameters.jobid was null or undefined when calling runInteractiveApp.'); - } - - if (requestParameters.application === null || requestParameters.application === undefined) { - throw new runtime.RequiredError('application','Required parameter requestParameters.application was null or undefined when calling runInteractiveApp.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/job/{jobid}/interactive/{application}`.replace(`{${"jobid"}}`, encodeURIComponent(String(requestParameters.jobid))).replace(`{${"application"}}`, encodeURIComponent(String(requestParameters.application))), - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + const queryParameters: any = {}; - return new runtime.JSONApiResponse(response, (jsonValue) => InteractiveAppResultFromJSON(jsonValue)); + if (requestParameters.archiveFormat !== undefined) { + queryParameters["archive_format"] = requestParameters.archiveFormat; } - /** - * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. - * Run Interactive App - */ - async runInteractiveApp(requestParameters: RunInteractiveAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.runInteractiveAppRaw(requestParameters, initOverrides); - return await response.value(); + if (requestParameters.exclude) { + queryParameters["exclude"] = requestParameters.exclude; } + if (requestParameters.excludeDirs) { + queryParameters["exclude_dirs"] = requestParameters.excludeDirs; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/archive/{path}` + .replace( + `{${"path"}}`, + encodeURIComponent(String(requestParameters.path)) + ) + .replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ), + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Download job output as archive. Args: path: Sub directory inside job directory to start from. job_dir: The job directory. background_tasks: FastAPI mechanism for post-processing tasks archive_format: Format to use for archive. Supported formats are \'.zip\', \'.tar\', \'.tar.xz\', \'.tar.gz\', \'.tar.bz2\' exclude: list of filename patterns that should be excluded from archive. exclude_dirs: list of directory patterns that should be excluded from archive. Returns: FileResponse: Archive containing the output of job_dir + * Retrieve Job Subdirectory As Archive + */ + async retrieveJobSubdirectoryAsArchive( + requestParameters: RetrieveJobSubdirectoryAsArchiveRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.retrieveJobSubdirectoryAsArchiveRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. + * Retrieve Jobs + */ + async retrieveJobsRaw( + requestParameters: RetrieveJobsRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise>> { + const queryParameters: any = {}; + + if (requestParameters.limit !== undefined) { + queryParameters["limit"] = requestParameters.limit; + } + + if (requestParameters.offset !== undefined) { + queryParameters["offset"] = requestParameters.offset; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/`, + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + jsonValue.map(JobModelDTOFromJSON) + ); + } + + /** + * Retrieve all jobs of user from the database. Args: limit: limit of jobs. offset: offset of jobs. job_dao: JobDAO object. user: Current active user. context: Context with destinations. file_staging_queue: When scheduler reports job is complete. The output files need to be copied back. Use queue to perform download outside request/response handling. Returns: stream of jobs. + * Retrieve Jobs + */ + async retrieveJobs( + requestParameters: RetrieveJobsRequest = {}, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const response = await this.retrieveJobsRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + + /** + * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. + * Run Interactive App + */ + async runInteractiveAppRaw( + requestParameters: RunInteractiveAppRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if ( + requestParameters.jobid === null || + requestParameters.jobid === undefined + ) { + throw new runtime.RequiredError( + "jobid", + "Required parameter requestParameters.jobid was null or undefined when calling runInteractiveApp." + ); + } + + if ( + requestParameters.application === null || + requestParameters.application === undefined + ) { + throw new runtime.RequiredError( + "application", + "Required parameter requestParameters.application was null or undefined when calling runInteractiveApp." + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters["Content-Type"] = "application/json"; + + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/api/job/{jobid}/interactive/{application}` + .replace( + `{${"jobid"}}`, + encodeURIComponent(String(requestParameters.jobid)) + ) + .replace( + `{${"application"}}`, + encodeURIComponent(String(requestParameters.application)) + ), + method: "POST", + headers: headerParameters, + query: queryParameters, + body: requestParameters.body as any, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + InteractiveAppResultFromJSON(jsonValue) + ); + } + + /** + * Run interactive app on a completed job. Args: request: The request. job_dir: The job directory. application: The interactive application. Returns: The result of running the interactive application. + * Run Interactive App + */ + async runInteractiveApp( + requestParameters: RunInteractiveAppRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.runInteractiveAppRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } } /** * @export */ export const RetrieveJobDirectoryAsArchiveArchiveFormatEnum = { - Zip: '.zip', - Tar: '.tar', - TarXz: '.tar.xz', - TarGz: '.tar.gz', - TarBz2: '.tar.bz2' + Zip: ".zip", + Tar: ".tar", + TarXz: ".tar.xz", + TarGz: ".tar.gz", + TarBz2: ".tar.bz2", } as const; -export type RetrieveJobDirectoryAsArchiveArchiveFormatEnum = typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum[keyof typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum]; +export type RetrieveJobDirectoryAsArchiveArchiveFormatEnum = + (typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum)[keyof typeof RetrieveJobDirectoryAsArchiveArchiveFormatEnum]; /** * @export */ export const RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = { - Zip: '.zip', - Tar: '.tar', - TarXz: '.tar.xz', - TarGz: '.tar.gz', - TarBz2: '.tar.bz2' + Zip: ".zip", + Tar: ".tar", + TarXz: ".tar.xz", + TarGz: ".tar.gz", + TarBz2: ".tar.bz2", } as const; -export type RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum[keyof typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum]; +export type RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum = + (typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum)[keyof typeof RetrieveJobSubdirectoryAsArchiveArchiveFormatEnum]; diff --git a/app/bartender-client/apis/UserApi.ts b/app/bartender-client/apis/UserApi.ts index 94626dda..307b5dab 100644 --- a/app/bartender-client/apis/UserApi.ts +++ b/app/bartender-client/apis/UserApi.ts @@ -5,66 +5,67 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -import * as runtime from '../runtime'; -import type { - User, -} from '../models'; -import { - UserFromJSON, - UserToJSON, -} from '../models'; +import * as runtime from "../runtime"; +import type { User } from "../models"; +import { UserFromJSON, UserToJSON } from "../models"; /** - * + * */ export class UserApi extends runtime.BaseAPI { + /** + * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. + * Whoami + */ + async whoamiRaw( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const queryParameters: any = {}; - /** - * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. - * Whoami - */ - async whoamiRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; + const headerParameters: runtime.HTTPHeaders = {}; - if (this.configuration && this.configuration.apiKey) { - queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication - } - - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("HTTPBearer", []); + if (this.configuration && this.configuration.apiKey) { + queryParameters["token"] = this.configuration.apiKey("token"); // APIKeyQuery authentication + } - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/api/whoami`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("HTTPBearer", []); - return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } } + const response = await this.request( + { + path: `/api/whoami`, + method: "GET", + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); - /** - * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. - * Whoami - */ - async whoami(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.whoamiRaw(initOverrides); - return await response.value(); - } + return new runtime.JSONApiResponse(response, (jsonValue) => + UserFromJSON(jsonValue) + ); + } + /** + * Get current user based on API key. Args: user: Current user. Returns: Current logged in user. + * Whoami + */ + async whoami( + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.whoamiRaw(initOverrides); + return await response.value(); + } } diff --git a/app/bartender-client/apis/index.ts b/app/bartender-client/apis/index.ts index 77cd312e..e3ef3240 100644 --- a/app/bartender-client/apis/index.ts +++ b/app/bartender-client/apis/index.ts @@ -1,6 +1,6 @@ /* tslint:disable */ /* eslint-disable */ -export * from './ApplicationApi'; -export * from './DefaultApi'; -export * from './JobApi'; -export * from './UserApi'; +export * from "./ApplicationApi"; +export * from "./DefaultApi"; +export * from "./JobApi"; +export * from "./UserApi"; diff --git a/app/bartender-client/index.ts b/app/bartender-client/index.ts index be9d1ede..749c57fa 100644 --- a/app/bartender-client/index.ts +++ b/app/bartender-client/index.ts @@ -1,5 +1,5 @@ /* tslint:disable */ /* eslint-disable */ -export * from './runtime'; -export * from './apis'; -export * from './models'; +export * from "./runtime"; +export * from "./apis"; +export * from "./models"; diff --git a/app/bartender-client/models/ApplicatonConfiguration.ts b/app/bartender-client/models/ApplicatonConfiguration.ts index 32f3e64b..318cbcfe 100644 --- a/app/bartender-client/models/ApplicatonConfiguration.ts +++ b/app/bartender-client/models/ApplicatonConfiguration.ts @@ -5,89 +5,95 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * Command to run application. - * + * * `$config` in command string will be replaced with value of * ApplicatonConfiguration.config. - * + * * The config value must be a path relative to the job directory. - * + * * .. code-block:: yaml - * + * * command: wc $config * config: README.md * @export * @interface ApplicatonConfiguration */ export interface ApplicatonConfiguration { - /** - * - * @type {string} - * @memberof ApplicatonConfiguration - */ - command: string; - /** - * - * @type {string} - * @memberof ApplicatonConfiguration - */ - config: string; - /** - * - * @type {Array} - * @memberof ApplicatonConfiguration - */ - allowedRoles?: Array; + /** + * + * @type {string} + * @memberof ApplicatonConfiguration + */ + command: string; + /** + * + * @type {string} + * @memberof ApplicatonConfiguration + */ + config: string; + /** + * + * @type {Array} + * @memberof ApplicatonConfiguration + */ + allowedRoles?: Array; } /** * Check if a given object implements the ApplicatonConfiguration interface. */ export function instanceOfApplicatonConfiguration(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "command" in value; - isInstance = isInstance && "config" in value; + let isInstance = true; + isInstance = isInstance && "command" in value; + isInstance = isInstance && "config" in value; - return isInstance; + return isInstance; } -export function ApplicatonConfigurationFromJSON(json: any): ApplicatonConfiguration { - return ApplicatonConfigurationFromJSONTyped(json, false); +export function ApplicatonConfigurationFromJSON( + json: any +): ApplicatonConfiguration { + return ApplicatonConfigurationFromJSONTyped(json, false); } -export function ApplicatonConfigurationFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicatonConfiguration { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'command': json['command'], - 'config': json['config'], - 'allowedRoles': !exists(json, 'allowed_roles') ? undefined : json['allowed_roles'], - }; +export function ApplicatonConfigurationFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): ApplicatonConfiguration { + if (json === undefined || json === null) { + return json; + } + return { + command: json["command"], + config: json["config"], + allowedRoles: !exists(json, "allowed_roles") + ? undefined + : json["allowed_roles"], + }; } -export function ApplicatonConfigurationToJSON(value?: ApplicatonConfiguration | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'command': value.command, - 'config': value.config, - 'allowed_roles': value.allowedRoles, - }; +export function ApplicatonConfigurationToJSON( + value?: ApplicatonConfiguration | null +): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + command: value.command, + config: value.config, + allowed_roles: value.allowedRoles, + }; } - diff --git a/app/bartender-client/models/DirectoryItem.ts b/app/bartender-client/models/DirectoryItem.ts index e845d01d..39c38228 100644 --- a/app/bartender-client/models/DirectoryItem.ts +++ b/app/bartender-client/models/DirectoryItem.ts @@ -5,97 +5,102 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * An entry in a directory. * @export * @interface DirectoryItem */ export interface DirectoryItem { - /** - * - * @type {string} - * @memberof DirectoryItem - */ - name: string; - /** - * - * @type {string} - * @memberof DirectoryItem - */ - path: string; - /** - * - * @type {boolean} - * @memberof DirectoryItem - */ - isDir: boolean; - /** - * - * @type {boolean} - * @memberof DirectoryItem - */ - isFile: boolean; - /** - * - * @type {Array} - * @memberof DirectoryItem - */ - children?: Array; + /** + * + * @type {string} + * @memberof DirectoryItem + */ + name: string; + /** + * + * @type {string} + * @memberof DirectoryItem + */ + path: string; + /** + * + * @type {boolean} + * @memberof DirectoryItem + */ + isDir: boolean; + /** + * + * @type {boolean} + * @memberof DirectoryItem + */ + isFile: boolean; + /** + * + * @type {Array} + * @memberof DirectoryItem + */ + children?: Array; } /** * Check if a given object implements the DirectoryItem interface. */ export function instanceOfDirectoryItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "path" in value; - isInstance = isInstance && "isDir" in value; - isInstance = isInstance && "isFile" in value; + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "path" in value; + isInstance = isInstance && "isDir" in value; + isInstance = isInstance && "isFile" in value; - return isInstance; + return isInstance; } export function DirectoryItemFromJSON(json: any): DirectoryItem { - return DirectoryItemFromJSONTyped(json, false); + return DirectoryItemFromJSONTyped(json, false); } -export function DirectoryItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): DirectoryItem { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'name': json['name'], - 'path': json['path'], - 'isDir': json['is_dir'], - 'isFile': json['is_file'], - 'children': !exists(json, 'children') ? undefined : ((json['children'] as Array).map(DirectoryItemFromJSON)), - }; +export function DirectoryItemFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): DirectoryItem { + if (json === undefined || json === null) { + return json; + } + return { + name: json["name"], + path: json["path"], + isDir: json["is_dir"], + isFile: json["is_file"], + children: !exists(json, "children") + ? undefined + : (json["children"] as Array).map(DirectoryItemFromJSON), + }; } export function DirectoryItemToJSON(value?: DirectoryItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'name': value.name, - 'path': value.path, - 'is_dir': value.isDir, - 'is_file': value.isFile, - 'children': value.children === undefined ? undefined : ((value.children as Array).map(DirectoryItemToJSON)), - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + name: value.name, + path: value.path, + is_dir: value.isDir, + is_file: value.isFile, + children: + value.children === undefined + ? undefined + : (value.children as Array).map(DirectoryItemToJSON), + }; } - diff --git a/app/bartender-client/models/HTTPValidationError.ts b/app/bartender-client/models/HTTPValidationError.ts index ac281ea0..37e580da 100644 --- a/app/bartender-client/models/HTTPValidationError.ts +++ b/app/bartender-client/models/HTTPValidationError.ts @@ -5,68 +5,75 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; -import type { ValidationError } from './ValidationError'; +import { exists, mapValues } from "../runtime"; +import type { ValidationError } from "./ValidationError"; import { - ValidationErrorFromJSON, - ValidationErrorFromJSONTyped, - ValidationErrorToJSON, -} from './ValidationError'; + ValidationErrorFromJSON, + ValidationErrorFromJSONTyped, + ValidationErrorToJSON, +} from "./ValidationError"; /** - * + * * @export * @interface HTTPValidationError */ export interface HTTPValidationError { - /** - * - * @type {Array} - * @memberof HTTPValidationError - */ - detail?: Array; + /** + * + * @type {Array} + * @memberof HTTPValidationError + */ + detail?: Array; } /** * Check if a given object implements the HTTPValidationError interface. */ export function instanceOfHTTPValidationError(value: object): boolean { - let isInstance = true; + let isInstance = true; - return isInstance; + return isInstance; } export function HTTPValidationErrorFromJSON(json: any): HTTPValidationError { - return HTTPValidationErrorFromJSONTyped(json, false); + return HTTPValidationErrorFromJSONTyped(json, false); } -export function HTTPValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): HTTPValidationError { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'detail': !exists(json, 'detail') ? undefined : ((json['detail'] as Array).map(ValidationErrorFromJSON)), - }; +export function HTTPValidationErrorFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): HTTPValidationError { + if (json === undefined || json === null) { + return json; + } + return { + detail: !exists(json, "detail") + ? undefined + : (json["detail"] as Array).map(ValidationErrorFromJSON), + }; } -export function HTTPValidationErrorToJSON(value?: HTTPValidationError | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'detail': value.detail === undefined ? undefined : ((value.detail as Array).map(ValidationErrorToJSON)), - }; +export function HTTPValidationErrorToJSON( + value?: HTTPValidationError | null +): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + detail: + value.detail === undefined + ? undefined + : (value.detail as Array).map(ValidationErrorToJSON), + }; } - diff --git a/app/bartender-client/models/InteractiveAppResult.ts b/app/bartender-client/models/InteractiveAppResult.ts index 5f43f9b1..c2d91b6a 100644 --- a/app/bartender-client/models/InteractiveAppResult.ts +++ b/app/bartender-client/models/InteractiveAppResult.ts @@ -5,17 +5,17 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * Represents the result of running a InteractiveApp. - * + * * Attributes: * returncode: The return code of the InteractiveApp process. * stderr: The standard error output of the InteractiveApp process. @@ -24,66 +24,68 @@ import { exists, mapValues } from '../runtime'; * @interface InteractiveAppResult */ export interface InteractiveAppResult { - /** - * - * @type {number} - * @memberof InteractiveAppResult - */ - returncode: number; - /** - * - * @type {string} - * @memberof InteractiveAppResult - */ - stderr: string; - /** - * - * @type {string} - * @memberof InteractiveAppResult - */ - stdout: string; + /** + * + * @type {number} + * @memberof InteractiveAppResult + */ + returncode: number; + /** + * + * @type {string} + * @memberof InteractiveAppResult + */ + stderr: string; + /** + * + * @type {string} + * @memberof InteractiveAppResult + */ + stdout: string; } /** * Check if a given object implements the InteractiveAppResult interface. */ export function instanceOfInteractiveAppResult(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "returncode" in value; - isInstance = isInstance && "stderr" in value; - isInstance = isInstance && "stdout" in value; + let isInstance = true; + isInstance = isInstance && "returncode" in value; + isInstance = isInstance && "stderr" in value; + isInstance = isInstance && "stdout" in value; - return isInstance; + return isInstance; } export function InteractiveAppResultFromJSON(json: any): InteractiveAppResult { - return InteractiveAppResultFromJSONTyped(json, false); + return InteractiveAppResultFromJSONTyped(json, false); } -export function InteractiveAppResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): InteractiveAppResult { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'returncode': json['returncode'], - 'stderr': json['stderr'], - 'stdout': json['stdout'], - }; +export function InteractiveAppResultFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): InteractiveAppResult { + if (json === undefined || json === null) { + return json; + } + return { + returncode: json["returncode"], + stderr: json["stderr"], + stdout: json["stdout"], + }; } -export function InteractiveAppResultToJSON(value?: InteractiveAppResult | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'returncode': value.returncode, - 'stderr': value.stderr, - 'stdout': value.stdout, - }; +export function InteractiveAppResultToJSON( + value?: InteractiveAppResult | null +): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + returncode: value.returncode, + stderr: value.stderr, + stdout: value.stdout, + }; } - diff --git a/app/bartender-client/models/InteractiveApplicationConfiguration.ts b/app/bartender-client/models/InteractiveApplicationConfiguration.ts index 008d2b39..0b72667f 100644 --- a/app/bartender-client/models/InteractiveApplicationConfiguration.ts +++ b/app/bartender-client/models/InteractiveApplicationConfiguration.ts @@ -5,34 +5,34 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * Configuration for an interactive application. - * + * * Interactive apps that can be run on a completed job. - * + * * Interactive apps are small interactive calculations that * can be run within a request-response cycle (<30s). - * + * * A interactive app should - * + * * * be quick to run (<60s) * * produce very little output (stdout, stderr, files) * * in the job directory only write new files and overwrite its own files. * * not have any arguments that can leak information, * for example paths to files outside the job directory. - * + * * Example: - * + * * Given completed job 123 run interactive app rescore with: - * + * * ```python * response = client.post('/api/job/123/interactiveapp/rescore', json={ * 'module': 1, @@ -46,7 +46,7 @@ import { exists, mapValues } from '../runtime'; * # Find the results in the job directory somewhere * files = client.get('/api/job/123/files') * ``` - * + * * Attributes: * command: Shell command template to run in job directory. * Use Python string template syntax to substitute variables from request body. @@ -59,73 +59,79 @@ import { exists, mapValues } from '../runtime'; * @interface InteractiveApplicationConfiguration */ export interface InteractiveApplicationConfiguration { - /** - * - * @type {string} - * @memberof InteractiveApplicationConfiguration - */ - command: string; - /** - * - * @type {object} - * @memberof InteractiveApplicationConfiguration - */ - input: object; - /** - * - * @type {string} - * @memberof InteractiveApplicationConfiguration - */ - description?: string; - /** - * - * @type {number} - * @memberof InteractiveApplicationConfiguration - */ - timeout?: number; + /** + * + * @type {string} + * @memberof InteractiveApplicationConfiguration + */ + command: string; + /** + * + * @type {object} + * @memberof InteractiveApplicationConfiguration + */ + input: object; + /** + * + * @type {string} + * @memberof InteractiveApplicationConfiguration + */ + description?: string; + /** + * + * @type {number} + * @memberof InteractiveApplicationConfiguration + */ + timeout?: number; } /** * Check if a given object implements the InteractiveApplicationConfiguration interface. */ -export function instanceOfInteractiveApplicationConfiguration(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "command" in value; - isInstance = isInstance && "input" in value; +export function instanceOfInteractiveApplicationConfiguration( + value: object +): boolean { + let isInstance = true; + isInstance = isInstance && "command" in value; + isInstance = isInstance && "input" in value; - return isInstance; + return isInstance; } -export function InteractiveApplicationConfigurationFromJSON(json: any): InteractiveApplicationConfiguration { - return InteractiveApplicationConfigurationFromJSONTyped(json, false); +export function InteractiveApplicationConfigurationFromJSON( + json: any +): InteractiveApplicationConfiguration { + return InteractiveApplicationConfigurationFromJSONTyped(json, false); } -export function InteractiveApplicationConfigurationFromJSONTyped(json: any, ignoreDiscriminator: boolean): InteractiveApplicationConfiguration { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'command': json['command'], - 'input': json['input'], - 'description': !exists(json, 'description') ? undefined : json['description'], - 'timeout': !exists(json, 'timeout') ? undefined : json['timeout'], - }; +export function InteractiveApplicationConfigurationFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): InteractiveApplicationConfiguration { + if (json === undefined || json === null) { + return json; + } + return { + command: json["command"], + input: json["input"], + description: !exists(json, "description") ? undefined : json["description"], + timeout: !exists(json, "timeout") ? undefined : json["timeout"], + }; } -export function InteractiveApplicationConfigurationToJSON(value?: InteractiveApplicationConfiguration | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'command': value.command, - 'input': value.input, - 'description': value.description, - 'timeout': value.timeout, - }; +export function InteractiveApplicationConfigurationToJSON( + value?: InteractiveApplicationConfiguration | null +): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + command: value.command, + input: value.input, + description: value.description, + timeout: value.timeout, + }; } - diff --git a/app/bartender-client/models/JobModelDTO.ts b/app/bartender-client/models/JobModelDTO.ts index 7c4f8f58..065b647d 100644 --- a/app/bartender-client/models/JobModelDTO.ts +++ b/app/bartender-client/models/JobModelDTO.ts @@ -5,124 +5,123 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * DTO for job models. - * + * * It returned when accessing job models from the API. * @export * @interface JobModelDTO */ export interface JobModelDTO { - /** - * - * @type {number} - * @memberof JobModelDTO - */ - id: number; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - name: string; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - application: string; - /** - * - * @type {string} - * @memberof JobModelDTO - */ - state: JobModelDTOStateEnum; - /** - * - * @type {Date} - * @memberof JobModelDTO - */ - createdOn: Date; - /** - * - * @type {Date} - * @memberof JobModelDTO - */ - updatedOn: Date; + /** + * + * @type {number} + * @memberof JobModelDTO + */ + id: number; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + name: string; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + application: string; + /** + * + * @type {string} + * @memberof JobModelDTO + */ + state: JobModelDTOStateEnum; + /** + * + * @type {Date} + * @memberof JobModelDTO + */ + createdOn: Date; + /** + * + * @type {Date} + * @memberof JobModelDTO + */ + updatedOn: Date; } - /** * @export */ export const JobModelDTOStateEnum = { - New: 'new', - Queued: 'queued', - Running: 'running', - StagingOut: 'staging_out', - Ok: 'ok', - Error: 'error' + New: "new", + Queued: "queued", + Running: "running", + StagingOut: "staging_out", + Ok: "ok", + Error: "error", } as const; -export type JobModelDTOStateEnum = typeof JobModelDTOStateEnum[keyof typeof JobModelDTOStateEnum]; - +export type JobModelDTOStateEnum = + (typeof JobModelDTOStateEnum)[keyof typeof JobModelDTOStateEnum]; /** * Check if a given object implements the JobModelDTO interface. */ export function instanceOfJobModelDTO(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "application" in value; - isInstance = isInstance && "state" in value; - isInstance = isInstance && "createdOn" in value; - isInstance = isInstance && "updatedOn" in value; + let isInstance = true; + isInstance = isInstance && "id" in value; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "application" in value; + isInstance = isInstance && "state" in value; + isInstance = isInstance && "createdOn" in value; + isInstance = isInstance && "updatedOn" in value; - return isInstance; + return isInstance; } export function JobModelDTOFromJSON(json: any): JobModelDTO { - return JobModelDTOFromJSONTyped(json, false); + return JobModelDTOFromJSONTyped(json, false); } -export function JobModelDTOFromJSONTyped(json: any, ignoreDiscriminator: boolean): JobModelDTO { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'id': json['id'], - 'name': json['name'], - 'application': json['application'], - 'state': json['state'], - 'createdOn': (new Date(json['created_on'])), - 'updatedOn': (new Date(json['updated_on'])), - }; +export function JobModelDTOFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): JobModelDTO { + if (json === undefined || json === null) { + return json; + } + return { + id: json["id"], + name: json["name"], + application: json["application"], + state: json["state"], + createdOn: new Date(json["created_on"]), + updatedOn: new Date(json["updated_on"]), + }; } export function JobModelDTOToJSON(value?: JobModelDTO | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'id': value.id, - 'name': value.name, - 'application': value.application, - 'state': value.state, - 'created_on': (value.createdOn.toISOString()), - 'updated_on': (value.updatedOn.toISOString()), - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + id: value.id, + name: value.name, + application: value.application, + state: value.state, + created_on: value.createdOn.toISOString(), + updated_on: value.updatedOn.toISOString(), + }; } - diff --git a/app/bartender-client/models/LocationInner.ts b/app/bartender-client/models/LocationInner.ts index c044159c..1bc62f1b 100644 --- a/app/bartender-client/models/LocationInner.ts +++ b/app/bartender-client/models/LocationInner.ts @@ -5,40 +5,41 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** - * + * * @export * @interface LocationInner */ -export interface LocationInner { -} +export interface LocationInner {} /** * Check if a given object implements the LocationInner interface. */ export function instanceOfLocationInner(value: object): boolean { - let isInstance = true; + let isInstance = true; - return isInstance; + return isInstance; } export function LocationInnerFromJSON(json: any): LocationInner { - return LocationInnerFromJSONTyped(json, false); + return LocationInnerFromJSONTyped(json, false); } -export function LocationInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): LocationInner { - return json; +export function LocationInnerFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): LocationInner { + return json; } export function LocationInnerToJSON(value?: LocationInner | null): any { - return value; + return value; } - diff --git a/app/bartender-client/models/User.ts b/app/bartender-client/models/User.ts index 6b65dc17..1aae08c9 100644 --- a/app/bartender-client/models/User.ts +++ b/app/bartender-client/models/User.ts @@ -5,79 +5,79 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { exists, mapValues } from "../runtime"; /** * User model. * @export * @interface User */ export interface User { - /** - * - * @type {string} - * @memberof User - */ - username: string; - /** - * - * @type {Array} - * @memberof User - */ - roles?: Array; - /** - * - * @type {string} - * @memberof User - */ - apikey: string; + /** + * + * @type {string} + * @memberof User + */ + username: string; + /** + * + * @type {Array} + * @memberof User + */ + roles?: Array; + /** + * + * @type {string} + * @memberof User + */ + apikey: string; } /** * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "username" in value; - isInstance = isInstance && "apikey" in value; + let isInstance = true; + isInstance = isInstance && "username" in value; + isInstance = isInstance && "apikey" in value; - return isInstance; + return isInstance; } export function UserFromJSON(json: any): User { - return UserFromJSONTyped(json, false); + return UserFromJSONTyped(json, false); } -export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'username': json['username'], - 'roles': !exists(json, 'roles') ? undefined : json['roles'], - 'apikey': json['apikey'], - }; +export function UserFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): User { + if (json === undefined || json === null) { + return json; + } + return { + username: json["username"], + roles: !exists(json, "roles") ? undefined : json["roles"], + apikey: json["apikey"], + }; } export function UserToJSON(value?: User | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'username': value.username, - 'roles': value.roles, - 'apikey': value.apikey, - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + username: value.username, + roles: value.roles, + apikey: value.apikey, + }; } - diff --git a/app/bartender-client/models/ValidationError.ts b/app/bartender-client/models/ValidationError.ts index f2ccd93e..6ec249a7 100644 --- a/app/bartender-client/models/ValidationError.ts +++ b/app/bartender-client/models/ValidationError.ts @@ -5,87 +5,87 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; -import type { LocationInner } from './LocationInner'; +import { exists, mapValues } from "../runtime"; +import type { LocationInner } from "./LocationInner"; import { - LocationInnerFromJSON, - LocationInnerFromJSONTyped, - LocationInnerToJSON, -} from './LocationInner'; + LocationInnerFromJSON, + LocationInnerFromJSONTyped, + LocationInnerToJSON, +} from "./LocationInner"; /** - * + * * @export * @interface ValidationError */ export interface ValidationError { - /** - * - * @type {Array} - * @memberof ValidationError - */ - loc: Array; - /** - * - * @type {string} - * @memberof ValidationError - */ - msg: string; - /** - * - * @type {string} - * @memberof ValidationError - */ - type: string; + /** + * + * @type {Array} + * @memberof ValidationError + */ + loc: Array; + /** + * + * @type {string} + * @memberof ValidationError + */ + msg: string; + /** + * + * @type {string} + * @memberof ValidationError + */ + type: string; } /** * Check if a given object implements the ValidationError interface. */ export function instanceOfValidationError(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "loc" in value; - isInstance = isInstance && "msg" in value; - isInstance = isInstance && "type" in value; + let isInstance = true; + isInstance = isInstance && "loc" in value; + isInstance = isInstance && "msg" in value; + isInstance = isInstance && "type" in value; - return isInstance; + return isInstance; } export function ValidationErrorFromJSON(json: any): ValidationError { - return ValidationErrorFromJSONTyped(json, false); + return ValidationErrorFromJSONTyped(json, false); } -export function ValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ValidationError { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'loc': ((json['loc'] as Array).map(LocationInnerFromJSON)), - 'msg': json['msg'], - 'type': json['type'], - }; +export function ValidationErrorFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): ValidationError { + if (json === undefined || json === null) { + return json; + } + return { + loc: (json["loc"] as Array).map(LocationInnerFromJSON), + msg: json["msg"], + type: json["type"], + }; } export function ValidationErrorToJSON(value?: ValidationError | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'loc': ((value.loc as Array).map(LocationInnerToJSON)), - 'msg': value.msg, - 'type': value.type, - }; + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + loc: (value.loc as Array).map(LocationInnerToJSON), + msg: value.msg, + type: value.type, + }; } - diff --git a/app/bartender-client/models/index.ts b/app/bartender-client/models/index.ts index 6435368c..a5b46d35 100644 --- a/app/bartender-client/models/index.ts +++ b/app/bartender-client/models/index.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ -export * from './ApplicatonConfiguration'; -export * from './DirectoryItem'; -export * from './HTTPValidationError'; -export * from './InteractiveAppResult'; -export * from './InteractiveApplicationConfiguration'; -export * from './JobModelDTO'; -export * from './LocationInner'; -export * from './User'; -export * from './ValidationError'; +export * from "./ApplicatonConfiguration"; +export * from "./DirectoryItem"; +export * from "./HTTPValidationError"; +export * from "./InteractiveAppResult"; +export * from "./InteractiveApplicationConfiguration"; +export * from "./JobModelDTO"; +export * from "./LocationInner"; +export * from "./User"; +export * from "./ValidationError"; diff --git a/app/bartender-client/runtime.ts b/app/bartender-client/runtime.ts index b2e15098..cbb50d79 100644 --- a/app/bartender-client/runtime.ts +++ b/app/bartender-client/runtime.ts @@ -5,83 +5,91 @@ * Job middleware for i-VRESSE * * The version of the OpenAPI document: 0.2.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // override for fetch implementation - middleware?: Middleware[]; // middleware to apply before/after fetch requests - queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security - headers?: HTTPHeaders; //header params we want to use on every request - credentials?: RequestCredentials; //value for the credentials param we want to use on each request + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: + | string + | Promise + | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} - - set config(configuration: Configuration) { - this.configuration = configuration; - } - - get basePath(): string { - return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; - } - - get fetchApi(): FetchAPI | undefined { - return this.configuration.fetchApi; + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null + ? this.configuration.basePath + : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === "function" ? apiKey : () => apiKey; } - - get middleware(): Middleware[] { - return this.configuration.middleware || []; - } - - get queryParamsStringify(): (params: HTTPQuery) => string { - return this.configuration.queryParamsStringify || querystring; + return undefined; + } + + get accessToken(): + | ((name?: string, scopes?: string[]) => string | Promise) + | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === "function" + ? accessToken + : async () => accessToken; } + return undefined; + } - get username(): string | undefined { - return this.configuration.username; - } + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } - get password(): string | undefined { - return this.configuration.password; - } - - get apiKey(): ((name: string) => string) | undefined { - const apiKey = this.configuration.apiKey; - if (apiKey) { - return typeof apiKey === 'function' ? apiKey : () => apiKey; - } - return undefined; - } - - get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { - const accessToken = this.configuration.accessToken; - if (accessToken) { - return typeof accessToken === 'function' ? accessToken : async () => accessToken; - } - return undefined; - } - - get headers(): HTTPHeaders | undefined { - return this.configuration.headers; - } - - get credentials(): RequestCredentials | undefined { - return this.configuration.credentials; - } + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } } export const DefaultConfig = new Configuration(); @@ -90,232 +98,304 @@ export const DefaultConfig = new Configuration(); * This is the base class for all generated API classes. */ export class BaseAPI { - - private middleware: Middleware[]; - - constructor(protected configuration = DefaultConfig) { - this.middleware = configuration.middleware; + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware( + this: T, + ...preMiddlewares: Array + ) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware( + this: T, + ...postMiddlewares: Array + ) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request( + context: RequestOpts, + initOverrides?: RequestInit | InitOverrideFunction + ): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response && response.status >= 200 && response.status < 300) { + return response; } - - withMiddleware(this: T, ...middlewares: Middleware[]) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - - withPreMiddleware(this: T, ...preMiddlewares: Array) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); + throw new ResponseError(response, "Response returned an error code"); + } + + private async createFetchParams( + context: RequestOpts, + initOverrides?: RequestInit | InitOverrideFunction + ) { + let url = this.configuration.basePath + context.path; + if ( + context.query !== undefined && + Object.keys(context.query).length !== 0 + ) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += "?" + this.configuration.queryParamsStringify(context.query); } - withPostMiddleware(this: T, ...postMiddlewares: Array) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } + const headers = Object.assign( + {}, + this.configuration.headers, + context.headers + ); + Object.keys(headers).forEach((key) => + headers[key] === undefined ? delete headers[key] : {} + ); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; - protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { - const { url, init } = await this.createFetchParams(context, initOverrides); - const response = await this.fetchApi(url, init); - if (response && (response.status >= 200 && response.status < 300)) { - return response; - } - throw new ResponseError(response, 'Response returned an error code'); - } + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })), + }; - private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + this.configuration.queryParamsStringify(context.query); - } + const init: RequestInit = { + ...overriddenInit, + body: + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), + }; - const headers = Object.assign({}, this.configuration.headers, context.headers); - Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); - - const initOverrideFn = - typeof initOverrides === "function" - ? initOverrides - : async () => initOverrides; - - const initParams = { - method: context.method, - headers, - body: context.body, - credentials: this.configuration.credentials, - }; - - const overriddenInit: RequestInit = { - ...initParams, - ...(await initOverrideFn({ - init: initParams, - context, - })) - }; - - const init: RequestInit = { - ...overriddenInit, - body: - isFormData(overriddenInit.body) || - overriddenInit.body instanceof URLSearchParams || - isBlob(overriddenInit.body) - ? overriddenInit.body - : JSON.stringify(overriddenInit.body), - }; - - return { url, init }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = + (await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + })) || fetchParams; + } } - - private fetchApi = async (url: string, init: RequestInit) => { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = await middleware.pre({ - fetch: this.fetchApi, - ...fetchParams, - }) || fetchParams; - } - } - let response: Response | undefined = undefined; - try { - response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); - } catch (e) { - for (const middleware of this.middleware) { - if (middleware.onError) { - response = await middleware.onError({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - error: e, - response: response ? response.clone() : undefined, - }) || response; - } - } - if (response === undefined) { - if (e instanceof Error) { - throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); - } else { - throw e; - } - } + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)( + fetchParams.url, + fetchParams.init + ); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = + (await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + })) || response; } - for (const middleware of this.middleware) { - if (middleware.post) { - response = await middleware.post({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - response: response.clone(), - }) || response; - } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError( + e, + "The request failed and the interceptors did not return an alternative response" + ); + } else { + throw e; } - return response; + } } - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone(this: T): T { - const constructor = this.constructor as any; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; + for (const middleware of this.middleware) { + if (middleware.post) { + response = + (await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + })) || response; + } } -}; + return response; + }; + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +} function isBlob(value: any): value is Blob { - return typeof Blob !== 'undefined' && value instanceof Blob; + return typeof Blob !== "undefined" && value instanceof Blob; } function isFormData(value: any): value is FormData { - return typeof FormData !== "undefined" && value instanceof FormData; + return typeof FormData !== "undefined" && value instanceof FormData; } export class ResponseError extends Error { - override name: "ResponseError" = "ResponseError"; - constructor(public response: Response, msg?: string) { - super(msg); - } + override name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } } export class FetchError extends Error { - override name: "FetchError" = "FetchError"; - constructor(public cause: Error, msg?: string) { - super(msg); - } + override name: "FetchError" = "FetchError"; + constructor(public cause: Error, msg?: string) { + super(msg); + } } export class RequiredError extends Error { - override name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } + override name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } } export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", }; -export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; +export type FetchAPI = WindowOrWorkerGlobalScope["fetch"]; export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HTTPMethod = + | "GET" + | "POST" + | "PUT" + | "PATCH" + | "DELETE" + | "OPTIONS" + | "HEAD"; export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; +export type HTTPQuery = { + [key: string]: + | string + | number + | null + | boolean + | Array + | Set + | HTTPQuery; +}; export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; +export type HTTPRequestInit = { + headers?: HTTPHeaders; + method: HTTPMethod; + credentials?: RequestCredentials; + body?: HTTPBody; +}; +export type ModelPropertyNaming = + | "camelCase" + | "snake_case" + | "PascalCase" + | "original"; -export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise +export type InitOverrideFunction = (requestContext: { + init: HTTPRequestInit; + context: RequestOpts; +}) => Promise; export interface FetchParams { - url: string; - init: RequestInit; + url: string; + init: RequestInit; } export interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; } export function exists(json: any, key: string) { - const value = json[key]; - return value !== null && value !== undefined; + const value = json[key]; + return value !== null && value !== undefined; } -export function querystring(params: HTTPQuery, prefix: string = ''): string { - return Object.keys(params) - .map(key => querystringSingleKey(key, params[key], prefix)) - .filter(part => part.length > 0) - .join('&'); +export function querystring(params: HTTPQuery, prefix: string = ""): string { + return Object.keys(params) + .map((key) => querystringSingleKey(key, params[key], prefix)) + .filter((part) => part.length > 0) + .join("&"); } -function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { - const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); - if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) - .join(`&${encodeURIComponent(fullKey)}=`); - return `${encodeURIComponent(fullKey)}=${multiValue}`; - } - if (value instanceof Set) { - const valueAsArray = Array.from(value); - return querystringSingleKey(key, valueAsArray, keyPrefix); - } - if (value instanceof Date) { - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; - } - if (value instanceof Object) { - return querystring(value as HTTPQuery, fullKey); - } - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; +function querystringSingleKey( + key: string, + value: + | string + | number + | null + | undefined + | boolean + | Array + | Set + | HTTPQuery, + keyPrefix: string = "" +): string { + const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); + if (value instanceof Array) { + const multiValue = value + .map((singleValue) => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent( + value.toISOString() + )}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; } export function mapValues(data: any, fn: (item: any) => any) { @@ -326,82 +406,85 @@ export function mapValues(data: any, fn: (item: any) => any) { } export function canConsumeForm(consumes: Consume[]): boolean { - for (const consume of consumes) { - if ('multipart/form-data' === consume.contentType) { - return true; - } + for (const consume of consumes) { + if ("multipart/form-data" === consume.contentType) { + return true; } - return false; + } + return false; } export interface Consume { - contentType: string; + contentType: string; } export interface RequestContext { - fetch: FetchAPI; - url: string; - init: RequestInit; + fetch: FetchAPI; + url: string; + init: RequestInit; } export interface ResponseContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - response: Response; + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; } export interface ErrorContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - error: unknown; - response?: Response; + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; } export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; - onError?(context: ErrorContext): Promise; + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse { - raw: Response; - value(): Promise; + raw: Response; + value(): Promise; } export interface ResponseTransformer { - (json: any): T; + (json: any): T; } export class JSONApiResponse { - constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} - - async value(): Promise { - return this.transformer(await this.raw.json()); - } + constructor( + public raw: Response, + private transformer: ResponseTransformer = (jsonValue: any) => jsonValue + ) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } } export class VoidApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return undefined; - } + async value(): Promise { + return undefined; + } } export class BlobApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return await this.raw.blob(); - }; + async value(): Promise { + return await this.raw.blob(); + } } export class TextApiResponse { - constructor(public raw: Response) {} + constructor(public raw: Response) {} - async value(): Promise { - return await this.raw.text(); - }; + async value(): Promise { + return await this.raw.text(); + } } From 4d5d3fd690e45fd46e0009d140990afb3c782d46 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Wed, 6 Sep 2023 12:08:43 +0200 Subject: [PATCH 004/116] Rescore working, but ugly --- app/models/job.server.test.ts | 561 +++++++++++++++++++------------- app/models/job.server.ts | 151 +++++++-- app/routes/jobs.$id._index.tsx | 8 + app/routes/jobs.$id.rescore.tsx | 187 +++++++---- package-lock.json | 60 +++- package.json | 2 + 6 files changed, 653 insertions(+), 316 deletions(-) diff --git a/app/models/job.server.test.ts b/app/models/job.server.test.ts index 70042415..698a4ad3 100644 --- a/app/models/job.server.test.ts +++ b/app/models/job.server.test.ts @@ -1,224 +1,341 @@ import { describe, test, expect } from "vitest"; -import { getWeightsFromConfig } from "./job.server"; +import { getLastCaprievalModule, getWeightsFromConfig } from "./job.server"; +import type { DirectoryItem } from "~/bartender-client"; -describe('getWeightsFromConfig', () => { - test('should return the correct weights', () => { - // Pruned config of - // output/data/configurations/enhanced_haddock_params.json - // from run of docking-antibody-antigen-ranairCDR-clt-test.cfg example - const config = { - "cns_exec": "", - "ncores": 8, - "max_cpus": true, - "mode": "local", - "batch_type": "slurm", - "queue": "", - "queue_limit": 100, - "concat": 1, - "self_contained": false, - "clean": false, - "preprocess": false, - "postprocess": true, - "run_dir": "output", - "molecules": [ - "data/4G6K_fv.pdb", - "data/4I1B-matched.pdb" - ], - "topoaa.1": { - }, - "rigidbody.1": { - }, - "caprieval.1": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - }, - "clustfcc.1": { - "threshold": 4, - "executable": "src/contact_fcc", - "contact_distance_cutoff": 5.0, - "fraction_cutoff": 0.6, - "strictness": 0.75 - }, - "seletopclusts.1": { - "top_models": 10, - "top_cluster": 1000 - }, - "caprieval.2": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - }, - "flexref.1": { - }, - "caprieval.3": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - }, - "emref.1": { - }, - "caprieval.4": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - }, - "emscoring.1": { - }, - "clustfcc.2": { - "executable": "src/contact_fcc", - "contact_distance_cutoff": 5.0, - "fraction_cutoff": 0.6, - "threshold": 4, - "strictness": 0.75 - }, - "seletopclusts.2": { - "top_cluster": 1000, - "top_models": NaN - }, - "caprieval.5": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - }, - "mdscoring.1": { - "w_air": 0.0, - "w_bsa": 0.0, - "w_cdih": 0.0, - "w_dani": 0.0, - "w_deint": 0.0, - "w_desolv": 1.0, - "w_elec": 0.2, - "w_lcc": -10000.0, - "w_rg": 0.0, - "w_sani": 0.0, - "w_sym": 0.0, - "w_vdw": 1.0, - "w_vean": 0.0, - "w_xpcs": 0.0, - "w_xrdc": 0.0, - "w_zres": 0.0, - "contactairs": false, - "kcont": 1.0, - "ssdihed": "", - "error_dih": 10, - "dnarest_on": false, - "ligand_param_fname": "", - "ligand_top_fname": "", - "elecflag": true, - "dielec": "cdie", - "epsilon": 1.0, - "dihedflag": true, - "individualize": true, - "solvent": "water", - "nemsteps": 200, - "timestep": 0.002, - "waterheatsteps": 100, - "watersteps": 1250, - "watercoolsteps": 500, - "iniseed": 917, - "keepwater": false, - "tolerance": 5, - "log_level": "quiet" - }, - "caprieval.6": { - "reference_fname": "data/4G6M-matched.pdb", - "irmsd": true, - "fnat": true, - "lrmsd": true, - "ilrmsd": true, - "dockq": true, - "irmsd_cutoff": 10.0, - "fnat_cutoff": 5.0, - "receptor_chain": "A", - "ligand_chains": [ - "B" - ], - "sortby": "score", - "sort_ascending": true, - "alignment_method": "sequence", - "lovoalign_exec": "", - "clt_threshold": 4 - } - } - const result = getWeightsFromConfig(config) - const expected = { - w_elec: 0.2, - w_vdw: 1, - w_desolv: 1, - w_bsa: 0, - w_air: 0, - } - expect(result).toEqual(expected) - }) -}) \ No newline at end of file +describe("getWeightsFromConfig", () => { + test("should return the correct weights", () => { + // Pruned config of + // output/data/configurations/enhanced_haddock_params.json + // from run of docking-antibody-antigen-ranairCDR-clt-test.cfg example + const config = { + cns_exec: "", + ncores: 8, + max_cpus: true, + mode: "local", + batch_type: "slurm", + queue: "", + queue_limit: 100, + concat: 1, + self_contained: false, + clean: false, + preprocess: false, + postprocess: true, + run_dir: "output", + molecules: ["data/4G6K_fv.pdb", "data/4I1B-matched.pdb"], + "topoaa.1": {}, + "rigidbody.1": {}, + "caprieval.1": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + "clustfcc.1": { + threshold: 4, + executable: "src/contact_fcc", + contact_distance_cutoff: 5.0, + fraction_cutoff: 0.6, + strictness: 0.75, + }, + "seletopclusts.1": { + top_models: 10, + top_cluster: 1000, + }, + "caprieval.2": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + "flexref.1": {}, + "caprieval.3": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + "emref.1": {}, + "caprieval.4": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + "emscoring.1": {}, + "clustfcc.2": { + executable: "src/contact_fcc", + contact_distance_cutoff: 5.0, + fraction_cutoff: 0.6, + threshold: 4, + strictness: 0.75, + }, + "seletopclusts.2": { + top_cluster: 1000, + top_models: NaN, + }, + "caprieval.5": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + "mdscoring.1": { + w_air: 0.0, + w_bsa: 0.0, + w_cdih: 0.0, + w_dani: 0.0, + w_deint: 0.0, + w_desolv: 1.0, + w_elec: 0.2, + w_lcc: -10000.0, + w_rg: 0.0, + w_sani: 0.0, + w_sym: 0.0, + w_vdw: 1.0, + w_vean: 0.0, + w_xpcs: 0.0, + w_xrdc: 0.0, + w_zres: 0.0, + contactairs: false, + kcont: 1.0, + ssdihed: "", + error_dih: 10, + dnarest_on: false, + ligand_param_fname: "", + ligand_top_fname: "", + elecflag: true, + dielec: "cdie", + epsilon: 1.0, + dihedflag: true, + individualize: true, + solvent: "water", + nemsteps: 200, + timestep: 0.002, + waterheatsteps: 100, + watersteps: 1250, + watercoolsteps: 500, + iniseed: 917, + keepwater: false, + tolerance: 5, + log_level: "quiet", + }, + "caprieval.6": { + reference_fname: "data/4G6M-matched.pdb", + irmsd: true, + fnat: true, + lrmsd: true, + ilrmsd: true, + dockq: true, + irmsd_cutoff: 10.0, + fnat_cutoff: 5.0, + receptor_chain: "A", + ligand_chains: ["B"], + sortby: "score", + sort_ascending: true, + alignment_method: "sequence", + lovoalign_exec: "", + clt_threshold: 4, + }, + }; + const result = getWeightsFromConfig(config); + const expected = { + w_elec: 0.2, + w_vdw: 1, + w_desolv: 1, + w_bsa: 0, + w_air: 0, + }; + expect(result).toEqual(expected); + }); +}); + +describe("getLastCaprievalModule", () => { + test("should return the last caprieval module", () => { + const files: DirectoryItem = { + name: "output", + path: "output", + isDir: true, + isFile: false, + children: [ + { + name: "00_topoaa", + path: "output/00_topoaa", + isDir: true, + isFile: false, + }, + { + name: "01_rigidbody", + path: "output/01_rigidbody", + isDir: true, + isFile: false, + }, + { + name: "02_caprieval", + path: "output/02_caprieval", + isDir: true, + isFile: false, + }, + { + name: "03_clustfcc", + path: "output/03_clustfcc", + isDir: true, + isFile: false, + }, + { + name: "04_seletopclusts", + path: "output/04_seletopclusts", + isDir: true, + isFile: false, + }, + { + name: "05_caprieval", + path: "output/05_caprieval", + isDir: true, + isFile: false, + }, + { + name: "06_flexref", + path: "output/06_flexref", + isDir: true, + isFile: false, + }, + { + name: "07_caprieval", + path: "output/07_caprieval", + isDir: true, + isFile: false, + }, + { + name: "08_emref", + path: "output/08_emref", + isDir: true, + isFile: false, + }, + { + name: "09_caprieval", + path: "output/09_caprieval", + isDir: true, + isFile: false, + }, + { + name: "10_emscoring", + path: "output/10_emscoring", + isDir: true, + isFile: false, + }, + { + name: "11_clustfcc", + path: "output/11_clustfcc", + isDir: true, + isFile: false, + }, + { + name: "12_seletopclusts", + path: "output/12_seletopclusts", + isDir: true, + isFile: false, + }, + { + name: "13_caprieval", + path: "output/13_caprieval", + isDir: true, + isFile: false, + }, + { + name: "14_mdscoring", + path: "output/14_mdscoring", + isDir: true, + isFile: false, + }, + { + name: "15_caprieval", + path: "output/15_caprieval", + isDir: true, + isFile: false, + }, + { + name: "analysis", + path: "output/analysis", + isDir: true, + isFile: false, + }, + { + name: "data", + path: "output/data", + isDir: true, + isFile: false, + }, + { + name: "log", + path: "output/log", + isDir: false, + isFile: true, + }, + { + name: "traceback", + path: "output/traceback", + isDir: true, + isFile: false, + }, + ], + }; + const result = getLastCaprievalModule(files); + const expected = 15; + expect(result).toEqual(expected); + }); +}); diff --git a/app/models/job.server.ts b/app/models/job.server.ts index 1b734b5e..fa6b6151 100644 --- a/app/models/job.server.ts +++ b/app/models/job.server.ts @@ -2,8 +2,10 @@ import type { Params } from "@remix-run/react"; import { JobApi } from "~/bartender-client/apis/JobApi"; import { buildConfig } from "./config.server"; import { JOB_OUTPUT_DIR } from "./constants"; +import type { DirectoryItem } from "~/bartender-client"; import { ResponseError } from "~/bartender-client"; -import { object, number, Output } from "valibot"; +import type { Output } from "valibot"; +import { object, number, coerce, finite } from "valibot"; const BOOK_KEEPING_FILES = [ "stderr.txt", @@ -84,7 +86,11 @@ export async function getJobfile( }); } -export async function listOutputFiles(jobid: number, bartenderToken: string) { +export async function listOutputFiles( + jobid: number, + bartenderToken: string, + maxDepth = 3 +) { return await safeApi(bartenderToken, async (api) => { const items = await api.retrieveJobDirectoriesFromPath({ jobid, @@ -92,7 +98,7 @@ export async function listOutputFiles(jobid: number, bartenderToken: string) { // user might have supplied deeper directory structure // so can not browse past maxDepth, // but can download archive with files at any depth - maxDepth: 3, + maxDepth, }); return items; }); @@ -152,62 +158,137 @@ export async function getSubDirectoryAsArchive( }); } -export const WeightsSchema = object( - { - w_elec: number(), - w_vdw: number(), - w_desolv: number(), - w_bsa: number(), - w_air: number(), - } -); +export const WeightsSchema = object({ + // could use minimum/maximum from catalog, + // if they had sane values instead of -9999/9999 + w_elec: coerce(number([finite()]), Number), + w_vdw: coerce(number([finite()]), Number), + w_desolv: coerce(number([finite()]), Number), + w_bsa: coerce(number([finite()]), Number), + w_air: coerce(number([finite()]), Number), +}); export type Weights = Output; async function getConfig(jobid: number, bartenderToken: string) { - const path = 'output/data/configurations/enhanced_haddock_params.json' + const path = "output/data/configurations/enhanced_haddock_params.json"; const response = await getJobfile(jobid, path, bartenderToken); - const body = await response.json() - return body + const body = await response.text(); + return JSON.parse(body.replace(/\bNaN\b/g, "null")); } export function getWeightsFromConfig(config: any): Weights { // Find last module with weights - const keys = Object.keys(config).reverse() + const keys = Object.keys(config).reverse(); for (const key of keys) { - const module = config[key] - if ('w_elec' in module) { + const module = config[key]; + if ("w_elec" in module) { return { w_elec: module.w_elec, w_vdw: module.w_vdw, w_desolv: module.w_desolv, w_bsa: module.w_bsa, w_air: module.w_air, - } - } + }; + } } - throw new Error('No weights found in config') + throw new Error("No weights found in config"); } -export async function getWeights(jobid: number, bartenderToken: string): Promise { +export async function getWeights( + jobid: number, + bartenderToken: string +): Promise { // TODO check if rescore has been run and return those weights - const config = await getConfig(jobid, bartenderToken) - return getWeightsFromConfig(config) + const config = await getConfig(jobid, bartenderToken); + return getWeightsFromConfig(config); } -export async function step2rescoreModule(jobid: number, bartenderToken: string): Promise { - return -1 +export function getLastCaprievalModule(files: DirectoryItem): number { + if (!files.children) { + throw new Error("No modules found"); + } + const modules = [...files.children].reverse(); + for (const module of modules || []) { + if (module.isDir && module.name.endsWith("caprieval")) { + return parseInt(module.name.split("_")[0]); + } + } + throw new Error("No caprieval module found"); } -export async function getScores(jobid: number, module: number, bartenderToken: string) { - const files = await listOutputFiles(jobid, bartenderToken); - +export async function step2rescoreModule( + jobid: number, + bartenderToken: string +): Promise { + const files = await listOutputFiles(jobid, bartenderToken, 1); + return getLastCaprievalModule(files); } -export async function rescore(jobid: number, module: number, weights: Weights, bartenderToken: string) { +export async function getScores( + jobid: number, + module: number, + bartenderToken: string, + interactivness = 0 +) { + // output/15_caprieval/capri_ss.tsv + let prefix = `output/${module}_caprieval`; + if (interactivness > 0) { + Array(interactivness).forEach(() => (prefix += "_interactive")); + } + const structures = await getStructureScores(prefix, jobid, bartenderToken); + const clusters = await getClusterScores(prefix, jobid, bartenderToken); + return { structures, clusters }; +} + +async function getStructureScores( + prefix: string, + jobid: number, + bartenderToken: string +) { + const path = `${prefix}/capri_ss.tsv`; + const response = await getJobfile(jobid, path, bartenderToken); + const body = await response.text(); + const { tsvParse } = await import("d3-dsv"); + return tsvParse(body); +} + +async function getClusterScores( + prefix: string, + jobid: number, + bartenderToken: string +) { + const path = `${prefix}/capri_clt.tsv`; + const response = await getJobfile(jobid, path, bartenderToken); + const body = await response.text(); + const { tsvParse } = await import("d3-dsv"); + const commentless = removeComments(body); + return tsvParse(commentless); +} + +function removeComments(body: string): string { + return body.replace(/^#.*\n/gm, ""); +} + +export async function getInteractiveScores( + jobid: number, + module: number, + bartenderToken: string +) { + // Calling rescore multiple times will keep adding `_interactive` to the module name. + // TODO find the last one or somehow return all of them together with their weights + return await getScores(jobid, module, bartenderToken, 1); +} + +export async function rescore( + jobid: number, + module: number, + weights: Weights, + bartenderToken: string +) { const body = { module, - ...weights - } + ...weights, + }; const result = await safeApi(bartenderToken, async (api) => { const response = await api.runInteractiveApp({ jobid, @@ -219,5 +300,7 @@ export async function rescore(jobid: number, module: number, weights: Weights, b if (result.returncode !== 0) { throw new Error(`rescore failed with return code ${result.returncode}`); } - return await getScores(jobid, module, bartenderToken); -} \ No newline at end of file + // TODO used weights are outputed to result.stdout, need some way to store them + // either using https://github.com/i-VRESSE/bartender/pull/76 + // or as part of https://github.com/haddocking/haddock3/tree/interactive_rescoring +} diff --git a/app/routes/jobs.$id._index.tsx b/app/routes/jobs.$id._index.tsx index 8b0a2706..05c62c63 100644 --- a/app/routes/jobs.$id._index.tsx +++ b/app/routes/jobs.$id._index.tsx @@ -68,6 +68,14 @@ export default function JobPage() { 📦 Download archive +
+

Interactive applications

+ +
)} diff --git a/app/routes/jobs.$id.rescore.tsx b/app/routes/jobs.$id.rescore.tsx index da8c5a20..6a18bd6a 100644 --- a/app/routes/jobs.$id.rescore.tsx +++ b/app/routes/jobs.$id.rescore.tsx @@ -1,72 +1,143 @@ -import type { LoaderArgs} from "@remix-run/node"; +import type { LoaderArgs } from "@remix-run/node"; import { json } from "@remix-run/node"; -import { Form, useLoaderData } from "@remix-run/react"; -import { safeParse } from "valibot"; +import { Form, useActionData, useLoaderData } from "@remix-run/react"; +import { flatten, safeParse } from "valibot"; import { getBartenderToken } from "~/bartender_token.server"; -import { jobIdFromParams, getJobById, getWeights, WeightsSchema, getScores, step2rescoreModule, rescore } from "~/models/job.server"; +import { ErrorMessages } from "~/components/ErrorMessages"; +import { + jobIdFromParams, + getJobById, + getWeights, + WeightsSchema, + getScores, + step2rescoreModule, + rescore, + getInteractiveScores, +} from "~/models/job.server"; import { CompletedJobs } from "~/utils"; - export const loader = async ({ params, request }: LoaderArgs) => { - const jobId = jobIdFromParams(params); - const token = await getBartenderToken(request); - const job = await getJobById(jobId, token); - if (!CompletedJobs.has(job.state)) { - throw new Error("Job is not completed"); - } - const module = await step2rescoreModule(jobId, token); - const weights = await getWeights(jobId, token); - const scores = await getScores(jobId, module, token); - return json({ weights, scores }); -} + const jobId = jobIdFromParams(params); + const token = await getBartenderToken(request); + const job = await getJobById(jobId, token); + if (!CompletedJobs.has(job.state)) { + throw new Error("Job is not completed"); + } + const module = await step2rescoreModule(jobId, token); + const weights = await getWeights(jobId, token); + const scores = await getScores(jobId, module, token); + return json({ weights, scores }); +}; export const action = async ({ request, params }: LoaderArgs) => { - const token = await getBartenderToken(request); - const jobId = jobIdFromParams(params); - const formData = await request.formData(); - const result = safeParse(WeightsSchema, Object.fromEntries(formData)); - if (!result.success) { - throw json({ error: "Invalid weights" }, { status: 400 }); - } - const weights = result.data; - const module = await step2rescoreModule(jobId, token); - const scores = await rescore(jobId, module, weights, token); - return json({ weights, scores }); -} - + const token = await getBartenderToken(request); + const jobId = jobIdFromParams(params); + const formData = await request.formData(); + const result = safeParse(WeightsSchema, Object.fromEntries(formData)); + console.log(result); + if (!result.success) { + const errors = flatten(result.error); + return json({ errors }, { status: 400 }); + } + const weights = result.data; + const module = await step2rescoreModule(jobId, token); + await rescore(jobId, module, weights, token); + const scores = await getInteractiveScores(jobId, module, token); + return json({ weights, scores, errors: { nested: {} } }); +}; export default function RescorePage() { - const { weights, scores } = useLoaderData(); - - return ( - <> -
-            {JSON.stringify(scores, null, 2)}
-        
-
-

Rescore

-