Coder Social home page Coder Social logo

azure / aml-deploy Goto Github PK

View Code? Open in Web Editor NEW
41.0 9.0 16.0 159 KB

GitHub Action that allows you to deploy machine learning models in Azure Machine Learning.

License: MIT License

Dockerfile 0.34% Shell 0.11% Python 99.56%
azure-machine-learning aml azure mlops machine-learning data-science

aml-deploy's Issues

Uncomplete sentence in patterns

@marvinbuss the syntax {"IS_SENT_START": False, "OP": "*"} works only for words that come before the word in the pattern right? what about the sentences where we can't make any assumptions about how the sentence will end but still want to match as soon as the sentence starts with a certain set of words. One example: "I thought I share our newest features with you" Now the Words we match is "I thought" and "our". Now do I need to add something to make sure it matches even though there are words coming after the words in pattern3?

` def _you_centered21(
self,
rule_id="R0061",
description="Put your recipient in the center of your sentence. Simply replace the I focused sentence with a You focused one.That's how you catch their attention.",
info="Try to be very precise on what you want and use the present form if possible.",
example_pos="You can find a guide on how you can benefit from the most recent product update attached.",
example_neg="I thought I share our newest features with you"
) -> None:
""" Check for negative and positive tone.

    rule_id (str): The ID of the rule.
    description (str): The description of the rule.
    info (str): Additional info about the rule.
    example_pos (str): Positive example for this rule.
    example_neg (str): Negative example for this rule.
    """
    # Define matcher
    matcher = Matcher(self.nlp.vocab)

    # Define patterns to match
    pattern1 = [
        {"LOWER": "I"}
    ]

    pattern2 = [
        {"LOWER": "thought"}
    ]

    pattern3 = [
        {"LOWER": "our"} ,{"IS_SENT_START": False, "OP": "*"}
    ]


    # Add the patterns to the matcher and apply the matcher to the doc
    matcher.add("positivetone_pattern", [pattern1, pattern2, pattern3])
    matches = matcher(self.doc)

    # Merge the matched intervals
    intervals = [(start, end) for match_id, start, end in matches]
    merged = merge_intervals(intervals)

    # Add recommendations
    if len(merged) > 0:
        self._add_recommendation(
            rule_id=rule_id,
            description=description,
            info=info,
            example_pos=example_pos,
            example_neg=example_neg,
            token_intervals=merged
        )`

Can not load the model in score.py

Hi,

I have a registered model that I want to deploy, but when trying to load it with:

in score.py:

import tensorflow.keras.models import load_model
model_path = os.path.join(os.getenv("AZUREML_MODEL_DIR"), 
                            "outputs", "best_model")
model = load_model(model_path)

I get the error that saved_model.pb is not found in the folder. If you look in registered model/Artifacts/ the file saved_model.pb exists

raise IOError("SavedModel file does not exist at: %s/{%s|%s}" %
OSError: SavedModel file does not exist at: /var/azureml-app/azureml-models/p8_model/27/outputs/best_model/{saved_model.pbtxt|saved_model.pb}

What can be the issue here?

I just realized that azureml copies the model folder hierarchy inconsistently from one deploy to another. How to know in what folder the final model will be? (For one deploy it was outputs/best_model, for another it was without outputs folder)

Regards,
Voka

Single word functions valid?

Hi @marvinbuss , I noticed there are functions with single words ergo only one pattern. Will the model detect sentences with the words or does the function only work when there are sentences with one word. I inserted a function for you to check.

` def _positive_word08(
self,
rule_id="R0079",
description="The word ""But"" implies a conflict. It will subconsciously affect your recipient. To make sure you keep it positive use a stronger, more confident word if possible. ",
info="Try to be very precise on what you want and use the present form if possible.",
example_pos="And",
example_neg="But"
) -> None:
""" Check for negative and positive tone.

    rule_id (str): The ID of the rule.
    description (str): The description of the rule.
    info (str): Additional info about the rule.
    example_pos (str): Positive example for this rule.
    example_neg (str): Negative example for this rule.
    """
    # Define matcher
    matcher = Matcher(self.nlp.vocab)

    # Define patterns to match
    pattern1 = [
        {"LOWER": "But"}
    ]


    # Add the patterns to the matcher and apply the matcher to the doc
    matcher.add("positivetone_pattern", [pattern1])
    matches = matcher(self.doc)

    # Merge the matched intervals
    intervals = [(start, end) for match_id, start, end in matches]
    merged = merge_intervals(intervals)

    # Add recommendations
    if len(merged) > 0:
        self._add_recommendation(
            rule_id=rule_id,
            description=description,
            info=info,
            example_pos=example_pos,
            example_neg=example_neg,
            token_intervals=merged
        )` @

Pass list as input to action

The user must be able to pass a list for the following input values:

  • model_name
  • model_version
    This is required to deploy multiple models to one container.

docker image created is not directly consumable

the docker image creation option is available but once image is created and pushed into the container registry, if you try to deploy the image, it does not work, reason is image is just the model package image and does not contain the web server code which comes from mcr.microsoft.com/azureml/aci-init-container
and mcr.microsoft.com/azureml-aci-frontend container.
these containers are deployed along with model package by Azure ML when ACI deployment is selected. It also requires a lot of environment params written by Azure ml

now user can not use currently available actions to deploy this image, because those all details are hidden.

can we provide a mechanism for user to deploy these images?

Could not load model with provided details

Hi,

I am encountering the below error when I am trying to deploy a model in ACI.

Traceback (most recent call last):
  File "/code/main.py", line 318, in <module>
    main()
  File "/code/main.py", line 129, in main
    raise AMLConfigurationException(f"Could not load model with provided details: ***exception***")
utils.AMLConfigurationException: Could not load model with provided details: WebserviceException:
	Message: ModelNotFound: Model with name porto_seguro_safe_driver_model, version 14 not found in provided workspace
	InnerException None
	ErrorResponse 
***
    "error": ***
        "message": "ModelNotFound: Model with name porto_seguro_safe_driver_model, version 14 not found in provided workspace"
    ***
***

Here is my GitHub Action yaml.

      - name: Deploy Model to ACI
        id: deploy_aci
        uses: Azure/aml-deploy@v1
        with:
          azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
          model_name:  "${{ env.MODEL_NAME }}"
          model_version: "${{ env.MODEL_VERSION }}"
          parameters_file: "deploy_aci.json"

I verified that I have these models in my AML.

ka@Azure:~$ az ml model list -o table
Name                            Version    Framework    CreatedTime
------------------------------  ---------  -----------  -------------------
porto_seguro_safe_driver_model  14         Custom       2020-11-20T15:16:19
porto_seguro_safe_driver_model  13         Custom       2020-11-19T17:25:36
porto_seguro_safe_driver_model  12         Custom       2020-11-19T16:39:02
porto_seguro_safe_driver_model  11         Custom       2020-11-19T16:15:37
porto_seguro_safe_driver_model  10         Custom       2020-09-18T17:25:55
porto_seguro_safe_driver_model  9          Custom       2020-09-04T15:55:04
porto_seguro_safe_driver_model  8          Custom       2020-09-03T22:40:08
porto_seguro_safe_driver_model  7          Custom       2020-09-03T21:47:30
porto_seguro_safe_driver_model  6          Custom       2020-09-03T16:11:49
porto_seguro_safe_driver_model  5          Custom       2020-09-03T14:08:11
porto_seguro_safe_driver_model  4          Custom       2020-08-28T21:22:35
porto_seguro_safe_driver_model  3          Custom       2020-08-28T20:38:17
driver_model.pkl                2          Custom       2020-08-28T20:17:31
porto_seguro_safe_driver_model  2          Custom       2020-08-25T02:49:24
porto_seguro_safe_driver_model  1          Custom       2020-08-25T02:21:00
driver_model.pkl                1          Custom       2020-08-19T18:04:23

Any suggestion on how I should go about this error?

Response Code: 502 - Content: b"'str' object has no attribute 'tolist'"

when i tried running this code i got this error, kindly assist on it
import json

input_payload = json.dumps({
'data': [[34.927778, 0.24, 7.3899, 83, 16.1000, 1016.51, 1]],
'method': 'predict' # If you have a classification model, you can get probabilities by changing this to 'predict_proba'.
})

output = service.run(input_payload)

print(output)

error :

Received bad response from service. More information can be found by calling .get_logs() on the webservice object.
Response Code: 502
Headers: {'Connection': 'keep-alive', 'Content-Length': '38', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Tue, 26 Apr 2022 05:35:50 GMT', 'Server': 'nginx/1.10.3 (Ubuntu)', 'X-Ms-Request-Id': 'd84f9266-f41c-4587-a3e9-56b482cccc80', 'X-Ms-Run-Function-Failed': 'True'}
Content: b"'str' object has no attribute 'tolist'"


WebserviceException Traceback (most recent call last)
in
7 })
8
----> 9 output = service.run(input_payload)
10
11 print(output)

/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azureml/core/webservice/aci.py in run(self, input_data)
398 return resp.json()
399 else:
--> 400 raise WebserviceException('Received bad response from service. More information can be found by calling '
401 '.get_logs() on the webservice object.\n'
402 'Response Code: {}\n'

WebserviceException: WebserviceException:
Message: Received bad response from service. More information can be found by calling .get_logs() on the webservice object.
Response Code: 502
Headers: {'Connection': 'keep-alive', 'Content-Length': '38', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Tue, 26 Apr 2022 05:35:50 GMT', 'Server': 'nginx/1.10.3 (Ubuntu)', 'X-Ms-Request-Id': 'd84f9266-f41c-4587-a3e9-56b482cccc80', 'X-Ms-Run-Function-Failed': 'True'}
Content: b"'str' object has no attribute 'tolist'"
InnerException None
ErrorResponse
{
"error": {
"message": "Received bad response from service. More information can be found by calling .get_logs() on the webservice object.\nResponse Code: 502\nHeaders: {'Connection': 'keep-alive', 'Content-Length': '38', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Tue, 26 Apr 2022 05:35:50 GMT', 'Server': 'nginx/1.10.3 (Ubuntu)', 'X-Ms-Request-Id': 'd84f9266-f41c-4587-a3e9-56b482cccc80', 'X-Ms-Run-Function-Failed': 'True'}\nContent: b"'str' object has no attribute 'tolist'""
}
}

Handling service name exception internally

is user gives service name as which does not confirm to Azure restrictions for naming. Should we make the whole name as lowercase?

##[error]Model deployment failed with exception: WebserviceException:
Message: Error, provided service name is invalid. It must only consist of lowercase letters, numbers, or dashes, start with a
letter, end with a letter or number, and be between 3 and 32 characters long.
InnerException None
ErrorResponse


"error": ***
    "message": "Error, provided service name is invalid. It must only consist of lowercase letters, numbers, or dashes, start with a letter, end with a letter or number, and be between 3 and 32 characters long."
***

input given : "testACIService"

Bug in AML Python SDK leads to problems in creating images in AML related ACR

This is in relation to #6 & #8
With the creation of an image into the AML Workspace related ACR, multiple Repos per image per aml-deploy call will be created.
It seems, that calling Model.package(...) is the core reason. (create_image related)
Maybe you could state this somewhere in the documentation or implement a workaround if there is low effort.
Here an example of my ACR repo list:
azureml-repos-failure

SSLError: HTTPSConnectionPool when registering ML model on Azure

Hi Everyone,

Please I have my Databricks instance in a VNET. I’m trying to deploy my Machine learning model using the Azure ML workspace on Azure Container Instance (ACI).

I’m able to create an ML workspace. I get an SSLERROR when I try to register the Model using Model.register().

Using this code -

`from azureml.core import Workspace
from azureml.core.model import Model
import azureml.core
from azureml.core.workspace import Workspace
from azureml.core.model import Model

from azureml.core import Workspace
ws = Workspace.create(name='myworkspace',
subscription_id='mysub_id',
resource_group='myresourcegroup',
location='eastus'
)

model_reg = Model.register(model_path = “./model_dir”,
model_name = "ModelX",
workspace = ws)
`

Find below the error when I try to deploy my model.

SSL Error:
SSLError: HTTPSConnectionPool(host='eastus.experiments.azureml.net', port=443): Max retries exceeded with url: /discovery (Caused by SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')")))
Please note only the Azure Databricks is in a VNET on Azure. How do I resolve it and deploy my model as a webservice on ACI.

Thank you.

Add model profiling as feature

Model profiling would be a nice feature to add. Alternatively, we could create a new Action for this feature to simplify the Action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.