Search code examples
nuclio

How do I deploy a Nuclio function with MLRun?


I need an example of deploying a Nuclio function using MLRun.

  • I have my code in a .py file
  • How do I use MLRun to deploy this function to Nuclio?
  • How do I configure the HTTP endpoint? (using a specified port)

Solution

  • You should follow these steps:

    1. Call to code_to_function as in this example:
    fn = code_to_function(name='data-generator', handler='main', kind='job', filename='functions/code.py')
    
    1. Invoke with_http on the function:
    fn.with_http(host='URL_path', port=port_number)
    
    1. Deploy the function:
    fn.deploy()