prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  lightly-download fails for integer tag names
  lightly-download fails for integer tag names
  
  For the `tag_name` `1000`, the following warning appears:
  > Possible bug: I get `warnings.warn(f'The specified tag {tag_name} does not exist`
  
  The source of the problem is probably in this line:
  https://github.com/lightly-ai/lightly/blob/db33b15de6f77e50b0c815c4c405a8fb371d22e7/lightly/cli/download_cli.py#L44
  
  Current guess: Either the api sends the string as a number or the command-line tool parses the string as a number which makes the lookup fail.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `lightly/cli/download_cli.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 """**Lightly Download:** Download images from the Lightly platform.
  3 
  4 This module contains the entrypoint for the **lightly-download**
  5 command-line interface.
  6 """
  7 
  8 # Copyright (c) 2020. Lightly AG and its affiliates.
  9 # All Rights Reserved
  10 
  11 import os
  12 import shutil
  13 import warnings
  14 
  15 import hydra
  16 from torch.utils.hipify.hipify_python import bcolors
  17 from tqdm import tqdm
  18 
  19 import lightly.data as data
  20 from lightly.cli._helpers import fix_input_path, print_as_warning
  21 
  22 from lightly.api.utils import getenv
  23 from lightly.api.api_workflow_client import ApiWorkflowClient
  24 from lightly.api.bitmask import BitMask
  25 from lightly.openapi_generated.swagger_client import TagData, TagArithmeticsRequest, TagArithmeticsOperation, \
  26     TagBitMaskResponse
  27 
  28 
  29 def _download_cli(cfg, is_cli_call=True):
  30     tag_name = cfg['tag_name']
  31     dataset_id = cfg['dataset_id']
  32     token = cfg['token']
  33 
  34     if not tag_name or not token or not dataset_id:
  35         print_as_warning('Please specify all of the parameters tag_name, token and dataset_id')
  36         print_as_warning('For help, try: lightly-download --help')
  37         return
  38 
  39     api_workflow_client = ApiWorkflowClient(
  40         token=token, dataset_id=dataset_id
  41     )
  42 
  43     # get tag id
  44     tag_name_id_dict = dict([tag.name, tag.id] for tag in api_workflow_client._get_all_tags())
  45     tag_id = tag_name_id_dict.get(tag_name, None)
  46     if tag_id is None:
  47         warnings.warn(f'The specified tag {tag_name} does not exist.')
  48         return
  49 
  50     # get tag data
  51     tag_data: TagData = api_workflow_client.tags_api.get_tag_by_tag_id(
  52         dataset_id=dataset_id, tag_id=tag_id
  53     )
  54 
  55     if cfg["exclude_parent_tag"]:
  56         parent_tag_id = tag_data.prev_tag_id
  57         tag_arithmetics_request = TagArithmeticsRequest(
  58             tag_id1=tag_data.id,
  59             tag_id2=parent_tag_id,
  60             operation=TagArithmeticsOperation.DIFFERENCE)
  61         bit_mask_response: TagBitMaskResponse \
  62             = api_workflow_client.tags_api.perform_tag_arithmetics(body=tag_arithmetics_request, dataset_id=dataset_id)
  63         bit_mask_data = bit_mask_response.bit_mask_data
  64     else:
  65         bit_mask_data = tag_data.bit_mask_data
  66 
  67     # get samples
  68     chosen_samples_ids = BitMask.from_hex(bit_mask_data).to_indices()
  69     samples = [api_workflow_client.filenames_on_server[i] for i in chosen_samples_ids]
  70 
  71     # store sample names in a .txt file
  72     filename = cfg['tag_name'] + '.txt'
  73     with open(filename, 'w') as f:
  74         for item in samples:
  75             f.write("%s\n" % item)
  76 
  77     filepath = os.path.join(os.getcwd(), filename)
  78     msg = f'The list of files in tag {cfg["tag_name"]} is stored at: {bcolors.OKBLUE}{filepath}{bcolors.ENDC}'
  79     print(msg, flush=True)
  80 
  81     if not cfg['input_dir'] and cfg['output_dir']:
  82         # download full images from api
  83         output_dir = fix_input_path(cfg['output_dir'])
  84         api_workflow_client.download_dataset(output_dir, tag_name=tag_name)
  85 
  86     elif cfg['input_dir'] and cfg['output_dir']:
  87         input_dir = fix_input_path(cfg['input_dir'])
  88         output_dir = fix_input_path(cfg['output_dir'])
  89         print(f'Copying files from {input_dir} to {bcolors.OKBLUE}{output_dir}{bcolors.ENDC}.')
  90 
  91         # create a dataset from the input directory
  92         dataset = data.LightlyDataset(input_dir=input_dir)
  93 
  94         # dump the dataset in the output directory
  95         dataset.dump(output_dir, samples)
  96 
  97 
  98 @hydra.main(config_path='config', config_name='config')
  99 def download_cli(cfg):
  100     """Download images from the Lightly platform.
  101 
  102     Args:
  103         cfg:
  104             The default configs are loaded from the config file.
  105             To overwrite them please see the section on the config file 
  106             (.config.config.yaml).
  107     
  108     Command-Line Args:
  109         tag_name:
  110             Download all images from the requested tag. Use initial-tag
  111             to get all images from the dataset.
  112         token:
  113             User access token to the Lightly platform. If dataset_id
  114             and token are specified, the images and embeddings are 
  115             uploaded to the platform.
  116         dataset_id:
  117             Identifier of the dataset on the Lightly platform. If 
  118             dataset_id and token are specified, the images and 
  119             embeddings are uploaded to the platform.
  120         input_dir:
  121             If input_dir and output_dir are specified, lightly will copy
  122             all images belonging to the tag from the input_dir to the 
  123             output_dir.
  124         output_dir:
  125             If input_dir and output_dir are specified, lightly will copy
  126             all images belonging to the tag from the input_dir to the 
  127             output_dir.
  128 
  129     Examples:
  130         >>> # download list of all files in the dataset from the Lightly platform
  131         >>> lightly-download token='123' dataset_id='XYZ'
  132         >>> 
  133         >>> # download list of all files in tag 'my-tag' from the Lightly platform
  134         >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag'
  135         >>>
  136         >>> # download all images in tag 'my-tag' from the Lightly platform
  137         >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' output_dir='my_data/'
  138         >>>
  139         >>> # copy all files in 'my-tag' to a new directory
  140         >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' input_dir='data/' output_dir='my_data/'
  141 
  142 
  143     """
  144     _download_cli(cfg)
  145 
  146 
  147 def entry():
  148     download_cli()
  149
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/lightly/cli/download_cli.py b/lightly/cli/download_cli.py
  --- a/lightly/cli/download_cli.py
  +++ b/lightly/cli/download_cli.py
  @@ -27,9 +27,10 @@
   
   
   def _download_cli(cfg, is_cli_call=True):
  -    tag_name = cfg['tag_name']
  -    dataset_id = cfg['dataset_id']
  -    token = cfg['token']
  +
  +    tag_name = str(cfg['tag_name'])
  +    dataset_id = str(cfg['dataset_id'])
  +    token = str(cfg['token'])
   
       if not tag_name or not token or not dataset_id:
           print_as_warning('Please specify all of the parameters tag_name, token and dataset_id')
  @@ -69,7 +70,7 @@
       samples = [api_workflow_client.filenames_on_server[i] for i in chosen_samples_ids]
   
       # store sample names in a .txt file
  -    filename = cfg['tag_name'] + '.txt'
  +    filename = tag_name + '.txt'
       with open(filename, 'w') as f:
           for item in samples:
               f.write("%s\n" % item)
  
verification_info: {"golden_diff": "diff --git a/lightly/cli/download_cli.py b/lightly/cli/download_cli.py\n--- a/lightly/cli/download_cli.py\n+++ b/lightly/cli/download_cli.py\n@@ -27,9 +27,10 @@\n \n \n def _download_cli(cfg, is_cli_call=True):\n-    tag_name = cfg['tag_name']\n-    dataset_id = cfg['dataset_id']\n-    token = cfg['token']\n+\n+    tag_name = str(cfg['tag_name'])\n+    dataset_id = str(cfg['dataset_id'])\n+    token = str(cfg['token'])\n \n     if not tag_name or not token or not dataset_id:\n         print_as_warning('Please specify all of the parameters tag_name, token and dataset_id')\n@@ -69,7 +70,7 @@\n     samples = [api_workflow_client.filenames_on_server[i] for i in chosen_samples_ids]\n \n     # store sample names in a .txt file\n-    filename = cfg['tag_name'] + '.txt'\n+    filename = tag_name + '.txt'\n     with open(filename, 'w') as f:\n         for item in samples:\n             f.write(\"%s\\n\" % item)\n", "issue": "lightly-download fails for integer tag names\nlightly-download fails for integer tag names\r\n\r\nFor the `tag_name` `1000`, the following warning appears:\r\n> Possible bug: I get `warnings.warn(f'The specified tag {tag_name} does not exist`\r\n\r\nThe source of the problem is probably in this line:\r\nhttps://github.com/lightly-ai/lightly/blob/db33b15de6f77e50b0c815c4c405a8fb371d22e7/lightly/cli/download_cli.py#L44\r\n\r\nCurrent guess: Either the api sends the string as a number or the command-line tool parses the string as a number which makes the lookup fail.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"**Lightly Download:** Download images from the Lightly platform.\n\nThis module contains the entrypoint for the **lightly-download**\ncommand-line interface.\n\"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nimport shutil\nimport warnings\n\nimport hydra\nfrom torch.utils.hipify.hipify_python import bcolors\nfrom tqdm import tqdm\n\nimport lightly.data as data\nfrom lightly.cli._helpers import fix_input_path, print_as_warning\n\nfrom lightly.api.utils import getenv\nfrom lightly.api.api_workflow_client import ApiWorkflowClient\nfrom lightly.api.bitmask import BitMask\nfrom lightly.openapi_generated.swagger_client import TagData, TagArithmeticsRequest, TagArithmeticsOperation, \\\n    TagBitMaskResponse\n\n\ndef _download_cli(cfg, is_cli_call=True):\n    tag_name = cfg['tag_name']\n    dataset_id = cfg['dataset_id']\n    token = cfg['token']\n\n    if not tag_name or not token or not dataset_id:\n        print_as_warning('Please specify all of the parameters tag_name, token and dataset_id')\n        print_as_warning('For help, try: lightly-download --help')\n        return\n\n    api_workflow_client = ApiWorkflowClient(\n        token=token, dataset_id=dataset_id\n    )\n\n    # get tag id\n    tag_name_id_dict = dict([tag.name, tag.id] for tag in api_workflow_client._get_all_tags())\n    tag_id = tag_name_id_dict.get(tag_name, None)\n    if tag_id is None:\n        warnings.warn(f'The specified tag {tag_name} does not exist.')\n        return\n\n    # get tag data\n    tag_data: TagData = api_workflow_client.tags_api.get_tag_by_tag_id(\n        dataset_id=dataset_id, tag_id=tag_id\n    )\n\n    if cfg[\"exclude_parent_tag\"]:\n        parent_tag_id = tag_data.prev_tag_id\n        tag_arithmetics_request = TagArithmeticsRequest(\n            tag_id1=tag_data.id,\n            tag_id2=parent_tag_id,\n            operation=TagArithmeticsOperation.DIFFERENCE)\n        bit_mask_response: TagBitMaskResponse \\\n            = api_workflow_client.tags_api.perform_tag_arithmetics(body=tag_arithmetics_request, dataset_id=dataset_id)\n        bit_mask_data = bit_mask_response.bit_mask_data\n    else:\n        bit_mask_data = tag_data.bit_mask_data\n\n    # get samples\n    chosen_samples_ids = BitMask.from_hex(bit_mask_data).to_indices()\n    samples = [api_workflow_client.filenames_on_server[i] for i in chosen_samples_ids]\n\n    # store sample names in a .txt file\n    filename = cfg['tag_name'] + '.txt'\n    with open(filename, 'w') as f:\n        for item in samples:\n            f.write(\"%s\\n\" % item)\n\n    filepath = os.path.join(os.getcwd(), filename)\n    msg = f'The list of files in tag {cfg[\"tag_name\"]} is stored at: {bcolors.OKBLUE}{filepath}{bcolors.ENDC}'\n    print(msg, flush=True)\n\n    if not cfg['input_dir'] and cfg['output_dir']:\n        # download full images from api\n        output_dir = fix_input_path(cfg['output_dir'])\n        api_workflow_client.download_dataset(output_dir, tag_name=tag_name)\n\n    elif cfg['input_dir'] and cfg['output_dir']:\n        input_dir = fix_input_path(cfg['input_dir'])\n        output_dir = fix_input_path(cfg['output_dir'])\n        print(f'Copying files from {input_dir} to {bcolors.OKBLUE}{output_dir}{bcolors.ENDC}.')\n\n        # create a dataset from the input directory\n        dataset = data.LightlyDataset(input_dir=input_dir)\n\n        # dump the dataset in the output directory\n        dataset.dump(output_dir, samples)\n\n\n@hydra.main(config_path='config', config_name='config')\ndef download_cli(cfg):\n    \"\"\"Download images from the Lightly platform.\n\n    Args:\n        cfg:\n            The default configs are loaded from the config file.\n            To overwrite them please see the section on the config file \n            (.config.config.yaml).\n    \n    Command-Line Args:\n        tag_name:\n            Download all images from the requested tag. Use initial-tag\n            to get all images from the dataset.\n        token:\n            User access token to the Lightly platform. If dataset_id\n            and token are specified, the images and embeddings are \n            uploaded to the platform.\n        dataset_id:\n            Identifier of the dataset on the Lightly platform. If \n            dataset_id and token are specified, the images and \n            embeddings are uploaded to the platform.\n        input_dir:\n            If input_dir and output_dir are specified, lightly will copy\n            all images belonging to the tag from the input_dir to the \n            output_dir.\n        output_dir:\n            If input_dir and output_dir are specified, lightly will copy\n            all images belonging to the tag from the input_dir to the \n            output_dir.\n\n    Examples:\n        >>> #\u00a0download list of all files in the dataset from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ'\n        >>> \n        >>> # download list of all files in tag 'my-tag' from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag'\n        >>>\n        >>> # download all images in tag 'my-tag' from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' output_dir='my_data/'\n        >>>\n        >>> # copy all files in 'my-tag' to a new directory\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' input_dir='data/' output_dir='my_data/'\n\n\n    \"\"\"\n    _download_cli(cfg)\n\n\ndef entry():\n    download_cli()\n", "path": "lightly/cli/download_cli.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"**Lightly Download:** Download images from the Lightly platform.\n\nThis module contains the entrypoint for the **lightly-download**\ncommand-line interface.\n\"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nimport shutil\nimport warnings\n\nimport hydra\nfrom torch.utils.hipify.hipify_python import bcolors\nfrom tqdm import tqdm\n\nimport lightly.data as data\nfrom lightly.cli._helpers import fix_input_path, print_as_warning\n\nfrom lightly.api.utils import getenv\nfrom lightly.api.api_workflow_client import ApiWorkflowClient\nfrom lightly.api.bitmask import BitMask\nfrom lightly.openapi_generated.swagger_client import TagData, TagArithmeticsRequest, TagArithmeticsOperation, \\\n    TagBitMaskResponse\n\n\ndef _download_cli(cfg, is_cli_call=True):\n\n    tag_name = str(cfg['tag_name'])\n    dataset_id = str(cfg['dataset_id'])\n    token = str(cfg['token'])\n\n    if not tag_name or not token or not dataset_id:\n        print_as_warning('Please specify all of the parameters tag_name, token and dataset_id')\n        print_as_warning('For help, try: lightly-download --help')\n        return\n\n    api_workflow_client = ApiWorkflowClient(\n        token=token, dataset_id=dataset_id\n    )\n\n    # get tag id\n    tag_name_id_dict = dict([tag.name, tag.id] for tag in api_workflow_client._get_all_tags())\n    tag_id = tag_name_id_dict.get(tag_name, None)\n    if tag_id is None:\n        warnings.warn(f'The specified tag {tag_name} does not exist.')\n        return\n\n    # get tag data\n    tag_data: TagData = api_workflow_client.tags_api.get_tag_by_tag_id(\n        dataset_id=dataset_id, tag_id=tag_id\n    )\n\n    if cfg[\"exclude_parent_tag\"]:\n        parent_tag_id = tag_data.prev_tag_id\n        tag_arithmetics_request = TagArithmeticsRequest(\n            tag_id1=tag_data.id,\n            tag_id2=parent_tag_id,\n            operation=TagArithmeticsOperation.DIFFERENCE)\n        bit_mask_response: TagBitMaskResponse \\\n            = api_workflow_client.tags_api.perform_tag_arithmetics(body=tag_arithmetics_request, dataset_id=dataset_id)\n        bit_mask_data = bit_mask_response.bit_mask_data\n    else:\n        bit_mask_data = tag_data.bit_mask_data\n\n    # get samples\n    chosen_samples_ids = BitMask.from_hex(bit_mask_data).to_indices()\n    samples = [api_workflow_client.filenames_on_server[i] for i in chosen_samples_ids]\n\n    # store sample names in a .txt file\n    filename = tag_name + '.txt'\n    with open(filename, 'w') as f:\n        for item in samples:\n            f.write(\"%s\\n\" % item)\n\n    filepath = os.path.join(os.getcwd(), filename)\n    msg = f'The list of files in tag {cfg[\"tag_name\"]} is stored at: {bcolors.OKBLUE}{filepath}{bcolors.ENDC}'\n    print(msg, flush=True)\n\n    if not cfg['input_dir'] and cfg['output_dir']:\n        # download full images from api\n        output_dir = fix_input_path(cfg['output_dir'])\n        api_workflow_client.download_dataset(output_dir, tag_name=tag_name)\n\n    elif cfg['input_dir'] and cfg['output_dir']:\n        input_dir = fix_input_path(cfg['input_dir'])\n        output_dir = fix_input_path(cfg['output_dir'])\n        print(f'Copying files from {input_dir} to {bcolors.OKBLUE}{output_dir}{bcolors.ENDC}.')\n\n        # create a dataset from the input directory\n        dataset = data.LightlyDataset(input_dir=input_dir)\n\n        # dump the dataset in the output directory\n        dataset.dump(output_dir, samples)\n\n\n@hydra.main(config_path='config', config_name='config')\ndef download_cli(cfg):\n    \"\"\"Download images from the Lightly platform.\n\n    Args:\n        cfg:\n            The default configs are loaded from the config file.\n            To overwrite them please see the section on the config file \n            (.config.config.yaml).\n    \n    Command-Line Args:\n        tag_name:\n            Download all images from the requested tag. Use initial-tag\n            to get all images from the dataset.\n        token:\n            User access token to the Lightly platform. If dataset_id\n            and token are specified, the images and embeddings are \n            uploaded to the platform.\n        dataset_id:\n            Identifier of the dataset on the Lightly platform. If \n            dataset_id and token are specified, the images and \n            embeddings are uploaded to the platform.\n        input_dir:\n            If input_dir and output_dir are specified, lightly will copy\n            all images belonging to the tag from the input_dir to the \n            output_dir.\n        output_dir:\n            If input_dir and output_dir are specified, lightly will copy\n            all images belonging to the tag from the input_dir to the \n            output_dir.\n\n    Examples:\n        >>> #\u00a0download list of all files in the dataset from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ'\n        >>> \n        >>> # download list of all files in tag 'my-tag' from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag'\n        >>>\n        >>> # download all images in tag 'my-tag' from the Lightly platform\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' output_dir='my_data/'\n        >>>\n        >>> # copy all files in 'my-tag' to a new directory\n        >>> lightly-download token='123' dataset_id='XYZ' tag_name='my-tag' input_dir='data/' output_dir='my_data/'\n\n\n    \"\"\"\n    _download_cli(cfg)\n\n\ndef entry():\n    download_cli()\n", "path": "lightly/cli/download_cli.py"}]}