github-code-scanning[bot] commented on code in PR #12071:
URL: https://github.com/apache/dolphinscheduler/pull/12071#discussion_r975504265
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/main/java/org/apache/dolphinscheduler/plugin/task/mlflow/MlflowTask.java:
##########
@@ -141,43 +170,68 @@
args.add(String.format(MlflowConstants.EXPORT_MLFLOW_TRACKING_URI_ENV,
mlflowParameters.getMlflowTrackingUri()));
String runCommand;
+ String versionString;
- if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_BASIC_ALGORITHM))
{
- args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT));
- args.add(String.format(MlflowConstants.GIT_CLONE_REPO,
MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
+ if (mlflowParameters.isCustomProject()) {
+ runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
+ versionString =
getVersionString(mlflowParameters.getMlflowProjectVersion(),
mlflowParameters.getMlflowProjectRepository());
+ } else {
+ switch (mlflowParameters.getMlflowJobType()) {
+ case MlflowConstants.JOB_TYPE_BASIC_ALGORITHM:
+ runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
+ break;
+ case MlflowConstants.JOB_TYPE_AUTOML:
+ runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
+ break;
+ default:
+ throw new TaskException("Unsupported mlflow job type: " +
mlflowParameters.getMlflowJobType());
+ }
- runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
- runCommand = String.format(runCommand,
mlflowParameters.getAlgorithm(), mlflowParameters.getParams(),
mlflowParameters.getSearchParams(), mlflowParameters.getModelName(),
- mlflowParameters.getExperimentName());
+ versionString = getVersionString(getPresetRepositoryVersion(),
getPresetRepository());
+ }
- } else if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_AUTOML)) {
- args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
MlflowConstants.PRESET_AUTOML_PROJECT));
- args.add(String.format(MlflowConstants.GIT_CLONE_REPO,
MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
+ // add version string to command if repository is local path
+ if (StringUtils.isNotEmpty(versionString)) {
+ runCommand = runCommand + " " + versionString;
+ }
- runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
- runCommand = String.format(runCommand,
mlflowParameters.getAutomlTool(), mlflowParameters.getParams(),
mlflowParameters.getModelName(), mlflowParameters.getExperimentName());
+ switch (mlflowParameters.getMlflowJobType()) {
+ case MlflowConstants.JOB_TYPE_BASIC_ALGORITHM:
+ args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- } else if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_CUSTOM_PROJECT))
{
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
mlflowParameters.getMlflowProjectRepository()));
+ String repoBasicAlgorithm = getPresetRepository() +
MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT;
+ args.add(String.format(MlflowConstants.SET_REPOSITORY,
repoBasicAlgorithm));
- runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
- runCommand = String.format(runCommand,
mlflowParameters.getParams(), mlflowParameters.getExperimentName(),
mlflowParameters.getMlflowProjectVersion());
- } else {
- runCommand = String.format("Cant not Support %s",
mlflowParameters.getMlflowJobType());
+ runCommand = String.format(runCommand,
mlflowParameters.getAlgorithm(), mlflowParameters.getParams(),
mlflowParameters.getSearchParams(), mlflowParameters.getModelName(),
+ mlflowParameters.getExperimentName());
+ break;
+
+ case MlflowConstants.JOB_TYPE_AUTOML:
+ args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
+ String repoAutoML = getPresetRepository() +
MlflowConstants.PRESET_AUTOML_PROJECT;
+ args.add(String.format(MlflowConstants.SET_REPOSITORY,
repoAutoML));
+
+ runCommand = String.format(runCommand,
mlflowParameters.getAutomlTool(), mlflowParameters.getParams(),
mlflowParameters.getModelName(), mlflowParameters.getExperimentName());
+ break;
+ case MlflowConstants.JOB_TYPE_CUSTOM_PROJECT:
+ args.add(String.format(MlflowConstants.SET_REPOSITORY,
mlflowParameters.getMlflowProjectRepository()));
+ runCommand = String.format(runCommand,
mlflowParameters.getParams(), mlflowParameters.getExperimentName());
Review Comment:
## Missing format argument
This format call refers to 4 argument(s) but only supplies 2 argument(s).
This format call refers to 5 argument(s) but only supplies 2 argument(s).
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1496)
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/main/java/org/apache/dolphinscheduler/plugin/task/mlflow/MlflowTask.java:
##########
@@ -141,43 +170,68 @@
args.add(String.format(MlflowConstants.EXPORT_MLFLOW_TRACKING_URI_ENV,
mlflowParameters.getMlflowTrackingUri()));
String runCommand;
+ String versionString;
- if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_BASIC_ALGORITHM))
{
- args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT));
- args.add(String.format(MlflowConstants.GIT_CLONE_REPO,
MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
+ if (mlflowParameters.isCustomProject()) {
+ runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
+ versionString =
getVersionString(mlflowParameters.getMlflowProjectVersion(),
mlflowParameters.getMlflowProjectRepository());
+ } else {
+ switch (mlflowParameters.getMlflowJobType()) {
+ case MlflowConstants.JOB_TYPE_BASIC_ALGORITHM:
+ runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
+ break;
+ case MlflowConstants.JOB_TYPE_AUTOML:
+ runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
+ break;
+ default:
+ throw new TaskException("Unsupported mlflow job type: " +
mlflowParameters.getMlflowJobType());
+ }
- runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
- runCommand = String.format(runCommand,
mlflowParameters.getAlgorithm(), mlflowParameters.getParams(),
mlflowParameters.getSearchParams(), mlflowParameters.getModelName(),
- mlflowParameters.getExperimentName());
+ versionString = getVersionString(getPresetRepositoryVersion(),
getPresetRepository());
+ }
- } else if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_AUTOML)) {
- args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
MlflowConstants.PRESET_AUTOML_PROJECT));
- args.add(String.format(MlflowConstants.GIT_CLONE_REPO,
MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
+ // add version string to command if repository is local path
+ if (StringUtils.isNotEmpty(versionString)) {
+ runCommand = runCommand + " " + versionString;
+ }
- runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
- runCommand = String.format(runCommand,
mlflowParameters.getAutomlTool(), mlflowParameters.getParams(),
mlflowParameters.getModelName(), mlflowParameters.getExperimentName());
+ switch (mlflowParameters.getMlflowJobType()) {
+ case MlflowConstants.JOB_TYPE_BASIC_ALGORITHM:
+ args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
- } else if
(mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_CUSTOM_PROJECT))
{
- args.add(String.format(MlflowConstants.SET_REPOSITORY,
mlflowParameters.getMlflowProjectRepository()));
+ String repoBasicAlgorithm = getPresetRepository() +
MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT;
+ args.add(String.format(MlflowConstants.SET_REPOSITORY,
repoBasicAlgorithm));
- runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
- runCommand = String.format(runCommand,
mlflowParameters.getParams(), mlflowParameters.getExperimentName(),
mlflowParameters.getMlflowProjectVersion());
- } else {
- runCommand = String.format("Cant not Support %s",
mlflowParameters.getMlflowJobType());
+ runCommand = String.format(runCommand,
mlflowParameters.getAlgorithm(), mlflowParameters.getParams(),
mlflowParameters.getSearchParams(), mlflowParameters.getModelName(),
+ mlflowParameters.getExperimentName());
+ break;
+
+ case MlflowConstants.JOB_TYPE_AUTOML:
+ args.add(String.format(MlflowConstants.SET_DATA_PATH,
mlflowParameters.getDataPath()));
+ String repoAutoML = getPresetRepository() +
MlflowConstants.PRESET_AUTOML_PROJECT;
+ args.add(String.format(MlflowConstants.SET_REPOSITORY,
repoAutoML));
+
+ runCommand = String.format(runCommand,
mlflowParameters.getAutomlTool(), mlflowParameters.getParams(),
mlflowParameters.getModelName(), mlflowParameters.getExperimentName());
Review Comment:
## Missing format argument
This format call refers to 5 argument(s) but only supplies 4 argument(s).
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1495)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]