Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DSIP-46] Unify the logic task params data structure between front-end and back-end #16153

Closed
2 tasks done
Tracked by #14102
ruanwenjun opened this issue Jun 13, 2024 · 2 comments · Fixed by #16193
Closed
2 tasks done
Tracked by #14102
Assignees
Labels
DSIP improvement make more easy to user or prompt friendly
Milestone

Comments

@ruanwenjun
Copy link
Member

ruanwenjun commented Jun 13, 2024

Search before asking

  • I had searched in the DSIP and found no similar DSIP.

Motivation

The logic task params in backend is not structure, we need to parse the logic params from some fields.
This make us to use some extra JSON deserialize code, and make the logic is very hard to maintain.

public DependentParameters getDependency() {
if (this.dependency == null) {
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
this.dependency =
JSONUtils.parseObject((String) taskParamsMap.get(Constants.DEPENDENCE), DependentParameters.class);
}
return this.dependency;
}
public void setDependency(DependentParameters dependency) {
this.dependency = dependency;
}
public ConditionsParameters getConditionsParameters() {
if (this.conditionsParameters == null) {
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
this.conditionsParameters =
JSONUtils.parseObject((String) taskParamsMap.get(Constants.DEPENDENCE), ConditionsParameters.class);
}
return conditionsParameters;
}
public ConditionsParameters.ConditionResult getConditionResult() {
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
String conditionResult = (String) taskParamsMap.getOrDefault(Constants.CONDITION_RESULT, "");
if (StringUtils.isNotEmpty(conditionResult)) {
return JSONUtils.parseObject(conditionResult, new TypeReference<ConditionsParameters.ConditionResult>() {
});
}
return null;
}
public void setConditionResult(ConditionsParameters conditionsParameters) {
if (conditionsParameters == null) {
return;
}
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
if (taskParamsMap == null) {
taskParamsMap = new HashMap<>();
}
taskParamsMap.put(Constants.CONDITION_RESULT, JSONUtils.toJsonString(conditionsParameters));
this.setTaskParams(JSONUtils.toJsonString(taskParamsMap));
}
public SwitchParameters getSwitchDependency() {
// todo: We need to directly use Jackson to deserialize the taskParam, rather than parse the map and get from
// field.
if (this.switchDependency == null) {
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
this.switchDependency =
JSONUtils.parseObject((String) taskParamsMap.get(Constants.SWITCH_RESULT), SwitchParameters.class);
}
return this.switchDependency;
}
public void setSwitchDependency(SwitchParameters switchDependency) {
Map<String, Object> taskParamsMap =
JSONUtils.parseObject(this.getTaskParams(), new TypeReference<Map<String, Object>>() {
});
taskParamsMap.put(Constants.SWITCH_RESULT, JSONUtils.toJsonString(switchDependency));
this.switchDependency = switchDependency;
this.setTaskParams(JSONUtils.toJsonString(taskParamsMap));
}

Design Detail

Directly parse the logic task params from task params.

Compatibility, Deprecation, and Migration Plan

compatibility

Test Plan

Code of Conduct

@ruanwenjun ruanwenjun added Waiting for reply Waiting for reply DSIP labels Jun 13, 2024
@ruanwenjun ruanwenjun changed the title [DSIP-] Unify the logic task params data structure between front-end and back-end [DSIP-46] Unify the logic task params data structure between front-end and back-end Jun 13, 2024
@SbloodyS SbloodyS removed the Waiting for reply Waiting for reply label Jun 14, 2024
@cncws
Copy link
Contributor

cncws commented Jun 14, 2024

Hope this DSIP can solve the problem I had:[Bug] [PyTorch] pythonCommand is not used at runtime, it's always using ${PYTHON_LAUNCHER} #15961

@ruanwenjun
Copy link
Member Author

Hope this DSIP can solve the problem I had:[Bug] [PyTorch] pythonCommand is not used at runtime, it's always using ${PYTHON_LAUNCHER} #15961

This DSIP will not fixed this problem, you need to define a PYTHON_LAUNCHER at your environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DSIP improvement make more easy to user or prompt friendly
Projects
None yet
4 participants