prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Cache Docker Images by Branch
  ### Context
  
  We want to be able to cache docker image layers that are created locally as testing artfacts locally to be used by github actions.
  The current prepare_images.sh does this but there was an issue with the definition for branch_name.
  We also don't want to remove support non-ccdl members developing locally.
  
  
  ![image](https://github.com/AlexsLemonade/refinebio/assets/1075609/e984ea3b-658e-41f4-ba61-7d652841e89e)
  
  
  ### Solution or next step
  
  - After #3285 is merged, we should set sensible defaults that can be overridden for external contributors.
  - Get current branch name or tag to be set when pushing images to ccdl(staging) repo.
  
  Determine:
  - If they don't have access to the docker repo should we just build locally and not push?
  - How long can docker tags be / are they compatible with our longer branch names.
  
  
  </issue>
  <code>
  [start of common/setup.py]
  1 import os
  2 
  3 from setuptools import find_packages, setup
  4 
  5 # allow setup.py to be run from any path
  6 os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
  7 
  8 VERSION_FILE = "version"
  9 try:
  10     with open(VERSION_FILE, "rt") as version_file:
  11         version_string = version_file.read().strip().split("-")[0]
  12 except OSError:
  13     print(
  14         "Cannot read version to determine System Version."
  15         " Please create a file common/version containing an up to date System Version."
  16     )
  17     raise
  18 
  19 setup(
  20     name="data-refinery-common",
  21     version=version_string,
  22     packages=find_packages(),
  23     include_package_data=True,
  24     # These values are based on what is in common/requirements.txt.
  25     install_requires=[
  26         "boto3>=1.9.16",
  27         "coverage>=4.5.1",
  28         "daiquiri>=1.5.0",
  29         "django>=3.2,<4",
  30         "raven>=6.9.0",
  31         "requests>=2.10.1",
  32         "retrying>=1.3.3",
  33         "psycopg2-binary>=2.7.5",
  34     ],
  35     license="BSD License",
  36     description="Common functionality to be shared between Data Refinery sub-projects.",
  37     url="https://www.greenelab.com",
  38     author="Kurt Wheeler",
  39     author_email="team@greenelab.com",
  40     classifiers=[
  41         "Environment :: Web Environment",
  42         "Framework :: Django",
  43         "Intended Audience :: Developers",
  44         "License :: OSI Approved :: BSD License",
  45         "Operating System :: Ubuntu",
  46         "Programming Language :: Python",
  47         "Programming Language :: Python :: 3.5",
  48         "Programming Language :: Python :: 3.6",
  49         "Topic :: Internet :: WWW/HTTP",
  50     ],
  51 )
  52
  [end of common/setup.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/common/setup.py b/common/setup.py
  --- a/common/setup.py
  +++ b/common/setup.py
  @@ -1,4 +1,6 @@
   import os
  +import re
  +from datetime import datetime
   
   from setuptools import find_packages, setup
   
  @@ -11,11 +13,21 @@
           version_string = version_file.read().strip().split("-")[0]
   except OSError:
       print(
  -        "Cannot read version to determine System Version."
  -        " Please create a file common/version containing an up to date System Version."
  +        "Cannot read version file to determine system version. "
  +        "Please create a file common/version containing an up to date system version."
       )
       raise
   
  +version_re = re.compile(
  +    r"^([1-9][0-9]*!)?(0|[1-9][0-9]*)"
  +    "(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))"
  +    "?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$"
  +)
  +if not version_re.match(version_string):
  +    # Generate version based on the datetime.now(): e.g., 2023.5.17.dev1684352560.
  +    now = datetime.now()
  +    version_string = f"{now.strftime('%Y.%-m.%-d.dev')}{int(datetime.timestamp(now))}"
  +
   setup(
       name="data-refinery-common",
       version=version_string,
  
verification_info: {"golden_diff": "diff --git a/common/setup.py b/common/setup.py\n--- a/common/setup.py\n+++ b/common/setup.py\n@@ -1,4 +1,6 @@\n import os\n+import re\n+from datetime import datetime\n \n from setuptools import find_packages, setup\n \n@@ -11,11 +13,21 @@\n         version_string = version_file.read().strip().split(\"-\")[0]\n except OSError:\n     print(\n-        \"Cannot read version to determine System Version.\"\n-        \" Please create a file common/version containing an up to date System Version.\"\n+        \"Cannot read version file to determine system version. \"\n+        \"Please create a file common/version containing an up to date system version.\"\n     )\n     raise\n \n+version_re = re.compile(\n+    r\"^([1-9][0-9]*!)?(0|[1-9][0-9]*)\"\n+    \"(\\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))\"\n+    \"?(\\.post(0|[1-9][0-9]*))?(\\.dev(0|[1-9][0-9]*))?$\"\n+)\n+if not version_re.match(version_string):\n+    # Generate version based on the datetime.now(): e.g., 2023.5.17.dev1684352560.\n+    now = datetime.now()\n+    version_string = f\"{now.strftime('%Y.%-m.%-d.dev')}{int(datetime.timestamp(now))}\"\n+\n setup(\n     name=\"data-refinery-common\",\n     version=version_string,\n", "issue": "Cache Docker Images by Branch\n### Context\r\n\r\nWe want to be able to cache docker image layers that are created locally as testing artfacts locally to be used by github actions.\r\nThe current prepare_images.sh does this but there was an issue with the definition for branch_name.\r\nWe also don't want to remove support non-ccdl members developing locally.\r\n\r\n\r\n![image](https://github.com/AlexsLemonade/refinebio/assets/1075609/e984ea3b-658e-41f4-ba61-7d652841e89e)\r\n\r\n\r\n### Solution or next step\r\n\r\n- After #3285 is merged, we should set sensible defaults that can be overridden for external contributors.\r\n- Get current branch name or tag to be set when pushing images to ccdl(staging) repo.\r\n\r\nDetermine:\r\n- If they don't have access to the docker repo should we just build locally and not push?\r\n- How long can docker tags be / are they compatible with our longer branch names.\r\n\n", "before_files": [{"content": "import os\n\nfrom setuptools import find_packages, setup\n\n# allow setup.py to be run from any path\nos.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))\n\nVERSION_FILE = \"version\"\ntry:\n    with open(VERSION_FILE, \"rt\") as version_file:\n        version_string = version_file.read().strip().split(\"-\")[0]\nexcept OSError:\n    print(\n        \"Cannot read version to determine System Version.\"\n        \" Please create a file common/version containing an up to date System Version.\"\n    )\n    raise\n\nsetup(\n    name=\"data-refinery-common\",\n    version=version_string,\n    packages=find_packages(),\n    include_package_data=True,\n    # These values are based on what is in common/requirements.txt.\n    install_requires=[\n        \"boto3>=1.9.16\",\n        \"coverage>=4.5.1\",\n        \"daiquiri>=1.5.0\",\n        \"django>=3.2,<4\",\n        \"raven>=6.9.0\",\n        \"requests>=2.10.1\",\n        \"retrying>=1.3.3\",\n        \"psycopg2-binary>=2.7.5\",\n    ],\n    license=\"BSD License\",\n    description=\"Common functionality to be shared between Data Refinery sub-projects.\",\n    url=\"https://www.greenelab.com\",\n    author=\"Kurt Wheeler\",\n    author_email=\"team@greenelab.com\",\n    classifiers=[\n        \"Environment :: Web Environment\",\n        \"Framework :: Django\",\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Operating System :: Ubuntu\",\n        \"Programming Language :: Python\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Topic :: Internet :: WWW/HTTP\",\n    ],\n)\n", "path": "common/setup.py"}]}