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)
def project_get(project_uuid): project = Project.query.filter(Project.uuid == project_uuid).first() if project is None: return jsonify({"message": "Project doesn't exist."}), 404 resp = requests.get( (f'http://{current_app.config["ORCHEST_API_ADDRESS"]}' f"/api/projects/{project_uuid}")) if resp.status_code == 404: return ( jsonify( {"message": "Project doesn't exist in the orchest-api."}), 404, ) elif resp.status_code != 200: return ( jsonify({"message": "Orchest-api project retrieval failed."}), resp.status_code, ) else: # Merge the project data coming from the orchest-api. counts = project_entity_counts(project_uuid) project = {**project.as_dict(), **resp.json(), **counts} return jsonify(project)