=========
Schedules
=========

If you have a project that requires regular updates for tasks (such as data processing or monthly/weekly reports) or a model that needs to be retrained on updated data sources at regular intervals, Data Science & AI Workbench enables you to schedule your deployments to automate project executions. Strategically scheduling deployments minimizes manual intervention and can reduce system load during peak hours, maintaining optimal performance for your cluster. 

.. note::

    Scheduled tasks can read data previously committed to a project, but cannot be used to commit any new data to the project. Any data written to a scheduled deployment's container is deleted immediately after the scheduled task completes. Anaconda recommends you ensure data is read from and written to an :doc:`external data source <data/load>`. 

Scheduling a deployment
=======================

#. From the |file-code| **Projects** page, open the project you want to schedule a deployment for.
#. Select |calendar-light| **Schedules** from the project's left-hand navigation.
#. Click **Schedule**. 
#. Complete the **Create a Schedule** form: 

    #. Enter a name for your schedule that clearly establishes its purpose.
    #. Specify whether you want to deploy the latest version of the project, or select a particular version.
    #. Select a deployment command. 
    
        .. note:: 
            
            * Because schedules are intended for automatic or non-interactive execution of script files or notebooks, only ``unix:`` commands are supported.
            * If there is no command listed, you cannot schedule a deployment.

    #. Select a resource profile for the deployment to use. 
    #. Set the frequency for your scheduled deployment to occur. 
    
        .. tip:: 
            
            * You can use the interface to determine when you want to schedule the deployment frequency, or select *Custom* and enter a valid `cron expression <https://crontab.guru/>`_.
            * If you need to deploy right away—without creating a schedule—select *Run Now*.

    #. Select a timezone for your scheduled deployment. 
    #. Click **Schedule** / **Run Now**. 

Viewing schedule details
========================

#. From the |file-code| **Projects** page, select |calendar-light| **Schedules** from the left-hand navigation.
#. Click on a schedule in the list to view its details. 

From here you can see previous |bike| :ref:`Runs <runs>` of a scheduled task or :ref:`manage the schedule <manage_schedule>`.

.. _manage_schedule:
 
Managing a schedule
===================

From a schedule's details view, you can use the controls at the top of the page to |pause| pause or |play| resume, |edit| edit, or |trash| delete a selected schedule.

.. note::
    
    If you attempt to delete a schedule that is currently running or is scheduled to run, you will be prompted to confirm that you want to force the deletion.

.. _runs:

Runs
====

Each time a scheduled task is executed, its run is automatically logged. You can view all runs associated with a schedule in its details view. Selecting a specific run from the list displays the corresponding log for that execution.

.. tip:: 
    
    * If something went wrong with your deployment, the runs log can be a helpful tool in troubleshooting the issue. 
    * Selecting a run opens the *Project's* |bike| **Runs** view. 
 
.. |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>

.. |calendar-light| raw:: html 

   <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M112 0c8.8 0 16 7.2 16 16V64H320V16c0-8.8 7.2-16 16-16s16 7.2 16 16V64h32c35.3 0 64 28.7 64 64v32 32V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192 160 128C0 92.7 28.7 64 64 64H96V16c0-8.8 7.2-16 16-16zM416 192H32V448c0 17.7 14.3 32 32 32H384c17.7 0 32-14.3 32-32V192zM384 96H64c-17.7 0-32 14.3-32 32v32H416V128c0-17.7-14.3-32-32-32z"/></svg>

.. |pause| raw:: html 

    <svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 512 512"><path d="M480 256A224 224 0 1 0 32 256a224 224 0 1 0 448 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm224-80V336c0 8.8-7.2 16-16 16s-16-7.2-16-16V176c0-8.8 7.2-16 16-16s16 7.2 16 16zm96 0V336c0 8.8-7.2 16-16 16s-16-7.2-16-16V176c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>

.. |edit| raw:: html 

    <svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 512 512"><path d="M395 25.9c12.5-12.5 32.8-12.5 45.3 0l45.8 45.8c12.5 12.5 12.5 32.8 0 45.3l-66.9 66.9L328.1 92.8 395 25.9zm-78.2 78.2l91.1 91.1L164.7 438.4c-1.5 1.5-3.1 3-4.7 4.4V408c0-4.4-3.6-8-8-8H112V360c0-4.4-3.6-8-8-8H69.2c1.4-1.6 2.9-3.2 4.4-4.7L316.8 104.1zM51.4 384.7c1.7-5.8 4-11.4 6.8-16.7H96v40c0 4.4 3.6 8 8 8h40v37.7c-5.3 2.8-10.9 5.1-16.7 6.8L19.8 492.2 51.4 384.7zm400.1-370c-18.7-18.7-49.1-18.7-67.9 0L62.3 336C50 348.3 41 363.5 36.1 380.2L.3 501.7c-.8 2.8-.1 5.8 2 7.9s5.1 2.8 7.9 2l121.6-35.8c16.7-4.9 31.9-13.9 44.2-26.2L497.4 128.3c18.7-18.7 18.7-49.1 0-67.9L451.5 14.6zM317.7 173.1c3.1-3.1 3.1-8.2 0-11.3s-8.2-3.1-11.3 0l-144 144c-3.1 3.1-3.1 8.2 0 11.3s8.2 3.1 11.3 0l144-144z"/></svg>

.. |trash| raw:: html 

    <svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 448 512"><path d="M177.7 32h92.5c5.5 0 10.6 2.8 13.6 7.5L299.1 64H148.9l15.3-24.5c2.9-4.7 8.1-7.5 13.6-7.5zM336.9 64L311 22.6C302.2 8.5 286.8 0 270.3 0H177.7C161.2 0 145.8 8.5 137 22.6L111.1 64H64.1 32 16C7.2 64 0 71.2 0 80s7.2 16 16 16H34.3L59.8 452.6C62.1 486.1 90 512 123.6 512H324.4c33.6 0 61.4-25.9 63.8-59.4L413.7 96H432c8.8 0 16-7.2 16-16s-7.2-16-16-16H416 383.9 336.9zm44.8 32L356.3 450.3C355.1 467 341.2 480 324.4 480H123.6c-16.8 0-30.7-13-31.9-29.7L66.4 96H381.6z"/></svg>

.. |bike| raw:: html

    <svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 640 512"><path d="M411.8 96H480V64H453.4L411.8 96zM488 128H412.2L467 232.1c14-5.3 29.2-8.1 45-8.1c70.7 0 128 57.3 128 128s-57.3 128-128 128s-128-57.3-128-128c0-43.4 21.6-81.8 54.7-104.9l-15-28.5C380.5 247.2 352 296.3 352 352v16c0 8.8-7.2 16-16 16H304c-8.8 0-16-7.2-16-16v-8c0-92.8-75.2-168-168-168H48c-8.8 0-16-7.2-16-16s7.2-16 16-16h72c41.4 0 79.9 12.6 111.8 34.1l127.4-98L342.3 64H272c-8.8 0-16-7.2-16-16s7.2-16 16-16h70.3c11.9 0 22.8 6.6 28.3 17.1L385 76.3 436.1 37c4.2-3.2 9.3-5 14.6-5H488c13.3 0 24 10.7 24 24v48c0 13.3-10.7 24-24 24zM257.5 214.7c36.7 34.7 60.2 83.3 62.4 137.3h.2c0-68 35.4-127.8 88.7-161.9l-34.4-65.3L257.5 214.7zM497.8 359.5l-44.1-83.8c-23 17.5-37.8 45.2-37.8 76.3c0 53 43 96 96 96s96-43 96-96s-43-96-96-96c-10.5 0-20.5 1.7-29.9 4.8l44.1 83.8c4.1 7.8 1.1 17.5-6.7 21.6s-17.5 1.1-21.6-6.7zM128 256c-53 0-96 43-96 96s43 96 96 96c47.6 0 87.1-34.6 94.7-80h-67c-5.5 9.6-15.9 16-27.7 16c-17.7 0-32-14.3-32-32s14.3-32 32-32c11.8 0 22.2 6.4 27.7 16h67c-7.6-45.4-47.1-80-94.7-80zM0 352a128 128 0 1 1 256 0A128 128 0 1 1 0 352z"/></svg>

.. |play| raw:: html

    <svg xmlns="http://www.w3.org/2000/svg" height="1.2em" width="1.2em" viewBox="0 0 512 512"><path d="M256 16a240 240 0 1 1 0 480 240 240 0 1 1 0-480zm0 496A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM196.1 161c2.5-1.4 5.6-1.4 8.1 .2l144 88c2.4 1.5 3.8 4 3.8 6.8s-1.4 5.4-3.8 6.8l-144 88c-2.5 1.5-5.6 1.6-8.1 .2s-4.1-4.1-4.1-7V168c0-2.9 1.6-5.6 4.1-7zm16.4-13.5c-7.4-4.5-16.7-4.7-24.3-.5s-12.3 12.3-12.3 20.9V344c0 8.7 4.7 16.7 12.3 20.9s16.8 4.1 24.3-.5l144-88c7.1-4.4 11.5-12.1 11.5-20.5s-4.4-16.1-11.5-20.5l-144-88z"/></svg>