===========
Deployments
===========

Deployments are methods for sharing parts of your data science projects and machine learning models with other users. You can create deployments for microservices such as interactive dashboard visualizations, web applications, REST APIs, or Jupyter Notebooks. 

When you deploy a project, Data Science & AI Workbench finds and builds all of the software dependencies (the packages and libraries the project needs to operate properly) and encapsulates them into a self-contained artifact. 

You can create multiple deployments from a single project. Each deployment can be a different version and can be :doc:`shared with others <share>`. 

Deployment commands
===================

Deployments are defined as commands in your ``anaconda-project.yml`` file. Each project in Workbench can define any number of deployable commands. See :ref:`Adding deployment commands to a project <add-deploy-command>` for more information.

Viewing all deployments
=======================

Select |chart-network| **Deployments** from the left-hand navigation to view a list of deployments across all projects you own or that have been shared with you.

.. thumbnail:: ../../images/ae5_view_all_deployments.png
   :align: center

Viewing a project's deployments
===============================

To view the deployments specific to a project:

#. From the |file-code| **Projects** page select your project.
#. Select |chart-network| **Deployments** from the left-hand navigation.

.. _deploy_project:

Deploying a project
===================

Deployments are run independently of development sessions for projects, and can be deployed to different hardware resource profiles.

#. From the |file-code| **Projects** page, select the project you want to deploy.
#. Select |chart-network| **Deployments** from the left-hand menu.
#. Click **Deploy**. 
#. Enter a name for your deployment. 
#. Select a resource profile to run your deployment. 

   .. note:: 
      
      The configurations present in this dropdown are controlled by your Administrator. Check with them if you are unsure which profile to choose. 

#. Select the project version associated with the deployment command you are running. 
#. Select a deployment command. 

   .. caution:: 
      
      If there is no deployment command listed, you cannot deploy your project. 

#. Set the URL for your deployment.

   .. note:: 
      
      This is the URL you'll use to access your deployment from a web browser, and therefore *it must be unique*. Toggle **Static URL** ``OFF`` if you want Workbench to automatically generate a URL for your deployment. 

#. Share your deployment with any other users or groups. 
#. Set your deployment to private or public access:
 
   Private access
      Restricts access to authenticated platform users only. Private deployments display a |lock| lock to indicate their secure status. 
   Public access
      Opens access to non-authenticated users. 

#. Click **Deploy**.

    .. note::
    
        It can take several minutes to obtain and build all the dependencies for the project deployment. 

You can also schedule a project to be deployed on a regular basis or at a specific time. For more information, see :doc:`Schedules </data-science-workflows/schedules>`.

Interacting with deployments
============================

To interact with your deployment, select it from the list of project deployments, or navigate to its URL in a web browser.

.. thumbnail:: ../../images/ae5_deployment_interact.png
   :align: center

.. _terminate_deployment:

Terminating a deployment
========================

Deployments that are no longer needed should be terminated to remove them from the server and free up cluster resources. Terminating a deployment does not affect the project that was used to create the deployment. 

.. caution:: 

    Terminating a deployment makes it unavailable to :doc:`any users you shared it with <share>`. 

To terminate a deployment:

#. From the |file-code| **Projects** page, select |chart-network| **Deployments** from the left-hand navigation.
#. Select the deployment you want to terminate.
#. Click |stop| **Stop deployment** at the top of the page. 
#. Click **Terminate** to confirm that you want to terminate the deployment.

.. note:: 

    You can also terminate a deployment from its |gears| **Settings** page. 

.. toctree::
   :maxdepth: 1
   :hidden:

   rest-api
   deploy-flask
   share
   deployment-logs
   
.. |chart-network| raw:: html
   
   <i class="fa-light fa-chart-network"></i>

.. |lock| raw:: html

	<i class="fa-solid fa-lock"></i>

.. |file-code| raw:: html

   <svg class="inline" height="1.2em" width="1.2em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M64 496c-26.5 0-48-21.5-48-48V64c0-26.5 21.5-48 48-48H204.1c1.3 0 2.6 .1 3.9 .2V136c0 22.1 17.9 40 40 40H367.8c.2 1.3 .2 2.6 .2 3.9V448c0 26.5-21.5 48-48 48H64zM358.6 157.3c.9 .9 1.7 1.8 2.4 2.7H248c-13.3 0-24-10.7-24-24V22.9c1 .8 1.9 1.6 2.7 2.4L358.6 157.3zM64 0C28.7 0 0 28.7 0 64V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V179.9c0-12.7-5.1-24.9-14.1-33.9L238.1 14.1c-9-9-21.2-14.1-33.9-14.1H64zm85.7 269.7c3.1-3.1 3.1-8.2 0-11.3s-8.2-3.1-11.3 0l-56 56c-3.1 3.1-3.1 8.2 0 11.3l56 56c3.1 3.1 8.2 3.1 11.3 0s3.1-8.2 0-11.3L99.3 320l50.3-50.3zm96-11.3c-3.1-3.1-8.2-3.1-11.3 0s-3.1 8.2 0 11.3L284.7 320l-50.3 50.3c-3.1 3.1-3.1 8.2 0 11.3s8.2 3.1 11.3 0l56-56c3.1-3.1 3.1-8.2 0-11.3l-56-56z"/></svg>

.. |stop| raw:: html

   <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128z"/></svg>

.. |gears| raw:: html

   <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M146.2 40.7l-6.9 25.1c-1.4 5.2-5.4 9.4-10.6 11c-14.6 4.6-27.9 12.4-39 22.5c-4 3.7-9.6 5.1-14.9 3.7L49.7 96.4c-2.2 3.1-4.3 6.3-6.3 9.6l-2.4 4.2c-1.8 3.3-3.5 6.6-5 10l18.3 18.5c3.8 3.9 5.4 9.4 4.2 14.7C56.8 160.7 56 168.2 56 176s.8 15.3 2.4 22.5c1.2 5.3-.4 10.8-4.2 14.7L35.9 231.8c1.5 3.4 3.2 6.7 5 10l2.5 4.3c2 3.3 4.1 6.5 6.3 9.6L74.9 249c5.3-1.4 10.9 0 14.9 3.7c11.1 10.2 24.3 17.9 39 22.5c5.2 1.6 9.2 5.8 10.6 11l6.9 25.1c4.5 .5 9.1 .7 13.8 .7s9.2-.2 13.8-.7l6.9-25.1c1.4-5.2 5.4-9.4 10.6-11c14.6-4.6 27.9-12.4 39-22.5c4-3.7 9.6-5.1 14.9-3.7l25.2 6.6c2.2-3 4.2-6.1 6.1-9.3l2.8-4.8c1.7-3.2 3.4-6.4 4.8-9.7l-18.3-18.5c-3.8-3.9-5.4-9.4-4.2-14.7c1.6-7.2 2.4-14.8 2.4-22.6s-.8-15.3-2.4-22.6c-1.2-5.3 .4-10.8 4.2-14.7l18.3-18.5c-1.5-3.3-3.1-6.5-4.8-9.7l-2.8-4.8c-1.9-3.2-4-6.3-6.1-9.3L245.1 103c-5.3 1.4-10.9 0-14.9-3.7c-11.1-10.2-24.3-17.9-39-22.5c-5.2-1.6-9.2-5.8-10.6-11l-6.9-25.1c-4.5-.5-9.1-.7-13.8-.7s-9.2 .2-13.8 .7zM130.8 10.5C140.3 8.9 150.1 8 160 8s19.7 .9 29.1 2.5c6.1 1.1 11 5.6 12.7 11.5l7.5 27.2c13.1 5.1 25.1 12.1 35.9 20.7l27.3-7.1c6-1.6 12.3 .5 16.3 5.2c5.6 6.7 10.7 13.8 15.2 21.3l.2 .3 0 0 2.9 5.1 .2 .3 0 0c4.1 7.5 7.7 15.4 10.7 23.6c2.1 5.8 .7 12.3-3.6 16.7l-19.8 20.1c1 6.8 1.6 13.7 1.6 20.7s-.5 13.9-1.6 20.7l19.8 20.1c4.3 4.4 5.8 10.9 3.6 16.7c-3 8.2-6.6 16-10.7 23.6l-.2 .3 0 0-3 5.1-.2 .3 0 0c-4.5 7.5-9.6 14.6-15.2 21.3c-4 4.7-10.3 6.8-16.3 5.2l-27.3-7.1c-10.7 8.6-22.8 15.6-35.8 20.7L201.8 330c-1.6 6-6.6 10.5-12.7 11.5c-9.5 1.7-19.2 2.5-29.1 2.5s-19.7-.9-29.2-2.5c-6.1-1.1-11-5.6-12.7-11.5l-7.5-27.2c-13.1-5.1-25.1-12.1-35.8-20.7l-27.3 7.1c-6 1.6-12.3-.5-16.3-5.2c-5.7-6.8-10.9-14-15.4-21.6l-.1-.2 0 0-2.6-4.5-.1-.2 0 0c-4.2-7.6-7.9-15.6-10.9-23.9c-2.1-5.8-.7-12.3 3.6-16.7l19.8-20.1C24.5 189.9 24 183 24 176s.5-13.9 1.6-20.7L5.7 135.2c-4.3-4.4-5.8-10.9-3.6-16.7c3-8.3 6.7-16.3 10.9-23.9l.1-.2 0 0 2.6-4.5 .1-.2 0 0C20.4 82 25.6 74.8 31.3 68c4-4.7 10.3-6.8 16.3-5.2l27.3 7.1c10.7-8.6 22.8-15.6 35.8-20.7L118.2 22c1.6-6 6.6-10.5 12.7-11.5zM104 176a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm56 24a24 24 0 1 0 0-48 24 24 0 1 0 0 48zM328.7 365.8l25.1 6.9c5.2 1.4 9.4 5.4 11 10.6c4.6 14.6 12.4 27.9 22.5 39c3.7 4 5.1 9.6 3.7 14.9l-6.6 25.2c3.1 2.2 6.3 4.3 9.6 6.3l4.2 2.4c3.3 1.8 6.6 3.5 10 5l18.5-18.3c3.9-3.8 9.4-5.4 14.7-4.2c7.2 1.6 14.8 2.4 22.5 2.4s15.3-.8 22.5-2.4c5.3-1.2 10.8 .4 14.7 4.2l18.5 18.3c3.4-1.5 6.7-3.2 10-5l4.3-2.5c3.3-2 6.5-4.1 9.6-6.3L537 437.1c-1.4-5.3 0-10.9 3.7-14.9c10.2-11.1 17.9-24.3 22.5-39c1.6-5.2 5.8-9.2 11-10.6l25.1-6.9c.5-4.5 .7-9.1 .7-13.8s-.2-9.2-.7-13.8l-25.1-6.9c-5.2-1.4-9.4-5.4-11-10.6c-4.6-14.7-12.4-27.9-22.5-39c-3.7-4-5.1-9.6-3.7-14.9l6.6-25.2c-3-2.2-6.1-4.2-9.3-6.1l-4.8-2.8c-3.2-1.7-6.4-3.4-9.7-4.8l-18.5 18.3c-3.9 3.8-9.4 5.4-14.7 4.2c-7.2-1.6-14.8-2.4-22.6-2.4s-15.3 .8-22.6 2.4c-5.3 1.2-10.8-.4-14.7-4.2l-18.5-18.3c-3.3 1.5-6.5 3.1-9.7 4.8l-4.8 2.8c-3.2 1.9-6.3 4-9.3 6.1l6.6 25.2c1.4 5.3 0 10.9-3.7 14.9c-10.2 11.1-17.9 24.3-22.5 39c-1.6 5.2-5.8 9.2-11 10.6l-25.1 6.9c-.5 4.5-.7 9.1-.7 13.8s.2 9.2 .7 13.8zm-30.2 15.4c-1.7-9.5-2.5-19.2-2.5-29.2s.9-19.7 2.5-29.1c1.1-6.1 5.6-11 11.5-12.7l27.2-7.5c5.1-13.1 12.1-25.1 20.7-35.9l-7.1-27.3c-1.6-6 .5-12.3 5.2-16.3c6.7-5.6 13.8-10.7 21.3-15.2l.3-.2 0 0 5.1-2.9 .3-.2 0 0c7.5-4.1 15.4-7.7 23.6-10.7c5.8-2.1 12.3-.7 16.7 3.6l20.1 19.8c6.8-1 13.7-1.6 20.7-1.6s13.9 .5 20.7 1.6l20.1-19.8c4.4-4.3 10.9-5.8 16.7-3.6c8.2 3 16 6.6 23.6 10.7l.3 .2 0 0 5.1 3 .3 .2 0 0c7.5 4.5 14.6 9.6 21.3 15.2c4.7 4 6.7 10.3 5.2 16.3l-7.1 27.3c8.6 10.7 15.6 22.8 20.7 35.8l27.2 7.5c6 1.6 10.5 6.6 11.5 12.7c1.7 9.5 2.5 19.2 2.5 29.1s-.9 19.7-2.5 29.2c-1.1 6.1-5.6 11-11.5 12.7l-27.2 7.5c-5.1 13.1-12.1 25.1-20.7 35.8l7.1 27.3c1.6 6-.5 12.3-5.2 16.3c-6.8 5.7-14 10.9-21.6 15.4l-.2 .1 0 0-4.5 2.6-.2 .1 0 0c-7.6 4.2-15.6 7.9-23.9 10.9c-5.8 2.1-12.3 .7-16.7-3.6l-20.1-19.8c-6.8 1-13.7 1.6-20.7 1.6s-13.9-.5-20.7-1.6l-20.1 19.8c-4.4 4.3-10.9 5.8-16.7 3.6c-8.3-3-16.3-6.7-23.9-10.9l-.2-.1 0 0-4.5-2.6-.2-.1 0 0c-7.6-4.6-14.9-9.8-21.6-15.4c-4.7-4-6.8-10.3-5.2-16.3l7.1-27.3c-8.6-10.7-15.6-22.8-20.7-35.8L310 393.8c-6-1.6-10.5-6.6-11.5-12.7zM464 408a56 56 0 1 1 0-112 56 56 0 1 1 0 112zm24-56a24 24 0 1 0 -48 0 24 24 0 1 0 48 0z"/></svg>