Skip to content

Commit 350a4ea

Browse files
committed
enable safe replacement of mlops.json by setting environment variables
1 parent c0f47d1 commit 350a4ea

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

adk/mlops.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ def __init__(self, api_token, path):
1515
if os.path.exists(path):
1616
with open(path) as f:
1717
mlops_config = json.load(f)
18-
else:
19-
raise Exception("'mlops.json' file does not exist, but mlops was requested.")
18+
self.endpoint = mlops_config['datarobot_mlops_service_url']
19+
self.model_id = mlops_config['model_id']
20+
self.deployment_id = mlops_config['deployment_id']
21+
self.mlops_name = mlops_config.get('mlops_dir_name', 'datarobot_mlops_package-8.1.2')
22+
if "MLOPS_SERVICE_URL" in os.environ:
23+
self.endpoint = os.environ['MLOPS_SERVICE_URL']
24+
if "MODEL_ID" in os.environ:
25+
self.model_id = os.environ['MODEL_ID']
26+
if "DEPLOYMENT_ID" in os.environ:
27+
self.deployment_id = os.environ['DEPLOYMENT_ID']
2028
if not os.path.exists(self.agent_dir):
2129
raise Exception("environment is not configured for mlops.\nPlease select a valid mlops enabled environment.")
22-
self.endpoint = mlops_config['datarobot_mlops_service_url']
23-
self.model_id = mlops_config['model_id']
24-
self.deployment_id = mlops_config['deployment_id']
25-
self.mlops_name = mlops_config.get('mlops_dir_name', 'datarobot_mlops_package-8.1.2')
2630

2731
def init(self):
2832
os.environ['MLOPS_DEPLOYMENT_ID'] = self.deployment_id

0 commit comments

Comments
 (0)