prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Feast cli config file should be settable by an env var
  **Is your feature request related to a problem? Please describe.**
  
  If I have multiple feast instances, I want to be able to set different .feast files to configure the CLI.
  
  **Describe the solution you'd like**
  
  export FEAST_CONFIG=path/to/feast/configfile
  
  it should default to ~/.feast
  Feast cli config file should be settable by an env var
  **Is your feature request related to a problem? Please describe.**
  
  If I have multiple feast instances, I want to be able to set different .feast files to configure the CLI.
  
  **Describe the solution you'd like**
  
  export FEAST_CONFIG=path/to/feast/configfile
  
  it should default to ~/.feast
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sdk/python/feast/config.py`
  Content:
  ```
  1 #
  2 #  Copyright 2019 The Feast Authors
  3 #
  4 #  Licensed under the Apache License, Version 2.0 (the "License");
  5 #  you may not use this file except in compliance with the License.
  6 #  You may obtain a copy of the License at
  7 #
  8 #      https://www.apache.org/licenses/LICENSE-2.0
  9 #
  10 #  Unless required by applicable law or agreed to in writing, software
  11 #  distributed under the License is distributed on an "AS IS" BASIS,
  12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 #  See the License for the specific language governing permissions and
  14 #  limitations under the License.
  15 #
  16 
  17 from os.path import expanduser, join
  18 import logging
  19 import os
  20 import sys
  21 from typing import Dict
  22 from urllib.parse import urlparse
  23 from urllib.parse import ParseResult
  24 
  25 import toml
  26 
  27 _logger = logging.getLogger(__name__)
  28 
  29 feast_configuration_properties = {"core_url": "URL", "serving_url": "URL"}
  30 
  31 CONFIGURATION_FILE_DIR = ".feast"
  32 CONFIGURATION_FILE_NAME = "config.toml"
  33 
  34 
  35 def get_or_create_config() -> Dict:
  36     """
  37     Creates or gets the Feast users active configuration
  38     :return: dictionary of Feast properties
  39     """
  40 
  41     user_config_file_dir, user_config_file_path = _get_config_file_locations()
  42 
  43     if not os.path.exists(os.path.dirname(user_config_file_dir)):
  44         os.makedirs(os.path.dirname(user_config_file_dir))
  45 
  46     if not os.path.isfile(user_config_file_path):
  47         _save_config(user_config_file_path, _fproperties_to_dict())
  48 
  49     try:
  50         return toml.load(user_config_file_path)
  51     except FileNotFoundError:
  52         _logger.error(
  53             "Could not find Feast configuration file " + user_config_file_path
  54         )
  55         sys.exit(1)
  56     except toml.decoder.TomlDecodeError:
  57         _logger.error(
  58             "Could not decode Feast configuration file " + user_config_file_path
  59         )
  60         sys.exit(1)
  61     except Exception as e:
  62         _logger.error(e)
  63         sys.exit(1)
  64 
  65 
  66 def set_property(fproperty: str, value: str):
  67     """
  68     Sets a single property in the Feast users local configuration file
  69     :param fproperty: Feast property name
  70     :param value: Feast property value
  71     """
  72 
  73     if _is_valid_property(fproperty, value):
  74         active_feast_config = get_or_create_config()
  75         active_feast_config[fproperty] = value
  76         _, user_config_file_path = _get_config_file_locations()
  77         _save_config(user_config_file_path, active_feast_config)
  78         print("Updated property [%s]" % fproperty)
  79     else:
  80         _logger.error("Invalid property selected")
  81         sys.exit(1)
  82 
  83 
  84 def get_config_property_or_fail(fproperty):
  85     active_feast_config = get_or_create_config()
  86     if _is_valid_property(fproperty, active_feast_config[fproperty]):
  87         return active_feast_config[fproperty]
  88     _logger.error("Could not load Feast property from configuration: %s" % fproperty)
  89     sys.exit(1)
  90 
  91 
  92 def _fproperties_to_dict() -> Dict[str, str]:
  93     prop_dict = {}
  94     for fproperty in feast_configuration_properties:
  95         prop_dict[fproperty] = ""
  96     return prop_dict
  97 
  98 
  99 def _is_valid_property(fproperty: str, value: str) -> bool:
  100     """
  101     Validates both a Feast property as well as value
  102     :param fproperty: Feast property name
  103     :param value: Feast property value
  104     :return: Returns True if property and value are valid
  105     """
  106 
  107     if fproperty not in feast_configuration_properties:
  108         _logger.error("You are trying to set an invalid property")
  109         sys.exit(1)
  110 
  111     fprop_type = feast_configuration_properties[fproperty]
  112 
  113     if fprop_type == "URL":
  114         if "//" not in value:
  115             value = "%s%s" % ("grpc://", value)
  116         parsed_value = urlparse(value)  # type: ParseResult
  117         if parsed_value.netloc:
  118             return True
  119 
  120     _logger.error("The property you are trying to set could not be identified")
  121     sys.exit(1)
  122 
  123 
  124 def _save_config(user_config_file_path: str, config_string: Dict[str, str]):
  125     """
  126     Saves Feast configuration
  127     :param user_config_file_path: Local file system path to save configuration
  128     :param config_string: Contents in dictionary format to save to path
  129     """
  130 
  131     try:
  132         with open(user_config_file_path, "w+") as f:
  133             toml.dump(config_string, f)
  134     except Exception as e:
  135         _logger.error("Could not update configuration file for Feast")
  136         print(e)
  137         sys.exit(1)
  138 
  139 
  140 def _get_config_file_locations() -> (str, str):
  141     user_config_file_dir = join(expanduser("~"), CONFIGURATION_FILE_DIR)
  142     user_config_file_path = join(user_config_file_dir, CONFIGURATION_FILE_NAME)
  143     return user_config_file_dir, user_config_file_path
  144
  ```
  --- 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/sdk/python/feast/config.py b/sdk/python/feast/config.py
  --- a/sdk/python/feast/config.py
  +++ b/sdk/python/feast/config.py
  @@ -28,7 +28,7 @@
   
   feast_configuration_properties = {"core_url": "URL", "serving_url": "URL"}
   
  -CONFIGURATION_FILE_DIR = ".feast"
  +CONFIGURATION_FILE_DIR = os.environ.get("FEAST_CONFIG", ".feast")
   CONFIGURATION_FILE_NAME = "config.toml"
  
verification_info: {"golden_diff": "diff --git a/sdk/python/feast/config.py b/sdk/python/feast/config.py\n--- a/sdk/python/feast/config.py\n+++ b/sdk/python/feast/config.py\n@@ -28,7 +28,7 @@\n \n feast_configuration_properties = {\"core_url\": \"URL\", \"serving_url\": \"URL\"}\n \n-CONFIGURATION_FILE_DIR = \".feast\"\n+CONFIGURATION_FILE_DIR = os.environ.get(\"FEAST_CONFIG\", \".feast\")\n CONFIGURATION_FILE_NAME = \"config.toml\"\n", "issue": "Feast cli config file should be settable by an env var\n**Is your feature request related to a problem? Please describe.**\r\n\r\nIf I have multiple feast instances, I want to be able to set different .feast files to configure the CLI.\r\n\r\n**Describe the solution you'd like**\r\n\r\nexport FEAST_CONFIG=path/to/feast/configfile\r\n\r\nit should default to ~/.feast\nFeast cli config file should be settable by an env var\n**Is your feature request related to a problem? Please describe.**\r\n\r\nIf I have multiple feast instances, I want to be able to set different .feast files to configure the CLI.\r\n\r\n**Describe the solution you'd like**\r\n\r\nexport FEAST_CONFIG=path/to/feast/configfile\r\n\r\nit should default to ~/.feast\n", "before_files": [{"content": "#\n#  Copyright 2019 The Feast Authors\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#      https://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#\n\nfrom os.path import expanduser, join\nimport logging\nimport os\nimport sys\nfrom typing import Dict\nfrom urllib.parse import urlparse\nfrom urllib.parse import ParseResult\n\nimport toml\n\n_logger = logging.getLogger(__name__)\n\nfeast_configuration_properties = {\"core_url\": \"URL\", \"serving_url\": \"URL\"}\n\nCONFIGURATION_FILE_DIR = \".feast\"\nCONFIGURATION_FILE_NAME = \"config.toml\"\n\n\ndef get_or_create_config() -> Dict:\n    \"\"\"\n    Creates or gets the Feast users active configuration\n    :return: dictionary of Feast properties\n    \"\"\"\n\n    user_config_file_dir, user_config_file_path = _get_config_file_locations()\n\n    if not os.path.exists(os.path.dirname(user_config_file_dir)):\n        os.makedirs(os.path.dirname(user_config_file_dir))\n\n    if not os.path.isfile(user_config_file_path):\n        _save_config(user_config_file_path, _fproperties_to_dict())\n\n    try:\n        return toml.load(user_config_file_path)\n    except FileNotFoundError:\n        _logger.error(\n            \"Could not find Feast configuration file \" + user_config_file_path\n        )\n        sys.exit(1)\n    except toml.decoder.TomlDecodeError:\n        _logger.error(\n            \"Could not decode Feast configuration file \" + user_config_file_path\n        )\n        sys.exit(1)\n    except Exception as e:\n        _logger.error(e)\n        sys.exit(1)\n\n\ndef set_property(fproperty: str, value: str):\n    \"\"\"\n    Sets a single property in the Feast users local configuration file\n    :param fproperty: Feast property name\n    :param value: Feast property value\n    \"\"\"\n\n    if _is_valid_property(fproperty, value):\n        active_feast_config = get_or_create_config()\n        active_feast_config[fproperty] = value\n        _, user_config_file_path = _get_config_file_locations()\n        _save_config(user_config_file_path, active_feast_config)\n        print(\"Updated property [%s]\" % fproperty)\n    else:\n        _logger.error(\"Invalid property selected\")\n        sys.exit(1)\n\n\ndef get_config_property_or_fail(fproperty):\n    active_feast_config = get_or_create_config()\n    if _is_valid_property(fproperty, active_feast_config[fproperty]):\n        return active_feast_config[fproperty]\n    _logger.error(\"Could not load Feast property from configuration: %s\" % fproperty)\n    sys.exit(1)\n\n\ndef _fproperties_to_dict() -> Dict[str, str]:\n    prop_dict = {}\n    for fproperty in feast_configuration_properties:\n        prop_dict[fproperty] = \"\"\n    return prop_dict\n\n\ndef _is_valid_property(fproperty: str, value: str) -> bool:\n    \"\"\"\n    Validates both a Feast property as well as value\n    :param fproperty: Feast property name\n    :param value: Feast property value\n    :return: Returns True if property and value are valid\n    \"\"\"\n\n    if fproperty not in feast_configuration_properties:\n        _logger.error(\"You are trying to set an invalid property\")\n        sys.exit(1)\n\n    fprop_type = feast_configuration_properties[fproperty]\n\n    if fprop_type == \"URL\":\n        if \"//\" not in value:\n            value = \"%s%s\" % (\"grpc://\", value)\n        parsed_value = urlparse(value)  # type: ParseResult\n        if parsed_value.netloc:\n            return True\n\n    _logger.error(\"The property you are trying to set could not be identified\")\n    sys.exit(1)\n\n\ndef _save_config(user_config_file_path: str, config_string: Dict[str, str]):\n    \"\"\"\n    Saves Feast configuration\n    :param user_config_file_path: Local file system path to save configuration\n    :param config_string: Contents in dictionary format to save to path\n    \"\"\"\n\n    try:\n        with open(user_config_file_path, \"w+\") as f:\n            toml.dump(config_string, f)\n    except Exception as e:\n        _logger.error(\"Could not update configuration file for Feast\")\n        print(e)\n        sys.exit(1)\n\n\ndef _get_config_file_locations() -> (str, str):\n    user_config_file_dir = join(expanduser(\"~\"), CONFIGURATION_FILE_DIR)\n    user_config_file_path = join(user_config_file_dir, CONFIGURATION_FILE_NAME)\n    return user_config_file_dir, user_config_file_path\n", "path": "sdk/python/feast/config.py"}], "after_files": [{"content": "#\n#  Copyright 2019 The Feast Authors\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#      https://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#\n\nfrom os.path import expanduser, join\nimport logging\nimport os\nimport sys\nfrom typing import Dict\nfrom urllib.parse import urlparse\nfrom urllib.parse import ParseResult\n\nimport toml\n\n_logger = logging.getLogger(__name__)\n\nfeast_configuration_properties = {\"core_url\": \"URL\", \"serving_url\": \"URL\"}\n\nCONFIGURATION_FILE_DIR = os.environ.get(\"FEAST_CONFIG\", \".feast\")\nCONFIGURATION_FILE_NAME = \"config.toml\"\n\n\ndef get_or_create_config() -> Dict:\n    \"\"\"\n    Creates or gets the Feast users active configuration\n    :return: dictionary of Feast properties\n    \"\"\"\n\n    user_config_file_dir, user_config_file_path = _get_config_file_locations()\n\n    if not os.path.exists(os.path.dirname(user_config_file_dir)):\n        os.makedirs(os.path.dirname(user_config_file_dir))\n\n    if not os.path.isfile(user_config_file_path):\n        _save_config(user_config_file_path, _fproperties_to_dict())\n\n    try:\n        return toml.load(user_config_file_path)\n    except FileNotFoundError:\n        _logger.error(\n            \"Could not find Feast configuration file \" + user_config_file_path\n        )\n        sys.exit(1)\n    except toml.decoder.TomlDecodeError:\n        _logger.error(\n            \"Could not decode Feast configuration file \" + user_config_file_path\n        )\n        sys.exit(1)\n    except Exception as e:\n        _logger.error(e)\n        sys.exit(1)\n\n\ndef set_property(fproperty: str, value: str):\n    \"\"\"\n    Sets a single property in the Feast users local configuration file\n    :param fproperty: Feast property name\n    :param value: Feast property value\n    \"\"\"\n\n    if _is_valid_property(fproperty, value):\n        active_feast_config = get_or_create_config()\n        active_feast_config[fproperty] = value\n        _, user_config_file_path = _get_config_file_locations()\n        _save_config(user_config_file_path, active_feast_config)\n        print(\"Updated property [%s]\" % fproperty)\n    else:\n        _logger.error(\"Invalid property selected\")\n        sys.exit(1)\n\n\ndef get_config_property_or_fail(fproperty):\n    active_feast_config = get_or_create_config()\n    if _is_valid_property(fproperty, active_feast_config[fproperty]):\n        return active_feast_config[fproperty]\n    _logger.error(\"Could not load Feast property from configuration: %s\" % fproperty)\n    sys.exit(1)\n\n\ndef _fproperties_to_dict() -> Dict[str, str]:\n    prop_dict = {}\n    for fproperty in feast_configuration_properties:\n        prop_dict[fproperty] = \"\"\n    return prop_dict\n\n\ndef _is_valid_property(fproperty: str, value: str) -> bool:\n    \"\"\"\n    Validates both a Feast property as well as value\n    :param fproperty: Feast property name\n    :param value: Feast property value\n    :return: Returns True if property and value are valid\n    \"\"\"\n\n    if fproperty not in feast_configuration_properties:\n        _logger.error(\"You are trying to set an invalid property\")\n        sys.exit(1)\n\n    fprop_type = feast_configuration_properties[fproperty]\n\n    if fprop_type == \"URL\":\n        if \"//\" not in value:\n            value = \"%s%s\" % (\"grpc://\", value)\n        parsed_value = urlparse(value)  # type: ParseResult\n        if parsed_value.netloc:\n            return True\n\n    _logger.error(\"The property you are trying to set could not be identified\")\n    sys.exit(1)\n\n\ndef _save_config(user_config_file_path: str, config_string: Dict[str, str]):\n    \"\"\"\n    Saves Feast configuration\n    :param user_config_file_path: Local file system path to save configuration\n    :param config_string: Contents in dictionary format to save to path\n    \"\"\"\n\n    try:\n        with open(user_config_file_path, \"w+\") as f:\n            toml.dump(config_string, f)\n    except Exception as e:\n        _logger.error(\"Could not update configuration file for Feast\")\n        print(e)\n        sys.exit(1)\n\n\ndef _get_config_file_locations() -> (str, str):\n    user_config_file_dir = join(expanduser(\"~\"), CONFIGURATION_FILE_DIR)\n    user_config_file_path = join(user_config_file_dir, CONFIGURATION_FILE_NAME)\n    return user_config_file_dir, user_config_file_path\n", "path": "sdk/python/feast/config.py"}]}