=========
Tutorials
=========

.. contents::
   :local:
   :depth: 1

.. _repo-tutorial-labels-in-dev:

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

Anaconda Repository :ref:`labels <repo-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.

In this tutorial, we show 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."

#. You need to begin 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 Repository using the Client
   :ref:`upload <cli-upload>` command. Adding the ``--label``
   option tells Repository 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 path to 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.

   The following command produces 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

   Your version 2.0 is now in main::

     conda search --override -c USERNAME conda-package

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

You can also manage your package labels from your dashboard:
``https://<your-anaconda-repo>/USERNAME/conda-package``.

NOTE: Replace ``<your-anaconda-repo>`` with the name of your local
Repository, and ``USERNAME`` with your username.


.. _repo-tutorial-other-file-types:

Working with other file types
=============================

In addition to uploading or downloading
:ref:`packages <repo-glossary-package>`, you can also upload or
download other file types to/from Anaconda Repository.

Uploading other file types
--------------------------

You can upload any type of file with :doc:`Anaconda Client
command line interface <../commandreference>` (CLI) by using the
steps below.

PyPI package files, conda package files and notebook files
are automatically detected. There is no auto-detect for other
types of files, so you must explicitly specify the ``package``,
``package-type`` and ``version`` fields.

In the following example, we upload a spreadsheet named
``baby-names`` in comma separated value (CSV) format.

#. Create a new package, which creates a
   :ref:`repo-glossary-namespace` that can hold multiple files::

     anaconda login
     anaconda package --create jsmith/baby-names

#. Upload the file to the new namespace::

     anaconda upload --user jsmith --package baby-names --package-type file --version 1 baby-names1.csv

NOTE: In this example:

* The user or organization name is "jsmith."
* The package name is "baby-names."
* The package type is "file."
* The version is "1."
* The full filename is ``baby-names1.csv``.

Downloading other file types
-----------------------------

Files, such as the one created above, are available at::

  https://<your-anaconda-repo>/USERNAME/PACKAGE

Anyone can download these files using Client::

  anaconda download USERNAME/PACKAGE

NOTE: Replace ``<your-anaconda-repo>`` with the name of your
local Repository, ``USERNAME`` with the desired username and
``PACKAGE`` with the desired package name.
