========
Tutorial
========

.. _cloud-tutorials-labels:

Using labels in the development cycle
=====================================

Anaconda Cloud :ref:`labels <cloud-glossary-label>` can be used to 
facilitate a development cycle and organize the code that is in 
development, in testing and in production, without affecting 
non-development users. With labels you can upload a file to a 
specific label, so only users who put that label in the URL they 
search are able to find it.

Using Anaconda Client, :ref:`cloud-glossary-package` 
developers can create additional labels such as development 
``labels/dev``, test ``labels/test`` or other labels that are 
searched only if the user specifies the label. The following search 
examples use a :ref:`cloud-glossary-namespace` of ``travis``: 

* https://anaconda.org/travis/labels/main -- the label searched 
  by default.

* https://anaconda.org/travis -- same as default label with 
  ``main`` implicit.

* https://anaconda.org/travis/labels/dev -- contains the packages 
  in development.

* https://anaconda.org/travis/labels/test -- contains packages 
  ready to test.

* https://anaconda.org/travis/labels/any-custom-label -- any 
  label you want to use.

In this example, we show you how to use a ``test`` label, so that
you can upload files without affecting your production-quality 
packages. Without a ``--label`` argument the default label is 
``main``.

#. Let us start with a conda package. If you do not have one, 
   use our example conda package. Before you build the package, 
   edit the version in the ``meta.yaml`` file in 
   ``anaconda-client/example-packages/conda/`` to be ``2.0``::

       git clone https://github.com/Anaconda-Platform/anaconda-client/
       cd anaconda-client/example-packages/conda/
       nano meta.yaml # Bump version to 2.0
       conda config --set anaconda_upload no
       conda build .

#. Upload your test package to Cloud using the Client 
   :ref:`upload <cli-upload>` command.

   Adding the ``--label`` option tells Cloud to make the upload 
   visible only to users who specify that label::

       anaconda upload /path/to/conda-package-2.0.tar.bz2 --label test

   NOTE: Replace ``/path/to/`` with the actual path where you 
   stored the package.

#. You now can see that even when you search conda ``main``, 
   you do not see the ``2.0`` version of the test package. 
   This is because you need to tell conda to look for your 
   new ``test`` label.

#. The ``--override`` argument tells conda not to use any 
   channels in your ``~/.condarc`` file.

   No ``2.0`` results::

       conda search --override -c USERNAME conda-package

   NOTE: Replace USERNAME with your username.

   Your ``2.0`` package is here::

       conda search --override -c USERNAME/label/test conda-package

   NOTE: Replace ``USERNAME`` with your username.

#. You can give the label ``USERNAME/label/test`` to your testers.

   NOTE: Replace ``USERNAME`` with your username.
   
#. Once they finish testing, you may then want to copy the 
   ``test`` packages back to your ``main`` label::

       anaconda label --copy test main

   You can also manage your package labels from your dashboard: 
   ``https://anaconda.org/USERNAME/conda-package``.
 
   Your version ``2.0`` is now in ``main``::

       conda search --override -c USERNAME conda-package

   NOTE: Replace ``USERNAME`` with your username.
