示例#1
0
    def pipelines_get(project_uuid):

        try:
            with TwoPhaseExecutor(db.session) as tpe:
                SyncProjectPipelinesDBState(tpe).transaction(project_uuid)
        except Exception as e:
            msg = (
                "Error during project pipelines synchronization of "
                f"{project_uuid}: {str(e)}."
            )
            return jsonify({"message": msg}), 500

        pipelines = Pipeline.query.filter(Pipeline.project_uuid == project_uuid).all()
        pipelines_augmented = []

        for pipeline in pipelines:

            pipeline_augmented = {
                "uuid": pipeline.uuid,
                "path": pipeline.path,
            }

            pipeline_json = get_pipeline_json(pipeline.uuid, pipeline.project_uuid)
            if pipeline_json is not None:
                pipeline_augmented["name"] = pipeline_json["name"]
            else:
                pipeline_augmented["name"] = "Warning: pipeline file was not found."

            pipelines_augmented.append(pipeline_augmented)

        json_string = json.dumps({"success": True, "result": pipelines_augmented})

        return json_string, 200, {"content-type": "application/json"}
示例#2
0
文件: views.py 项目: sajanv88/orchest
    def projects_get():

        discoverFSDeletedProjects()
        discoverFSCreatedProjects()

        # Projects that are in a INITIALIZING or DELETING state won't
        # be shown until ready.
        projects = projects_schema.dump(
            Project.query.filter_by(status="READY").all())

        for project in projects:
            # Discover both pipelines of newly initialized projects and
            # manually initialized pipelines of existing projects. Use a
            # a TwoPhaseExecutor for each project so that issues in one
            # project do not hinder the pipeline synchronization of
            # others.
            try:
                with TwoPhaseExecutor(db.session) as tpe:
                    SyncProjectPipelinesDBState(tpe).transaction(
                        project["uuid"])
            except Exception as e:
                current_app.logger.error(
                    ("Error during project pipelines synchronization of "
                     f'{project["path"]}: {e}.'))

            counts = project_entity_counts(project["uuid"])
            project.update(counts)

        return jsonify(projects)
示例#3
0
    def projects_get():

        discoverFSDeletedProjects()
        discoverFSCreatedProjects()

        # Projects that are in a INITIALIZING or DELETING state won't
        # be shown until ready.
        projects = projects_schema.dump(
            Project.query.filter_by(status="READY").all())

        for project in projects:
            # Discover both pipelines of newly initialized projects and
            # manually initialized pipelines of existing projects. Use a
            # a TwoPhaseExecutor for each project so that issues in one
            # project do not hinder the pipeline synchronization of
            # others.
            try:
                with TwoPhaseExecutor(db.session) as tpe:
                    SyncProjectPipelinesDBState(tpe).transaction(
                        project["uuid"])
            except Exception as e:
                current_app.logger.error(
                    ("Error during project pipelines synchronization of "
                     f'{project["path"]}: {e}.'))

            project["pipeline_count"] = Pipeline.query.filter(
                Pipeline.project_uuid == project["uuid"]).count()
            project["environment_count"] = len(
                get_environments(project["uuid"]))

            resp = requests.get(
                f'http://{current_app.config["ORCHEST_API_ADDRESS"]}/api/jobs/',
                params={"project_uuid": project["uuid"]},
            )
            data = resp.json()
            if resp.status_code != 200:
                job_count = 0
            else:
                job_count = len(data.get("jobs", []))
            project["job_count"] = job_count

        return jsonify(projects)