prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Bump Python to 3.7.0
  ## Expected Behavior
  
  MedTagger should always use the latest version of Python technologies and follow the rabbit instead of leaving technical dept :)
  
  ## Actual Behavior
  
  We've got Python 3.6.x right now.
  
  ## Additional comment
  
  Remember about Makefiles, Dockerfiles, TravisCI and more(?).
  
  **WATCH OUT!** It's relatively new. Some of our dependencies may not work properly! Find out if `numpy` and other libs supports it!
  
  **BLOCKED BY:**
  - [SimpleITK](https://github.com/SimpleITK/SimpleITK/releases) - next release (>1.1.0) will be fine to use with Python3.7.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `backend/scripts/import_data.py`
  Content:
  ```
  1 """Script that will fill MedTagger with data.
  2 
  3 How to use it?
  4 --------------
  5 At first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:
  6 https://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).
  7 
  8 Then, place these data (unzipped) anywhere on your computer and run this script by:
  9 
  10     (venv) $ python3.6 scripts/import_data.py --source=./dir_with_scans/
  11 
  12 Please keep all scans with given structure:
  13 
  14     |
  15     `-- dir_with_scans
  16         |-- 0a0c32c9e08cc2ea76a71649de56be6d
  17         |   |-- 0a67f9edb4915467ac16a565955898d3.dcm
  18         |   |-- 0eb4e3cae3de93e50431cf12bdc6c93d.dcm
  19         |   `-- ...
  20         |-- 0a38e7597ca26f9374f8ea2770ba870d
  21         |   |-- 0bad9c3a3890617f78a905b78bc60f99.dcm
  22         |   |-- 1cffdd431884c2792ae0cbecec1c9e14.dcm
  23         |   `-- ...
  24         `-- ...
  25 
  26 """
  27 import os
  28 import argparse
  29 import glob
  30 import logging
  31 import logging.config
  32 
  33 from medtagger.repositories import scans as ScansRepository, datasets as DatasetsRepository
  34 from medtagger.workers.storage import parse_dicom_and_update_slice
  35 
  36 
  37 logging.config.fileConfig('logging.conf')
  38 logger = logging.getLogger(__name__)
  39 
  40 parser = argparse.ArgumentParser(description='Import data to the MedTagger.')
  41 parser.add_argument('--source', type=str, required=True, help='Source directory')
  42 parser.add_argument('--dataset', type=str, required=True, help='Dataset key for these scans')
  43 args = parser.parse_args()
  44 
  45 
  46 if __name__ == '__main__':
  47     logger.info('Checking Dataset...')
  48     dataset = DatasetsRepository.get_dataset_by_key(args.dataset)
  49 
  50     source = args.source.rstrip('/')
  51     for scan_directory in glob.iglob(source + '/*'):
  52         if not os.path.isdir(scan_directory):
  53             logger.warning('"%s" is not a directory. Skipping...', scan_directory)
  54             continue
  55 
  56         logger.info('Adding new Scan from "%s".', scan_directory)
  57         slice_names = glob.glob(scan_directory + '/*.dcm')
  58         number_of_slices = len(slice_names)
  59         scan = ScansRepository.add_new_scan(dataset, number_of_slices, None)
  60 
  61         for slice_name in slice_names:
  62             logger.info('Adding new Slice to Scan "%s" based on "%s".', scan.id, slice_name)
  63             with open(slice_name, 'rb') as slice_dicom_file:
  64                 _slice = scan.add_slice()
  65                 image = slice_dicom_file.read()
  66                 parse_dicom_and_update_slice.delay(_slice.id, image)
  67
  ```
  
  Path: `backend/scripts/convert_dicoms_to_png.py`
  Content:
  ```
  1 """Script that will convert multiple dicoms to PNG format.
  2 
  3 How to use it?
  4 --------------
  5 At first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:
  6 https://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).
  7 
  8 Then, place these data (unzipped) anywhere on your computer and run this script by:
  9 
  10     (venv) $ python3.6 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/
  11 
  12 Name of the converted Dicom file is a position of the scan on the z axis.
  13 """
  14 import os
  15 import argparse
  16 
  17 import SimpleITK as sitk
  18 from PIL import Image
  19 
  20 from medtagger.conversion import convert_slice_to_normalized_8bit_array
  21 from medtagger.definitions import DicomTag
  22 from medtagger.dicoms import read_list
  23 
  24 
  25 parser = argparse.ArgumentParser(description='Convert dicoms to png format.')
  26 parser.add_argument('--input', type=str, required=True, help='Full path to directory where dicoms are located')
  27 parser.add_argument('--output', type=str, required=True,
  28                     help='Full path to directory where converted dicoms would be located')
  29 
  30 args = parser.parse_args()
  31 dicoms_folder_path = args.input
  32 converted_dicoms_folder_path = args.output
  33 
  34 dicoms = [sitk.ReadImage(dicoms_folder_path + d) for d in os.listdir(dicoms_folder_path) if
  35           os.path.isfile(dicoms_folder_path + d)]
  36 min_position = abs(min(float((read_list(dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2]) for dicom in dicoms))
  37 
  38 if not os.path.exists(converted_dicoms_folder_path):
  39     os.mkdir(converted_dicoms_folder_path)
  40 
  41 for single_dicom in dicoms:
  42     image_bytes = convert_slice_to_normalized_8bit_array(single_dicom)
  43     slice_position = float((read_list(single_dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2])
  44     converted_dicom_name = '{0:.2f}'.format(slice_position + min_position)
  45     Image.fromarray(image_bytes, 'L').save(converted_dicoms_folder_path + converted_dicom_name + '.png')
  46
  ```
  --- 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/backend/scripts/convert_dicoms_to_png.py b/backend/scripts/convert_dicoms_to_png.py
  --- a/backend/scripts/convert_dicoms_to_png.py
  +++ b/backend/scripts/convert_dicoms_to_png.py
  @@ -7,7 +7,7 @@
   
   Then, place these data (unzipped) anywhere on your computer and run this script by:
   
  -    (venv) $ python3.6 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/
  +    (venv) $ python3.7 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/
   
   Name of the converted Dicom file is a position of the scan on the z axis.
   """
  diff --git a/backend/scripts/import_data.py b/backend/scripts/import_data.py
  --- a/backend/scripts/import_data.py
  +++ b/backend/scripts/import_data.py
  @@ -7,7 +7,7 @@
   
   Then, place these data (unzipped) anywhere on your computer and run this script by:
   
  -    (venv) $ python3.6 scripts/import_data.py --source=./dir_with_scans/
  +    (venv) $ python3.7 scripts/import_data.py --source=./dir_with_scans/
   
   Please keep all scans with given structure:
  
verification_info: {"golden_diff": "diff --git a/backend/scripts/convert_dicoms_to_png.py b/backend/scripts/convert_dicoms_to_png.py\n--- a/backend/scripts/convert_dicoms_to_png.py\n+++ b/backend/scripts/convert_dicoms_to_png.py\n@@ -7,7 +7,7 @@\n \n Then, place these data (unzipped) anywhere on your computer and run this script by:\n \n-    (venv) $ python3.6 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/\n+    (venv) $ python3.7 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/\n \n Name of the converted Dicom file is a position of the scan on the z axis.\n \"\"\"\ndiff --git a/backend/scripts/import_data.py b/backend/scripts/import_data.py\n--- a/backend/scripts/import_data.py\n+++ b/backend/scripts/import_data.py\n@@ -7,7 +7,7 @@\n \n Then, place these data (unzipped) anywhere on your computer and run this script by:\n \n-    (venv) $ python3.6 scripts/import_data.py --source=./dir_with_scans/\n+    (venv) $ python3.7 scripts/import_data.py --source=./dir_with_scans/\n \n Please keep all scans with given structure:\n", "issue": "Bump Python to 3.7.0\n## Expected Behavior\r\n\r\nMedTagger should always use the latest version of Python technologies and follow the rabbit instead of leaving technical dept :)\r\n\r\n## Actual Behavior\r\n\r\nWe've got Python 3.6.x right now.\r\n\r\n## Additional comment\r\n\r\nRemember about Makefiles, Dockerfiles, TravisCI and more(?).\r\n\r\n**WATCH OUT!** It's relatively new. Some of our dependencies may not work properly! Find out if `numpy` and other libs supports it!\r\n\r\n**BLOCKED BY:**\r\n- [SimpleITK](https://github.com/SimpleITK/SimpleITK/releases) - next release (>1.1.0) will be fine to use with Python3.7.\n", "before_files": [{"content": "\"\"\"Script that will fill MedTagger with data.\n\nHow to use it?\n--------------\nAt first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:\nhttps://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).\n\nThen, place these data (unzipped) anywhere on your computer and run this script by:\n\n    (venv) $ python3.6 scripts/import_data.py --source=./dir_with_scans/\n\nPlease keep all scans with given structure:\n\n    |\n    `-- dir_with_scans\n        |-- 0a0c32c9e08cc2ea76a71649de56be6d\n        |   |-- 0a67f9edb4915467ac16a565955898d3.dcm\n        |   |-- 0eb4e3cae3de93e50431cf12bdc6c93d.dcm\n        |   `-- ...\n        |-- 0a38e7597ca26f9374f8ea2770ba870d\n        |   |-- 0bad9c3a3890617f78a905b78bc60f99.dcm\n        |   |-- 1cffdd431884c2792ae0cbecec1c9e14.dcm\n        |   `-- ...\n        `-- ...\n\n\"\"\"\nimport os\nimport argparse\nimport glob\nimport logging\nimport logging.config\n\nfrom medtagger.repositories import scans as ScansRepository, datasets as DatasetsRepository\nfrom medtagger.workers.storage import parse_dicom_and_update_slice\n\n\nlogging.config.fileConfig('logging.conf')\nlogger = logging.getLogger(__name__)\n\nparser = argparse.ArgumentParser(description='Import data to the MedTagger.')\nparser.add_argument('--source', type=str, required=True, help='Source directory')\nparser.add_argument('--dataset', type=str, required=True, help='Dataset key for these scans')\nargs = parser.parse_args()\n\n\nif __name__ == '__main__':\n    logger.info('Checking Dataset...')\n    dataset = DatasetsRepository.get_dataset_by_key(args.dataset)\n\n    source = args.source.rstrip('/')\n    for scan_directory in glob.iglob(source + '/*'):\n        if not os.path.isdir(scan_directory):\n            logger.warning('\"%s\" is not a directory. Skipping...', scan_directory)\n            continue\n\n        logger.info('Adding new Scan from \"%s\".', scan_directory)\n        slice_names = glob.glob(scan_directory + '/*.dcm')\n        number_of_slices = len(slice_names)\n        scan = ScansRepository.add_new_scan(dataset, number_of_slices, None)\n\n        for slice_name in slice_names:\n            logger.info('Adding new Slice to Scan \"%s\" based on \"%s\".', scan.id, slice_name)\n            with open(slice_name, 'rb') as slice_dicom_file:\n                _slice = scan.add_slice()\n                image = slice_dicom_file.read()\n                parse_dicom_and_update_slice.delay(_slice.id, image)\n", "path": "backend/scripts/import_data.py"}, {"content": "\"\"\"Script that will convert multiple dicoms to PNG format.\n\nHow to use it?\n--------------\nAt first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:\nhttps://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).\n\nThen, place these data (unzipped) anywhere on your computer and run this script by:\n\n    (venv) $ python3.6 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/\n\nName of the converted Dicom file is a position of the scan on the z axis.\n\"\"\"\nimport os\nimport argparse\n\nimport SimpleITK as sitk\nfrom PIL import Image\n\nfrom medtagger.conversion import convert_slice_to_normalized_8bit_array\nfrom medtagger.definitions import DicomTag\nfrom medtagger.dicoms import read_list\n\n\nparser = argparse.ArgumentParser(description='Convert dicoms to png format.')\nparser.add_argument('--input', type=str, required=True, help='Full path to directory where dicoms are located')\nparser.add_argument('--output', type=str, required=True,\n                    help='Full path to directory where converted dicoms would be located')\n\nargs = parser.parse_args()\ndicoms_folder_path = args.input\nconverted_dicoms_folder_path = args.output\n\ndicoms = [sitk.ReadImage(dicoms_folder_path + d) for d in os.listdir(dicoms_folder_path) if\n          os.path.isfile(dicoms_folder_path + d)]\nmin_position = abs(min(float((read_list(dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2]) for dicom in dicoms))\n\nif not os.path.exists(converted_dicoms_folder_path):\n    os.mkdir(converted_dicoms_folder_path)\n\nfor single_dicom in dicoms:\n    image_bytes = convert_slice_to_normalized_8bit_array(single_dicom)\n    slice_position = float((read_list(single_dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2])\n    converted_dicom_name = '{0:.2f}'.format(slice_position + min_position)\n    Image.fromarray(image_bytes, 'L').save(converted_dicoms_folder_path + converted_dicom_name + '.png')\n", "path": "backend/scripts/convert_dicoms_to_png.py"}], "after_files": [{"content": "\"\"\"Script that will fill MedTagger with data.\n\nHow to use it?\n--------------\nAt first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:\nhttps://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).\n\nThen, place these data (unzipped) anywhere on your computer and run this script by:\n\n    (venv) $ python3.7 scripts/import_data.py --source=./dir_with_scans/\n\nPlease keep all scans with given structure:\n\n    |\n    `-- dir_with_scans\n        |-- 0a0c32c9e08cc2ea76a71649de56be6d\n        |   |-- 0a67f9edb4915467ac16a565955898d3.dcm\n        |   |-- 0eb4e3cae3de93e50431cf12bdc6c93d.dcm\n        |   `-- ...\n        |-- 0a38e7597ca26f9374f8ea2770ba870d\n        |   |-- 0bad9c3a3890617f78a905b78bc60f99.dcm\n        |   |-- 1cffdd431884c2792ae0cbecec1c9e14.dcm\n        |   `-- ...\n        `-- ...\n\n\"\"\"\nimport os\nimport argparse\nimport glob\nimport logging\nimport logging.config\n\nfrom medtagger.repositories import scans as ScansRepository, datasets as DatasetsRepository\nfrom medtagger.workers.storage import parse_dicom_and_update_slice\n\n\nlogging.config.fileConfig('logging.conf')\nlogger = logging.getLogger(__name__)\n\nparser = argparse.ArgumentParser(description='Import data to the MedTagger.')\nparser.add_argument('--source', type=str, required=True, help='Source directory')\nparser.add_argument('--dataset', type=str, required=True, help='Dataset key for these scans')\nargs = parser.parse_args()\n\n\nif __name__ == '__main__':\n    logger.info('Checking Dataset...')\n    dataset = DatasetsRepository.get_dataset_by_key(args.dataset)\n\n    source = args.source.rstrip('/')\n    for scan_directory in glob.iglob(source + '/*'):\n        if not os.path.isdir(scan_directory):\n            logger.warning('\"%s\" is not a directory. Skipping...', scan_directory)\n            continue\n\n        logger.info('Adding new Scan from \"%s\".', scan_directory)\n        slice_names = glob.glob(scan_directory + '/*.dcm')\n        number_of_slices = len(slice_names)\n        scan = ScansRepository.add_new_scan(dataset, number_of_slices, None)\n\n        for slice_name in slice_names:\n            logger.info('Adding new Slice to Scan \"%s\" based on \"%s\".', scan.id, slice_name)\n            with open(slice_name, 'rb') as slice_dicom_file:\n                _slice = scan.add_slice()\n                image = slice_dicom_file.read()\n                parse_dicom_and_update_slice.delay(_slice.id, image)\n", "path": "backend/scripts/import_data.py"}, {"content": "\"\"\"Script that will convert multiple dicoms to PNG format.\n\nHow to use it?\n--------------\nAt first, download some scans from anywhere on the Internet. You can use example dataset from Data Science Bowl 2017:\nhttps://www.kaggle.com/c/data-science-bowl-2017/data (look for 'sample_images.7z' file).\n\nThen, place these data (unzipped) anywhere on your computer and run this script by:\n\n    (venv) $ python3.7 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/\n\nName of the converted Dicom file is a position of the scan on the z axis.\n\"\"\"\nimport os\nimport argparse\n\nimport SimpleITK as sitk\nfrom PIL import Image\n\nfrom medtagger.conversion import convert_slice_to_normalized_8bit_array\nfrom medtagger.definitions import DicomTag\nfrom medtagger.dicoms import read_list\n\n\nparser = argparse.ArgumentParser(description='Convert dicoms to png format.')\nparser.add_argument('--input', type=str, required=True, help='Full path to directory where dicoms are located')\nparser.add_argument('--output', type=str, required=True,\n                    help='Full path to directory where converted dicoms would be located')\n\nargs = parser.parse_args()\ndicoms_folder_path = args.input\nconverted_dicoms_folder_path = args.output\n\ndicoms = [sitk.ReadImage(dicoms_folder_path + d) for d in os.listdir(dicoms_folder_path) if\n          os.path.isfile(dicoms_folder_path + d)]\nmin_position = abs(min(float((read_list(dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2]) for dicom in dicoms))\n\nif not os.path.exists(converted_dicoms_folder_path):\n    os.mkdir(converted_dicoms_folder_path)\n\nfor single_dicom in dicoms:\n    image_bytes = convert_slice_to_normalized_8bit_array(single_dicom)\n    slice_position = float((read_list(single_dicom, DicomTag.IMAGE_POSITION_PATIENT) or [])[2])\n    converted_dicom_name = '{0:.2f}'.format(slice_position + min_position)\n    Image.fromarray(image_bytes, 'L').save(converted_dicoms_folder_path + converted_dicom_name + '.png')\n", "path": "backend/scripts/convert_dicoms_to_png.py"}]}