bartender.web.api.applications.views#

Attributes#

Functions#

upload_job() → fastapi.responses.RedirectResponse)

Creates job model in the database, stage archive locally and submit to scheduler.

_check_role(→ None)

Check whether submitter is allowed to use application.

_validate_form(→ dict[str, str])

Validates the form request against the config.input_schema if it is defined.

validate_input(→ None)

Validates the input payload against the provided configuration.

extract_payload_from_form(→ dict[str, str])

Extracts the payload from the form request.

Module Contents#

bartender.web.api.applications.views.router#
async bartender.web.api.applications.views.upload_job(application: str, request: fastapi.Request, job_dao: bartender.db.dao.job_dao.CurrentJobDAO, submitter: bartender.web.users.CurrentUser, context: bartender.context.CurrentContext, upload: fastapi.UploadFile = File(description='Archive with files needed for application')) fastapi.responses.RedirectResponse#

Creates job model in the database, stage archive locally and submit to scheduler.

Parameters:
  • application (str) – Name of application to run job for.

  • upload (fastapi.UploadFile) – Archive with config file for application.

  • request (fastapi.Request) – request object.

  • job_dao (bartender.db.dao.job_dao.CurrentJobDAO) – JobDAO object.

  • submitter (bartender.web.users.CurrentUser) – User who submitted job.

  • context (bartender.context.CurrentContext) – Context with applications and destinations.

Raises:
  • IndexError – When job could not created inside database or when config file was not found.

  • HTTPException – Application is invalid.

Returns:

redirect response to created job.

Return type:

fastapi.responses.RedirectResponse

bartender.web.api.applications.views._check_role(application: str, submitter: bartender.web.users.User, context: bartender.context.Context) None#

Check whether submitter is allowed to use application.

When application has some allowed_roles defined then the submitter should have at least one of those roles to continue.

When application has no allowed_roles defined then the submitter is allowed to continue.

Parameters:
  • application (str) – Name of application to run job for.

  • submitter (bartender.web.users.User) – User who submitted job.

  • context (bartender.context.Context) – Context with applications.

Raises:

HTTPException – When submitter is missing role.

Return type:

None

async bartender.web.api.applications.views._validate_form(request: fastapi.Request, config: bartender.config.ApplicatonConfiguration) dict[str, str]#

Validates the form request against the config.input_schema if it is defined.

Parameters:
Returns:

The payload extracted from the form request. Without any files or duplicate keys.

Return type:

dict[str, str]

bartender.web.api.applications.views.validate_input(config: bartender.config.ApplicatonConfiguration, payload: dict[str, str]) None#

Validates the input payload against the provided configuration.

If invalid an exception is raised.

Parameters:
Return type:

None

bartender.web.api.applications.views.extract_payload_from_form(form: fastapi.datastructures.FormData) dict[str, str]#

Extracts the payload from the form request.

Parameters:

form (fastapi.datastructures.FormData) – The form request.

Returns:

The payload extracted from the form request. Without any files or duplicate keys.

Return type:

dict[str, str]