Skip to content

Commit c1d8200

Browse files
committed
replaced wildcard with actual path, which can be overridedn by the mlops.json file
1 parent 485ef9f commit c1d8200

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

adk/mlops.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
class MLOps(object):
88
spool_dir = "/tmp/ta"
9-
agent_dir = "/opt/mlops-agent/datarobot_mlops_package-8.1.2"
9+
agent_dir = "/opt/mlops-agent"
10+
mlops_dir_name = "datarobot_mlops_package-8.1.2"
1011

1112
def __init__(self, api_token, path):
1213
self.token = api_token
@@ -15,27 +16,28 @@ def __init__(self, api_token, path):
1516
mlops_config = json.load(f)
1617
else:
1718
raise Exception("'mlops.json' file does not exist, but mlops was requested.")
18-
if not os.path.exists(agent_dir):
19+
if not os.path.exists(self.agent_dir):
1920
raise Exception("environment is not configured for mlops.\nPlease select a valid mlops enabled environment.")
20-
self.endpoint = mlops_config['datarobot_api_endpoint']
21+
self.endpoint = mlops_config['datarobot_mlops_service_url']
2122
self.model_id = mlops_config['model_id']
2223
self.deployment_id = mlops_config['deployment_id']
24+
self.mlops_name = mlops_config.get('mlops_dir_name', 'datarobot_mlops_package-8.1.2')
2325

2426
def init(self):
2527
os.environ['MLOPS_DEPLOYMENT_ID'] = self.deployment_id
2628
os.environ['MLOPS_MODEL_ID'] = self.model_id
2729
os.environ['MLOPS_SPOOLER_TYPE'] = "FILESYSTEM"
28-
os.environ['MLOPS_FILESYSTEM_DIRECTORY'] = "/tmp/ta"
30+
os.environ['MLOPS_FILESYSTEM_DIRECTORY'] = self.spool_dir
2931

30-
with open(f'{self.agent_dir}/conf/mlops.agent.conf.yaml') as f:
32+
with open(f'{self.agent_dir}/{self.mlops_dir_name}/conf/mlops.agent.conf.yaml') as f:
3133
documents = yaml.load(f, Loader=yaml.FullLoader)
3234
documents['mlopsUrl'] = self.endpoint
3335
documents['apiToken'] = self.token
34-
with open(f'{self.agent_dir}/conf/mlops.agent.conf.yaml', 'w') as f:
36+
with open(f'{self.agent_dir}/{self.mlops_dir_name}/conf/mlops.agent.conf.yaml', 'w') as f:
3537
yaml.dump(documents, f)
3638

37-
subprocess.call(f'{self.agent_dir}/bin/start-agent.sh')
38-
check = subprocess.Popen([f'{self.agent_dir}/bin/status-agent.sh'], stdout=subprocess.PIPE)
39+
subprocess.call(f'{self.agent_dir}/{self.mlops_dir_name}/bin/start-agent.sh')
40+
check = subprocess.Popen([f'{self.agent_dir}/{self.mlops_dir_name}/bin/status-agent.sh'], stdout=subprocess.PIPE)
3941
output = check.stdout.readlines()[0]
4042
check.terminate()
4143
if b"DataRobot MLOps-Agent is running as a service." in output:

0 commit comments

Comments
 (0)