-
Notifications
You must be signed in to change notification settings - Fork 1
ALGO-62 Integrated mlops agent #16
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
09422ca
initial testable commit
zeryx 435e4fe
functional, feature filled commit
zeryx e0ec40e
added yaml as dependency
zeryx b32a1be
ugh version mgmt
zeryx 485ef9f
fix test shim
zeryx c1d8200
replaced wildcard with actual path, which can be overridedn by the ml…
zeryx a44964b
added pyaml to the dependencies
zeryx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import yaml | ||
import json | ||
import os | ||
import subprocess | ||
|
||
|
||
class MLOps(object): | ||
spool_dir = "/tmp/ta" | ||
agent_dir = "/opt/mlops-agent" | ||
mlops_dir_name = "datarobot_mlops_package-8.1.2" | ||
|
||
def __init__(self, api_token, path): | ||
self.token = api_token | ||
if os.path.exists(path): | ||
with open(path) as f: | ||
mlops_config = json.load(f) | ||
else: | ||
raise Exception("'mlops.json' file does not exist, but mlops was requested.") | ||
if not os.path.exists(self.agent_dir): | ||
raise Exception("environment is not configured for mlops.\nPlease select a valid mlops enabled environment.") | ||
self.endpoint = mlops_config['datarobot_mlops_service_url'] | ||
self.model_id = mlops_config['model_id'] | ||
self.deployment_id = mlops_config['deployment_id'] | ||
self.mlops_name = mlops_config.get('mlops_dir_name', 'datarobot_mlops_package-8.1.2') | ||
|
||
def init(self): | ||
os.environ['MLOPS_DEPLOYMENT_ID'] = self.deployment_id | ||
os.environ['MLOPS_MODEL_ID'] = self.model_id | ||
os.environ['MLOPS_SPOOLER_TYPE'] = "FILESYSTEM" | ||
os.environ['MLOPS_FILESYSTEM_DIRECTORY'] = self.spool_dir | ||
|
||
with open(f'{self.agent_dir}/{self.mlops_dir_name}/conf/mlops.agent.conf.yaml') as f: | ||
documents = yaml.load(f, Loader=yaml.FullLoader) | ||
documents['mlopsUrl'] = self.endpoint | ||
documents['apiToken'] = self.token | ||
with open(f'{self.agent_dir}/{self.mlops_dir_name}/conf/mlops.agent.conf.yaml', 'w') as f: | ||
yaml.dump(documents, f) | ||
|
||
subprocess.call(f'{self.agent_dir}/{self.mlops_dir_name}/bin/start-agent.sh') | ||
check = subprocess.Popen([f'{self.agent_dir}/{self.mlops_dir_name}/bin/status-agent.sh'], stdout=subprocess.PIPE) | ||
output = check.stdout.readlines()[0] | ||
check.terminate() | ||
if b"DataRobot MLOps-Agent is running as a service." in output: | ||
return True | ||
else: | ||
raise Exception(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
algorithmia>=1.7,<2 | ||
six | ||
six | ||
pyaml>=21.10,<21.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from adk import ADK | ||
|
||
from adk.modeldata import ModelData | ||
|
||
class ADKTest(ADK): | ||
def __init__(self, apply_func, load_func=None, client=None, manifest_path="model_manifest.json.freeze"): | ||
super(ADKTest, self).__init__(apply_func, load_func, client) | ||
self.model_data = self.init_manifest(manifest_path) | ||
self.model_data = ModelData(self.client, manifest_path) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you aren't using the same env var as the monitoring agent itself? This might make things simpler, unless you specifically don't want them to be the same. That would be just
MLOPS_API_TOKEN
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in the event that there are other MLOPS API tokens from different orgs; wanting to be very clear about what this token is used for so it's not confused with any algorithmia token