- Notifications
You must be signed in to change notification settings - Fork1
The Golang library for Modzy Machine Learning Operations (MLOps) Platform
License
modzy/sdk-go
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Modzy's Golang SDK queries models, submits inference jobs, and returns results directly to your editor.
Add the dependency
go get -u github.com/modzy/sdk-go
API keys are security credentials required to perform API requests to Modzy. Our API keys are composed of an ID that is split by a dot into two parts: a public and private part.
Thepublic part is the API keys' visible part only used to identify the key and by itself, it’s unable to perform API requests.
Theprivate part is the public part's complement and it’s required to perform API requests. Since it’s not stored on Modzy’s servers, it cannot be recovered. Make sure to save it securely. If lost, you canreplace the API key.
Find your API key in your user profile. To get your full API key click on "Get key":
Once you have amodel andversion identified, get authenticated with your API key.
client:=modzy.NewClient("http://url.to.modzy/api").WithAPIKey("API Key")
Modzy’s Marketplace includes pre-trained and re-trainable AI models from industry-leading machine learning companies, accelerating the process from data to value.
The Model service drives the Marketplace and can be integrated with other applications, scripts, and systems. It provides routes to list, search, and filter model and model-version details.
out,err:=client.Models().ListModels(ctx,input)iferr!=nil {returnerr}for_,modelSummary:=rangeout.Models {fmt.Println("Model: ",modelSummary)}
Tags help categorize and filter models. They make model browsing easier.
out,err:=client.Models().GetTags(ctx)iferr!=nil {returnerr}for_,tag:=rangeout.Tags {fmt.Println("Tag: ",tag)}
out,err:=client.Models().GetTagModels(ctx)iferr!=nil {returnerr}for_,model:=rangeout.Models {fmt.Println("Model: ",model)}
Models accept specificinput fileMIME types. Some models may require multiple input file types to run data accordingly. In this sample, we use a model that requirestext/plain.
Models require inputs to have a specificinput name declared in the job request. This name can be found in the model’s details. In this sample, we use a model that requiresinput.txt.
Additionally, users can set their own input names. When multiple input items are processed in a job, these names are helpful to identify and get each input’s results. In this sample, we use a model that requiresinput-1 andinput-2.
out,err:=client.Models().GetModelDetails(ctx,&modzy.GetModelDetailsInput{ModelID:"ed542963de"})iferr!=nil {returnerr}fmt.Println("Model: ",out.Details)
Model specific sample requests are available in the version details and in the Model Details page.
out,err:=client.Models().GetModelVersionDetails(ctx,&modzy.GetModelVersionDetailsInput{ModelID:"ed542963de",Version:"0.0.27"})iferr!=nil {returnerr}// then you'll get all the details about the specific model versionfmt.Printf("ModelVersion Details %s\n",out.Details)// Probably the more interesting are the ones related with the inputs and outputs of the modelfmt.Println(" inputs:")for_,input:=rangeout.Details.Inputs {fmt.Printf(" key %s, type %s, description: %s\n",input.Name,input.AcceptedMediaTypes,input.Description )}fmt.Println(" outputs:")for_,output:=rangeout.Details.Outputs {fmt.Printf(" key %s, type %s, description: %s\n",output.Name,output.MediaType,output.Description )}
Ajob is the process that sends data to a model, sets the model to run the data, and returns results.
Modzy supports severalinput types such astext,embedded for Base64 strings,aws-s3 andaws-s3-folder for inputs hosted in buckets, andjdbc for inputs stored in databases. In this sample, we usetext.
Here are samples to submit jobs withembedded,aws-s3,aws-s3-folder, andjdbc input types.
Submit a job with the model, version, and input items:
submitResponse,err:=client.Jobs().SubmitJobText(ctx,&modzy.SubmitJobTextInput{ModelIdentifier:"ed542963de",ModelVersion:"0.0.27",Inputs:map[string]string{"my-input": {"input.txt":"Modzy is great!" } }})
Hold until the inference is complete and results become available:
jobDetails,err:=submitResponse.WaitForCompletion(ctx,20*time.Second)
Results are available per input item and can be identified with the name provided for each input item upon job request. You can also add an input name to the route and limit the results to any given input item.
Jobs requested for multiple input items may have partial results available prior to job completion.
results,err:=jobDetails.GetResults(ctx)
Errors may arise for different reasons. Fetch errors to know what is their cause and how to fix them.
| Error | Description |
|---|---|
ModzyHTTPError | Wrapper for different errors, check code, message, url attributes. |
Submitting jobs:
submitResponse,err:=client.Jobs().SubmitJobText(ctx,&modzy.SubmitJobTextInput{ModelIdentifier="ed542963de",ModelVersion="0.0.27",Inputs=map[string]string{"my-input": {"input.txt":"Modzy is great!"} }})iferr!=nil {log.Fatalf("The job submission fails with code %s and message %s",err.Status,err.Message)return}
Modzy supportsbatch processing,explainability, andmodel drift detection.
Here is a list of Modzy APIs. To see all the APIs, check ourDocumentation.
| Feature | Code | Api route |
|---|---|---|
| List models | client.Models().ListModels() | api/models |
| Get model details | client.Models().GetModelDetails() | api/models/:model-id |
| List models by name | client.Models().GetModelDetailsByName() | api/models |
| List models by tags | client.Models().GetTagsModels() | api/models/tags/:tag-id |
| Get related models | client.Models().GetRelatedModels() | api/models/:model-id/related-models |
| Get a model's versions | client.Models().ListModelVersions() | api/models/:model-id/versions |
| Get version details | client.Models().GetModelVersionsDetails() | api/models/:model-id/versions/:version-id |
| List tags | client.Models().ListTags() | api/models/tags |
| Submit a Job (Text) | client.Jobs().SubmitJobText() | api/jobs |
| Submit a Job (Embedded) | client.Jobs().SubmitJobEmbedded() | api/jobs |
| Submit a Job (AWS S3) | client.Jobs().SubmitJobS3() | api/jobs |
| Submit a Job (JDBC) | client.Jobs().SubmitJobJDBC() | api/jobs |
| Cancel a job | lient.Jobs().CancelJob() | api/jobs/:job-id |
| Hold until inference is complete | client.Jobs().WaitForJobCompletion() | api/jobs/:job-id |
| Get job details | client.Jobs().GetJobDetails() | api/jobs/:job-id |
| Get results | client.Jobs().getJobResults() | api/results/:job-id |
| List the job history | client.Jobs().GetJobsHistory() | api/jobs/history |
Check out oursamples for details on specific use cases.
To run samples:
Set the base url and api key in each sample file:
// TODO: set the base url of modzy api and you api keyclient:=modzy.NewClient("http://url.to.modzy/api").WithAPIKey("API Key")
Or follow the instructionshere to learn more.
And then, you can:
$ go run samples/models/main.go
We are happy to receive contributions from all of our users. Check out ourcontributing file to learn more.
About
The Golang library for Modzy Machine Learning Operations (MLOps) Platform
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.

