prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  ENH: configurable XINFERENCE_HOME
  ### Is your feature request related to a problem? Please describe
  XINFERENCE_HOME should be configurable.
  
  ### Describe the solution you'd like
  We could starts with supporting the XINFERENCE_HOME env variable. This could be done by adding an util `get_xinference_home` and make sure this is the only way to get xinference home.
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `xinference/constants.py`
  Content:
  ```
  1 # Copyright 2022-2023 XProbe Inc.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import os
  16 from pathlib import Path
  17 
  18 XINFERENCE_HOME = str(Path.home() / ".xinference")
  19 XINFERENCE_CACHE_DIR = os.path.join(XINFERENCE_HOME, "cache")
  20 XINFERENCE_MODEL_DIR = os.path.join(XINFERENCE_HOME, "model")
  21 XINFERENCE_LOG_DIR = os.path.join(XINFERENCE_HOME, "logs")
  22 XINFERENCE_IMAGE_DIR = os.path.join(XINFERENCE_HOME, "image")
  23 
  24 XINFERENCE_DEFAULT_LOCAL_HOST = "127.0.0.1"
  25 XINFERENCE_DEFAULT_DISTRIBUTED_HOST = "0.0.0.0"
  26 XINFERENCE_DEFAULT_ENDPOINT_PORT = 9997
  27 
  28 XINFERENCE_ENV_ENDPOINT = "XINFERENCE_ENDPOINT"
  29 XINFERENCE_ENV_MODEL_SRC = "XINFERENCE_MODEL_SRC"
  30
  ```
  --- 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/xinference/constants.py b/xinference/constants.py
  --- a/xinference/constants.py
  +++ b/xinference/constants.py
  @@ -15,7 +15,16 @@
   import os
   from pathlib import Path
   
  -XINFERENCE_HOME = str(Path.home() / ".xinference")
  +XINFERENCE_ENV_ENDPOINT = "XINFERENCE_ENDPOINT"
  +XINFERENCE_ENV_MODEL_SRC = "XINFERENCE_MODEL_SRC"
  +XINFERENCE_ENV_HOME_PATH = "XINFERENCE_HOME"
  +
  +
  +def get_xinference_home():
  +    return os.environ.get(XINFERENCE_ENV_HOME_PATH, str(Path.home() / ".xinference"))
  +
  +
  +XINFERENCE_HOME = get_xinference_home()
   XINFERENCE_CACHE_DIR = os.path.join(XINFERENCE_HOME, "cache")
   XINFERENCE_MODEL_DIR = os.path.join(XINFERENCE_HOME, "model")
   XINFERENCE_LOG_DIR = os.path.join(XINFERENCE_HOME, "logs")
  @@ -24,6 +33,3 @@
   XINFERENCE_DEFAULT_LOCAL_HOST = "127.0.0.1"
   XINFERENCE_DEFAULT_DISTRIBUTED_HOST = "0.0.0.0"
   XINFERENCE_DEFAULT_ENDPOINT_PORT = 9997
  -
  -XINFERENCE_ENV_ENDPOINT = "XINFERENCE_ENDPOINT"
  -XINFERENCE_ENV_MODEL_SRC = "XINFERENCE_MODEL_SRC"
  
verification_info: {"golden_diff": "diff --git a/xinference/constants.py b/xinference/constants.py\n--- a/xinference/constants.py\n+++ b/xinference/constants.py\n@@ -15,7 +15,16 @@\n import os\n from pathlib import Path\n \n-XINFERENCE_HOME = str(Path.home() / \".xinference\")\n+XINFERENCE_ENV_ENDPOINT = \"XINFERENCE_ENDPOINT\"\n+XINFERENCE_ENV_MODEL_SRC = \"XINFERENCE_MODEL_SRC\"\n+XINFERENCE_ENV_HOME_PATH = \"XINFERENCE_HOME\"\n+\n+\n+def get_xinference_home():\n+    return os.environ.get(XINFERENCE_ENV_HOME_PATH, str(Path.home() / \".xinference\"))\n+\n+\n+XINFERENCE_HOME = get_xinference_home()\n XINFERENCE_CACHE_DIR = os.path.join(XINFERENCE_HOME, \"cache\")\n XINFERENCE_MODEL_DIR = os.path.join(XINFERENCE_HOME, \"model\")\n XINFERENCE_LOG_DIR = os.path.join(XINFERENCE_HOME, \"logs\")\n@@ -24,6 +33,3 @@\n XINFERENCE_DEFAULT_LOCAL_HOST = \"127.0.0.1\"\n XINFERENCE_DEFAULT_DISTRIBUTED_HOST = \"0.0.0.0\"\n XINFERENCE_DEFAULT_ENDPOINT_PORT = 9997\n-\n-XINFERENCE_ENV_ENDPOINT = \"XINFERENCE_ENDPOINT\"\n-XINFERENCE_ENV_MODEL_SRC = \"XINFERENCE_MODEL_SRC\"\n", "issue": "ENH: configurable XINFERENCE_HOME\n### Is your feature request related to a problem? Please describe\r\nXINFERENCE_HOME should be configurable.\r\n\r\n### Describe the solution you'd like\r\nWe could starts with supporting the XINFERENCE_HOME env variable. This could be done by adding an util `get_xinference_home` and make sure this is the only way to get xinference home.\r\n\r\n\n", "before_files": [{"content": "# Copyright 2022-2023 XProbe Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nfrom pathlib import Path\n\nXINFERENCE_HOME = str(Path.home() / \".xinference\")\nXINFERENCE_CACHE_DIR = os.path.join(XINFERENCE_HOME, \"cache\")\nXINFERENCE_MODEL_DIR = os.path.join(XINFERENCE_HOME, \"model\")\nXINFERENCE_LOG_DIR = os.path.join(XINFERENCE_HOME, \"logs\")\nXINFERENCE_IMAGE_DIR = os.path.join(XINFERENCE_HOME, \"image\")\n\nXINFERENCE_DEFAULT_LOCAL_HOST = \"127.0.0.1\"\nXINFERENCE_DEFAULT_DISTRIBUTED_HOST = \"0.0.0.0\"\nXINFERENCE_DEFAULT_ENDPOINT_PORT = 9997\n\nXINFERENCE_ENV_ENDPOINT = \"XINFERENCE_ENDPOINT\"\nXINFERENCE_ENV_MODEL_SRC = \"XINFERENCE_MODEL_SRC\"\n", "path": "xinference/constants.py"}], "after_files": [{"content": "# Copyright 2022-2023 XProbe Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nfrom pathlib import Path\n\nXINFERENCE_ENV_ENDPOINT = \"XINFERENCE_ENDPOINT\"\nXINFERENCE_ENV_MODEL_SRC = \"XINFERENCE_MODEL_SRC\"\nXINFERENCE_ENV_HOME_PATH = \"XINFERENCE_HOME\"\n\n\ndef get_xinference_home():\n    return os.environ.get(XINFERENCE_ENV_HOME_PATH, str(Path.home() / \".xinference\"))\n\n\nXINFERENCE_HOME = get_xinference_home()\nXINFERENCE_CACHE_DIR = os.path.join(XINFERENCE_HOME, \"cache\")\nXINFERENCE_MODEL_DIR = os.path.join(XINFERENCE_HOME, \"model\")\nXINFERENCE_LOG_DIR = os.path.join(XINFERENCE_HOME, \"logs\")\nXINFERENCE_IMAGE_DIR = os.path.join(XINFERENCE_HOME, \"image\")\n\nXINFERENCE_DEFAULT_LOCAL_HOST = \"127.0.0.1\"\nXINFERENCE_DEFAULT_DISTRIBUTED_HOST = \"0.0.0.0\"\nXINFERENCE_DEFAULT_ENDPOINT_PORT = 9997\n", "path": "xinference/constants.py"}]}