Exemplo n.º 1
0
from flask import abort, current_app, request
from flask_restx import Namespace, Resource
from sqlalchemy.orm import undefer

import app.models as models
from _orchest.internals.two_phase_executor import TwoPhaseExecutor, TwoPhaseFunction
from app import schema
from app.apis.namespace_environment_images import DeleteProjectEnvironmentImages
from app.apis.namespace_jobs import DeleteJob
from app.apis.namespace_runs import AbortPipelineRun
from app.apis.namespace_sessions import StopInteractiveSession
from app.connections import db
from app.utils import register_schema

api = Namespace("projects", description="Managing Projects")
api = register_schema(api)


@api.route("/")
class ProjectList(Resource):
    @api.doc("get_projects")
    @api.marshal_with(schema.projects)
    def get(self):
        """Get all projects."""

        projects = models.Project.query.all()
        return {"projects": [proj.__dict__ for proj in projects]}, 200

    @api.doc("create_project")
    @api.expect(schema.project)
    @api.marshal_with(schema.project)
Exemplo n.º 2
0
"""API endpoints for unspecified orchest-api level information."""
from datetime import datetime, timezone

from flask import current_app
from flask_restx import Namespace, Resource

from app import models, schema, utils
from app.connections import db
from app.core import sessions

api = Namespace("info", description="Orchest-api information.")
api = utils.register_schema(api)


@api.route("/idle")
class IdleCheck(Resource):
    @api.doc("orchest_api_idle")
    @api.marshal_with(
        schema.idleness_check_result,
        code=200,
        description="Orchest-api idleness check.",
    )
    def get(self):
        """Checks if the Orchest-api is idle.

        The Orchest-api is considered idle if:
        - no environments are being built
        - no jupyter images are being built
        - there are no ongoing interactive-runs
        - there are no ongoing job runs
        - there are no busy kernels among running sessions, said busy