====================================
Project reproducibility in Workbench
====================================

Why do I need to worry about project reproducibility?
=====================================================

Project reproducibility ensures that your work retains its integrity and utility over time and across different environments. This guarantees that your code will consistently produce the same results, or continue to operate as intended, regardless of where it is run. If you do not ensure that your project is reproducible, you risk having code that could suddenly stop functioning in the future due to changes in the project's software environment.

How can I achieve project reproducibility?
==========================================

While software tools can aid in project reproducibility, the only way to ensure complete project reproducibility is by encouraging users to adhere to the best practices described here at an organizational level. 

Using ``anaconda-project`` for basic reproducibility:
-----------------------------------------------------

The most reliable way to ensure your project remains reproducible indefinitely is to utilize the ``anaconda-project lock`` command to create a fully specified environment; one that has all packages used in the project and their dependencies locked to a specific version. This ensures that your project will be reproduced exactly as it was initially configured, because there will never be an unexpected update or change if new package dependencies are released. For more information about the ``anaconda-project-lock.yml`` file, see the official `Anaconda Project documentation <https://anaconda-project.readthedocs.io/en/latest/user-guide/reference.html#anaconda-project-yml-anaconda-project-local-yml-anaconda-project-lock-yml>`_.  

Project locking is not automatically enforced because it is a time-consuming process and isn't necessary when running development instances of the deployment. Therefore, it is up to the user to perform the locking procedure.

.. tip::
    
    Run the ``anaconda-project lock`` command when you have finalized work on a project, or if you are ready to move a specific version of your project to a production environment (i.e. you are ready for your project to be interacted with or used publicly). 

.. _environment_reproducibility:

Managing environments for reproducibility
-----------------------------------------

While locking your project is essential, it is ultimately the responsibility of the user to create and commit the lock file to the project. Furthermore, ``anaconda-project`` will run a “solve” (i.e. a resolution of dependencies) every time the project deploys, which can introduce potential issues for project reproducibility if the conda solver version has changed. 

With Workbench versions 5.5 and newer, administrators can create and distribute pre-solved “persistent environments” to their users. These environments are like preconfigured workspaces set up by an administrator that have all the necessary tools and software already in place so their team can work without needing to make changes to the environment.

Because these environments are pre-solved and fixed, they don't require a new solve with each deployment. This means deployments from these environments are created more quickly, and guarantee that your project will run as expected every time, regardless of any external changes such as updates to the conda resolver itself.

For instructions on configuring persistent environments and supplying them to your users, see :doc:`Configuring persistent environments and sample projects <../admin/custom_env_proj>`.

Best practices for managing environments for reproducibility:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

|clipboard-list-check| **Create comprehensive environments** - Ensure that every managed environment is set up with all necessary libraries and packages that users might need for their work, including proprietary or internal packages unique to your organization. This will allow users to perform their tasks without needing to modify the environment. 

|pen-slash| **Avoid unnecessary modifications** - Encourage users to avoid independently modifying the ``anaconda-project.yml`` file of persistent environments that are provided by administrators. This practice helps maintain the integrity and reproducibility of the environment.

|lock| **Promote project locking if modifications are required** - If users must make changes, they should use the ``anaconda-project lock`` command to lock the environment afterwards, ensuring it can be precisely recreated later. They must also inform the administrator of these changes, so future environments can be adjusted to incorporate these needs without further modifications. For step-by-step instructions on locking your project, see :ref:`Locking project configurations <project_locking>`.

.. tip::
    
    Run the ``anaconda-project lock`` command when you move to production, even if you created your project using a persistent environment with no configuration modifications!

|arrows-spin| **Continuous updates** - Administrators should routinely create new persistent environments to incorporate updates to packages and their dependencies. This keeps the environments up to date with the latest features and security patches.

|file-circle-check| **Naming conventions** - It's advisable to name these environments systematically, including the date of creation, which helps in identifying and managing them. For example, you could adopt the following structure: ``<GROUP>_<YYYY><MM>`` (where ``<GROUP>`` denotes the intended users for the environment and ``<YYYY><MM>`` is the year and month).

|file-slash| **Deprecate old environments safely** - Before an administrator deprecates an old environment, it's critical to ensure that it is not in use. Removing an environment that is still in use could disrupt ongoing projects. 


.. |clipboard-list-check| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M192 0c-37.1 0-67.6 28-71.6 64H112C91.1 64 73.3 77.4 66.7 96H64C28.7 96 0 124.7 0 160V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64h-2.7c-6.6-18.6-24.4-32-45.3-32h-8.4c-4-36-34.5-64-71.6-64zM16 160c0-26.5 21.5-48 48-48v16c0 17.7 14.3 32 32 32H288c17.7 0 32-14.3 32-32V112c26.5 0 48 21.5 48 48V448c0 26.5-21.5 48-48 48H64c-26.5 0-48-21.5-48-48V160zM136 72c0-30.9 25.1-56 56-56s56 25.1 56 56c0 4.4 3.6 8 8 8h16c17.7 0 32 14.3 32 32v16c0 8.8-7.2 16-16 16H96c-8.8 0-16-7.2-16-16V112c0-17.7 14.3-32 32-32h16c4.4 0 8-3.6 8-8zm56 24a16 16 0 1 0 0-32 16 16 0 1 0 0 32zM157.7 237.7c3.1-3.1 3.1-8.2 0-11.3s-8.2-3.1-11.3 0L96 276.7 77.7 258.3c-3.1-3.1-8.2-3.1-11.3 0s-3.1 8.2 0 11.3l24 24c3.1 3.1 8.2 3.1 11.3 0l56-56zM192 264c0 4.4 3.6 8 8 8H312c4.4 0 8-3.6 8-8s-3.6-8-8-8H200c-4.4 0-8 3.6-8 8zM160 384c0 4.4 3.6 8 8 8H312c4.4 0 8-3.6 8-8s-3.6-8-8-8H168c-4.4 0-8 3.6-8 8zM96 400a16 16 0 1 0 0-32 16 16 0 1 0 0 32z"/></svg>

.. |pen-slash| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M13 1.7C9.5-1 4.5-.4 1.7 3S-.4 11.5 3 14.3l624 496c3.5 2.7 8.5 2.2 11.2-1.3s2.2-8.5-1.3-11.2L13 1.7zM561.4 128.3c18.7-18.7 18.7-49.1 0-67.9L515.5 14.6c-18.7-18.7-49.1-18.7-67.9 0L307.7 154.6l12.6 10 60.4-60.4 91.1 91.1-49.7 49.7 12.6 10L561.4 128.3zM137.6 347.3l80.2-80.2-12.6-10L126.3 336c-12.3 12.3-21.3 27.5-26.2 44.2L64.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.2l92.2-92.2-12.6-10-90.9 90.9c-10.4 10.4-23.3 18-37.4 22.2L83.8 492.2l31.6-107.5c4.2-14.1 11.8-27 22.2-37.4zM459 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.9L392.1 92.8 459 25.9z"/></svg>

.. |lock| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M128 128v64H320V128c0-53-43-96-96-96s-96 43-96 96zM96 192V128C96 57.3 153.3 0 224 0s128 57.3 128 128v64h16c44.2 0 80 35.8 80 80V432c0 44.2-35.8 80-80 80H80c-44.2 0-80-35.8-80-80V272c0-44.2 35.8-80 80-80H96zM32 272V432c0 26.5 21.5 48 48 48H368c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48H80c-26.5 0-48 21.5-48 48z"/></svg>

.. |arrows-spin| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M91.3 65.4c-7.1 0-10.7 8.6-5.7 13.7l32.6 32.6 0 0 .8 .9 44.6 44.6c5 5 13.7 1.5 13.7-5.7l0-86.1-86.1 0zm15.9 57.8L74.3 90.3c-15.1-15.1-4.4-41 17-41h86.1c8.8 0 16 7.2 16 16v86.1c0 21.4-25.9 32.1-41 17l-33.9-33.9c-28.3 32.3-45.4 74.7-45.4 121c0 11.1 1 21.9 2.9 32.5H59.8c-1.7-10.6-2.6-21.4-2.6-32.5c0-50.7 18.9-97.1 50-132.3zm150-51.7c-11.3 0-22.4 1-33.1 3V58.3c10.8-1.8 21.8-2.7 33.1-2.7c51.6 0 98.6 19.5 134 51.6l32.7-32.8c15.1-15.1 41-4.4 41 17l0 86.1c0 8.8-7.2 16-16 16l-86.1 0c-21.4 0-32.1-25.9-17-41l34-34c-32.6-29.2-75.6-46.9-122.7-46.9zm184 184c0-10.7-.9-21.3-2.7-31.5h16.2c1.6 10.3 2.5 20.8 2.5 31.5c0 51.6-19.5 98.6-51.6 134l34.4 34.4c15.1 15.1 4.4 41-17 41H336.9c-8.8 0-16-7.2-16-16V362.8c0-21.4 25.9-32.1 41-17l32.4 32.4c29.2-32.6 46.9-75.6 46.9-122.7zM394.3 401.1l-1.4-1.5-42.4-42.4c-5-5-13.7-1.5-13.7 5.7v86.1H423c7.1 0 10.7-8.6 5.7-13.7L394.4 401l-.1 .1zM288 437v16.2c-10.1 1.6-20.4 2.4-30.9 2.4c-50.7 0-97.1-18.9-132.3-50L90.3 439.9c-15.1 15.1-41 4.4-41-17V336.9c0-8.8 7.2-16 16-16l86.1 0c21.4 0 32.1 25.9 17 41l-32.3 32.3c32.3 28.3 74.7 45.4 121 45.4c10.5 0 20.8-.9 30.9-2.6zM65.4 336.9l0 86.1c0 7.1 8.6 10.7 13.7 5.7l78.1-78.1c5-5 1.5-13.7-5.7-13.7l-86.1 0zM448.9 91.3c0-7.1-8.6-10.7-13.7-5.7l-78.1 78.1c-5 5-1.5 13.7 5.7 13.7l86.1 0 0-86.1z"/></svg>

.. |file-circle-check| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M64 496H311.2c5.8 5.5 12 10.6 18.5 15.3c-3.2 .5-6.4 .7-9.7 .7H64c-35.3 0-64-28.7-64-64V64C0 28.7 28.7 0 64 0H204.1c12.7 0 24.9 5.1 33.9 14.1L369.9 145.9c9 9 14.1 21.2 14.1 33.9v18.7c-5.4 1.5-10.8 3.3-16 5.4V179.9c0-1.3-.1-2.6-.2-3.9H248c-22.1 0-40-17.9-40-40V16.2c-1.3-.2-2.6-.2-3.9-.2H64C37.5 16 16 37.5 16 64V448c0 26.5 21.5 48 48 48zM361.1 160c-.8-1-1.6-1.9-2.4-2.7L226.7 25.4c-.9-.9-1.8-1.7-2.7-2.4V136c0 13.3 10.7 24 24 24H361.1zM432 496a128 128 0 1 0 0-256 128 128 0 1 0 0 256zm0-272a144 144 0 1 1 0 288 144 144 0 1 1 0-288zm69.7 98.3c3.1 3.1 3.1 8.2 0 11.3l-80 80c-3.1 3.1-8.2 3.1-11.3 0l-48-48c-3.1-3.1-3.1-8.2 0-11.3s8.2-3.1 11.3 0L416 396.7l74.3-74.3c3.1-3.1 8.2-3.1 11.3 0z"/></svg>

.. |file-slash| raw:: html
    
    <svg class="inline" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M512 179.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-20.1 0-38.1 9.3-49.8 23.9l12.6 9.9C163.5 22.9 176.9 16 192 16H332.1c1.3 0 2.6 .1 3.9 .2V136c0 22.1 17.9 40 40 40H495.8c.2 1.3 .2 2.6 .2 3.9V303.2l16 12.6v-136zM144 448V208.8l-16-12.6V448c0 35.3 28.7 64 64 64H448c20.1 0 38.1-9.3 49.8-23.9l-12.6-9.9C476.5 489.1 463.1 496 448 496H192c-26.5 0-48-21.5-48-48zM489.1 160H376c-13.3 0-24-10.7-24-24V22.9c1 .8 1.9 1.6 2.7 2.4L486.6 157.3c.9 .9 1.7 1.8 2.4 2.7zM13 1.7C9.5-1 4.5-.4 1.7 3S-.4 11.5 3 14.3l624 496c3.5 2.7 8.5 2.2 11.2-1.3s2.2-8.5-1.3-11.2L13 1.7z"/></svg>