logplus/Workflow/WFEngine/WorkflowEngine/include/WorkflowHelper.h
2026-01-16 17:18:41 +08:00

108 lines
3.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef PAI_FRAME_WORKFLOWENGINE_WORKFLOW_HELPER_H
#define PAI_FRAME_WORKFLOWENGINE_WORKFLOW_HELPER_H
#include "WorkFlowFile.h"
#include "JobCreater.h"
#include <string>
#include <set>
using namespace std;
namespace pai{
namespace workflow {
/**
* @brief 将工作流文件名称与作业的信息匹配,界面显示信息的结构体
*/
struct JobInfo
{
std::string workflowName;
std::string jobId;
pai::ios::job::JobStatus state;
JobInfo():workflowName(), jobId(), state()
{
}
};
/**
* @brief 实时监控模块需要获取的监控源信息结构体
*/
struct TimeMonitorInfo
{
//工作流名称
string jobName;
//数据输出路径
string dataFilePath;
//实时监控模块的信息
string monitorModuleName;
int monitorModuleId;
//被监控模块的信息
int monitorColor;
int index;
int monitoredStepID;
string monitoredModuleName;
};
/**
* WorkflowHelper just something stuff for workflow
*/
class PAI_WORKFLOWENGINE_EXPORT WorkflowHelper {
public:
WorkflowHelper();
virtual ~WorkflowHelper();
/**
* @brief 保存CWorkFlowFile对象至jsonfilename文件
* @param jsonfilename 目标工作流文件
* @param file 目标工作流文件对象
* @return 如果保存成功返回true否则返回false
*/
bool SaveWorkflow(const std::string& jsonfilename, CWorkFlowFile* file);
/*
* 此接口由界面使用,由于监控模块的特殊需求,有其他使用该接口的需要注意
* 界面传递过来的CWorkFlowFile中的监控模块没有connection链接
* 因此但是在返回的字符串中需要添加这个connection
*
*/
std::string GetWorkflowJson(CWorkFlowFile* file) const;
/**
* @brief 提交指定的工作流(核心算法)
* @param[in] jobInfo 待提交的工作流相关的提交信息
* @param[in/out] errorMsg 校验错误信息
* @pre 要先初始化errorMsg
* @return 如果提交成功返回true否则返回false
*/
bool Submit(JobSubmitInfo *jobInfo, string &errorMsg);
/**
* @brief 通过jobId获取实时监控模块的数据信息,解析工作流获取被监控模块信息和监控模块信息
* @param jobId 作业ID
* @return 监控模块数据信息
*/
static vector<TimeMonitorInfo> GetTimeMonitorInfos(const pai::ios::job::JobID& chainId);
private:
WorkflowHelper(const WorkflowHelper &);
WorkflowHelper & operator=(const WorkflowHelper &);
void InsertRunningDataRecords(const set<string> &dataPaths);
void DelRunningDataRecords(const set<string> &dataPaths);
void UpdateJobId2RunningDataRecord(const set<string> &dataPaths, const long long &jobId);
/**
* @brief 将一个提交成功后的作业Id保存到工作流编译临时目录
* @param jobid 作业的ID
* @param strCompileTmpDir 工作流编译临时目录
*/
void SaveJobIdToLocalCompileTmp(const std::string& jobid,std::string strCompileTmpDir);
private:
JobInfo jobinfo;
};
}
}
#endif