Skip to content

Commit

Permalink
Addressed feedback.
Browse files Browse the repository at this point in the history
Signed-off-by: Andon Andonov <[email protected]>
  • Loading branch information
doks5 committed Mar 23, 2023
1 parent 5c26e68 commit efbd4a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package com.vmware.taurus.service.deploy;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -14,14 +14,19 @@
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;

/** Handles operations related to supported python versions for data job deployments. */
/**
* Handles operations related to supported python versions for data job deployments.
* The class contains utility methods which provide functionality to read the configuration
* related to the python versions supported by the Control Service.
* These utility methods are meant to be used in other components, as needed.
* */
@Component
@RequiredArgsConstructor
@Slf4j
public class SupportedPythonVersions {

@Value("#{${datajobs.deployment.supportedPythonVersions}}")
private HashMap<String, HashMap<String, String>> supportedPythonVersions;
private Map<String, Map<String, String>> supportedPythonVersions;

@Value("${datajobs.vdk.image}")
private String vdkImage;
Expand All @@ -36,12 +41,12 @@ public class SupportedPythonVersions {
/**
* Check if the python_version passed by the user is supported by the Control Service.
*
* @param python_version python version passed by the user.
* @param pythonVersion python version passed by the user.
* @return true if the version is supported, and false otherwise.
*/
public boolean isPythonVersionSupported(String python_version) {
public boolean isPythonVersionSupported(String pythonVersion) {
if (!supportedPythonVersions.isEmpty()) {
return supportedPythonVersions.containsKey(python_version);
return supportedPythonVersions.containsKey(pythonVersion);
} else {
return false;
}
Expand Down Expand Up @@ -72,12 +77,12 @@ public String getSupportedPythonVersions() {
* according to the configuration, the base image corresponding to the python_version is returned.
* Otherwise, the default base image name as set in deploymentDataJobBaseImage is returned.
*
* @param python_version a string indicating the python version passed by the user
* @param pythonVersion a string indicating the python version passed by the user
* @return a string of the data job base image.
*/
public String getJobBaseImage(String python_version) {
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
return supportedPythonVersions.get(python_version).get(BASE_IMAGE);
public String getJobBaseImage(String pythonVersion) {
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(pythonVersion)) {
return supportedPythonVersions.get(pythonVersion).get(BASE_IMAGE);
} else {
return deploymentDataJobBaseImage;
}
Expand All @@ -93,12 +98,12 @@ public String getDefaultJobBaseImage() {
* configuration, the vdk image corresponding to the python_version is returned. Otherwise, the
* default vdk image name as set in vdkImage is returned.
*
* @param python_version a string indicating the python version passed by the user
* @param pythonVersion a string indicating the python version passed by the user
* @return a string of the data job base image.
*/
public String getVdkImage(String python_version) {
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
return supportedPythonVersions.get(python_version).get(VDK_IMAGE);
public String getVdkImage(String pythonVersion) {
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(pythonVersion)) {
return supportedPythonVersions.get(pythonVersion).get(VDK_IMAGE);
} else {
return vdkImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ datajobs.kadmin_password=${KADMIN_PASSWORD}
# This is the full image name of the data job builder
datajobs.builder.image=registry.hub.docker.com/versatiledatakit/job-builder:1.1
datajobs.deployment.dataJobBaseImage=registry.hub.docker.com/versatiledatakit/data-job-base-python-3.7:latest
datajobs.deployment.supportedPythonVersions=${DATAJOBS_DEPLOYMENT_SUPPORTED_PYTHON_VERSIONS:{}}

# Path to an ini config file that contains vdk runtime options
datajobs.vdk_options_ini=${VDK_OPTIONS_INI}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ datajobs.deployment.dataJobBaseImage=python:3.9-slim

# The map of python version and respective data job base and vdk images that would be
# used for data job deployments
datajobs.deployment.supportedPythonVersions={}
datajobs.deployment.supportedPythonVersions=${DATAJOBS_DEPLOYMENT_SUPPORTED_PYTHON_VERSIONS:{}}

#Configuration variables used for data job execution cleanup
#This is a spring cron expression, used to schedule the clean up job / default is every 3 hours
Expand Down

0 comments on commit efbd4a0

Please sign in to comment.