internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: oobabooga/text-generation-webui

Issue:
monkey_patch_llama_cpp_python is not needed
### Describe the bug

A bit busy to do a pull request.
Current (v1.9) version does not work with llama.cpp, solved it by disabling line 54-55 in llama_cpp_python_hijack.py.
```python
    #if return_lib is not None:
        #monkey_patch_llama_cpp_python(return_lib)
```

Guessing that the latest llama-cpp-python version update turned it into a generator so we don't have to patch one.

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

```python
    #if return_lib is not None:
        #monkey_patch_llama_cpp_python(return_lib)
```

### Screenshot

_No response_

### Logs

```shell
included
```


### System Info

```shell
Windows python==3.11
```



Discussion:

Resolving patch:
diff --git a/modules/chat.py b/modules/chat.py
--- a/modules/chat.py
+++ b/modules/chat.py
@@ -577,7 +577,7 @@ def find_all_histories_with_first_prompts(state):
                 data = json.load(f)
 
                 first_prompt = ""
-                if 'visible' in data and len(data['visible']) > 0:
+                if data and 'visible' in data and len(data['visible']) > 0:
                     if data['internal'][0][0] == '<|BEGIN-VISIBLE-CHAT|>':
                         if len(data['visible']) > 1:
                             first_prompt = html.unescape(data['visible'][1][0])
diff --git a/modules/llama_cpp_python_hijack.py b/modules/llama_cpp_python_hijack.py
--- a/modules/llama_cpp_python_hijack.py
+++ b/modules/llama_cpp_python_hijack.py
@@ -100,9 +100,11 @@ def eval_with_progress(self, tokens: Sequence[int]):
 
 
 def monkey_patch_llama_cpp_python(lib):
+    if getattr(lib.Llama, '_is_patched', False):
+        # If the patch is already applied, do nothing
+        return
 
     def my_generate(self, *args, **kwargs):
-
         if shared.args.streaming_llm:
             new_sequence = args[0]
             past_sequence = self._input_ids
@@ -116,3 +118,6 @@ def my_generate(self, *args, **kwargs):
     lib.Llama.eval = eval_with_progress
     lib.Llama.original_generate = lib.Llama.generate
     lib.Llama.generate = my_generate
+
+    # Set the flag to indicate that the patch has been applied
+    lib.Llama._is_patched = True


Test patch:
Repository: Showndarya/Hacktoberfest

Issue:
Travis test ignore first letter of filename for some reason
I'll try and figure out why, thought about simply renaming every file in the travis script but that requires alot of work and overhead for little gain, it is certainly doable, you have to configure the git on the travis instance and make a new commit etc.
Might as well have a cron job or something to it recursively and periodically over the entirety of the repo and make a single commit...


Discussion:
Oh yeah easy catch I'm checking if the first letter is a capital in `A/Axxxxx` instead of the actual filename.

Resolving patch:
diff --git a/.travis.py b/.travis.py
--- a/.travis.py
+++ b/.travis.py
@@ -19,13 +19,13 @@
         if re.search(r"\.json$", changed_file):
             changed_files_json.append(changed_file)
 
-
+ 
 # Iterate over list of changed JSON files.
 for changed_file_json in changed_files_json:
     print(f"Checking file {changed_file_json}...")
     there_was_an_error = False
 
-    if not changed_file_json[0].isupper():
+    if not os.path.basename(changed_file_json)[0].isupper():
         there_was_an_error = True
         print("🔥 File name not capitalized.")
 


Test patch:
Repository: Showndarya/Hacktoberfest

Issue:
Make JSON linting more verbose ?
Currently we simply check :
1. json is valid
2. json contains the keys we want
3. those keys are not empty

the problem is with step 1, it's not very helpful if people have no idea what the JSON spec is.

One fix is :
1. add a link to jsonlint.com or such a service in the print of the error so that people can check themselves.
2. add something like http://deron.meranda.us/python/demjson/ with proper package caching on travis side, but it will make for slower builds still probably


Discussion:
Might also want to look into http://www.fixjson.com

I tried it on https://github.com/Showndarya/Hacktoberfest/pull/442/files and it would have added the missing commas

Resolving patch:
diff --git a/.travis.py b/.travis.py
--- a/.travis.py
+++ b/.travis.py
@@ -34,7 +34,7 @@
             file_content = json.loads(data_file.read())
     except json.decoder.JSONDecodeError:
         there_was_an_error = True
-        print("🔥 JSON could not be parsed.")
+        print(f"🔥 JSON could not be parsed. Follow this link to know more : https://jsonlint.com/?json={data_file.read()}")
 
     if 'word' not in file_content:
         there_was_an_error = True


Test patch:
Repository: feast-dev/feast

Issue:
Python SDK fails to apply feature when submitting job
## Expected Behavior 

When using the Python SDK to start an import job, the `run` method should be able to `apply` features within the import.

## Current Behavior

The run method returns an error:

```
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/xxx/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/xxx/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/xxx/projects/feast/sdk/python/run.py", line 98, in <module>
    fs.run(importer, apply_features=True, apply_entity=True)
  File "/home/xxx/projects/feast/sdk/python/feast/sdk/client.py", line 169, in run
    self._apply_feature(feature)
  File "/home/xxx/projects/feast/sdk/python/feast/sdk/client.py", line 392, in _apply_feature
    response = self._core_service_stub.ApplyFeature(feature.spec)
AttributeError: 'str' object has no attribute 'spec'
```

## Steps to reproduce

Running the following code from the `0.0.1` Python SDK quickstart.

```
fs = Client(core_url=FEAST_CORE_URL, verbose=True)

serving_ds=Datastore(id='REDIS1')
warehouse_ds=Datastore(id='BIGQUERY1')

# Create importer
importer = Importer.from_df(df_complete, 
                           entity='ride', 
                           granularity=Granularity.NONE,
                           owner='user@website.com',  
                           staging_location=STAGING_LOCATION,
                           id_column='ride', 
                           timestamp_column='pickup_datetime',
                           serving_store=serving_ds,
                           warehouse_store=warehouse_ds)

# Update feature and entity metadata. Ideally you want to update these manually
# so that they contain adequate information for the next user
importer.entity.description = 'nyc taxi dataset' 
for feature_id in importer.features:
    importer.features[feature_id].description = 'nyc taxi dataset'
    
# Ingest the feature data into the store
fs.run(importer, apply_features=True, apply_entity=True)
```

### Specifications

- Version: 0.0.1
- Platform: Ubuntu 18.04
- Subsystem:

## Possible Solution



Discussion:

Resolving patch:
diff --git a/sdk/python/feast/sdk/client.py b/sdk/python/feast/sdk/client.py
--- a/sdk/python/feast/sdk/client.py
+++ b/sdk/python/feast/sdk/client.py
@@ -166,7 +166,7 @@ def run(self, importer, name_override=None,
             self._apply_entity(importer.entity)
         if apply_features:
             for feature in importer.features:
-                self._apply_feature(feature)
+                self._apply_feature(importer.features[feature])
 
         if importer.require_staging:
             print("Staging file to remote path {}"


Test patch:
Repository: feast-dev/feast

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


Discussion:
This is a good issue. We can easily add a flag to the Python SDK to support this. For 0.3.0 the CLI is created from the SDK.
This is a good issue. We can easily add a flag to the Python SDK to support this. For 0.3.0 the CLI is created from the SDK.

Resolving patch:
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"
 
 


Test patch:
Repository: feast-dev/feast

Issue:
Deduplicate example notebooks
Currently we have two sets of example notebooks for Feast
1. [Examples](https://github.com/gojek/feast/tree/master/examples/basic)
2. [Docker compose](https://github.com/gojek/feast/tree/master/infra/docker-compose/jupyter/notebooks)

The docker compose notebooks can be deduplicated so that all examples are only contained in the root of the project. This would make management easier.


Discussion:
hi @woop, I used the latest master branch and it failed in ingestion when i run [Examples](https://github.com/gojek/feast/tree/master/examples/basic) outside `http://localhost:8888/tree/feast-notebooks`. 
So i tried to run it in `http://localhost:8888/tree/feast-notebooks` by changed the core-url and serving-url as in the [Docker compose](https://github.com/gojek/feast/tree/master/infra/docker-compose/jupyter/notebooks) and it works. 

Is it possible to run [Examples](https://github.com/gojek/feast/tree/master/examples/basic) outside the `http://localhost:8888/tree/feast-notebooks` ? so i wouldn't enter the `jupyter` container to ingest data into feast. Thankyou
Hi @napitupulusThank you for being so patient.

Would it be possible to create a new issue perhaps? I dont think its on topic for this issue (deduplication of notebooks).

You should be able to run ingestion from outside Jupyter. I suspect that the problem is that you have a firewall blocking Kafka. The important part is that you expose the ingestion port from Kafka correctly. If you are unable to connect to the Kafka cluster then ingestion will fail.

Resolving patch:
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import os
+import subprocess
 
 from setuptools import find_packages, setup
 
@@ -48,7 +49,13 @@
 ]
 
 # README file from Feast repo root directory
-README_FILE = os.path.join(os.path.dirname(__file__), "..", "..", "README.md")
+repo_root = (
+    subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE)
+    .communicate()[0]
+    .rstrip()
+    .decode("utf-8")
+)
+README_FILE = os.path.join(repo_root, "README.md")
 with open(os.path.join(README_FILE), "r") as f:
     LONG_DESCRIPTION = f.read()
 


Test patch:
Repository: feast-dev/feast

Issue:
feast cli feature-sets describe broken
## Expected Behavior 
`feast feature-sets describe <name>` cannot be used because it doesn't allow the user to set a project, nor does it default to any value.

## Steps to reproduce
Call `feast feature-sets describe <some_feature_set>`

### Specifications

- Version: 0.5.0

## Possible Solution

The method calls `fs = feast_client.get_feature_set(name=name)`. Since no project is provided to `get_feature_set`, a default project needs to be set in the client. 

Either 
1. Allow users to pass feature set ids with projects specified (`project/feature_set`) or
2. Allow users to set a default project.

The method should fall back to a default project (`default`) should one not be provided.



Discussion:

Resolving patch:
diff --git a/sdk/python/feast/cli.py b/sdk/python/feast/cli.py
--- a/sdk/python/feast/cli.py
+++ b/sdk/python/feast/cli.py
@@ -156,12 +156,20 @@ def feature_set_create(filename):
 
 @feature_set.command("describe")
 @click.argument("name", type=click.STRING)
-def feature_set_describe(name: str):
+@click.option(
+    "--project",
+    "-p",
+    help="Project that feature set belongs to",
+    type=click.STRING,
+    default="default",
+)
+def feature_set_describe(name: str, project: str):
     """
     Describe a feature set
     """
     feast_client = Client()  # type: Client
-    fs = feast_client.get_feature_set(name=name)
+    fs = feast_client.get_feature_set(name=name, project=project)
+
     if not fs:
         print(f'Feature set with name "{name}" could not be found')
         return


Test patch:
Repository: feast-dev/feast

Issue:
AttributeError: 'dict' object has no attribute 'append' in job.to_chunked_dataframe()
## Expected Behavior 
Return a generator of a chunked dataframe
## Current Behavior
Giving error :
```
/home/dev/feast-venv/lib/python3.7/site-packages/feast/job.py in to_chunked_dataframe(self, max_chunk_size, timeout_sec)
    187         records = []
    188         for result in self.result(timeout_sec=timeout_sec):
--> 189             result.append(records)
    190             if len(records) == max_chunk_size:
    191                 df = pd.DataFrame.from_records(records)
AttributeError: 'dict' object has no attribute 'append'
```
## Steps to reproduce
```
test = job.to_chunked_dataframe(10)
next(test)
```
### Specifications

- Version: 0.5.0
- Platform: Python 3.7
- Subsystem: 

## Possible Solution
In line 189, it should be  `records.append(result)` instead of `result.append(records)`


Discussion:

Resolving patch:
diff --git a/sdk/python/feast/job.py b/sdk/python/feast/job.py
--- a/sdk/python/feast/job.py
+++ b/sdk/python/feast/job.py
@@ -134,13 +134,9 @@ def to_dataframe(
     ) -> pd.DataFrame:
         """
         Wait until a job is done to get an iterable rows of result. This method
-        will split the response into chunked DataFrame of a specified size to
-        to be yielded to the instance calling it.
+        will return the response as a DataFrame.
 
         Args:
-            max_chunk_size (int):
-                Maximum number of rows that the DataFrame should contain.
-
             timeout_sec (int):
                 Max no of seconds to wait until job is done. If "timeout_sec"
                 is exceeded, an exception will be raised.
@@ -180,14 +176,14 @@ def to_chunked_dataframe(
 
         # Max chunk size defined by user
         for result in self.result(timeout_sec=timeout_sec):
-            result.append(records)
+            records.append(result)
             if len(records) == max_chunk_size:
                 df = pd.DataFrame.from_records(records)
                 records.clear()  # Empty records array
                 yield df
 
         # Handle for last chunk that is < max_chunk_size
-        if not records:
+        if records:
             yield pd.DataFrame.from_records(records)
 
     def __iter__(self):


Test patch:
Repository: feast-dev/feast

Issue:
Zeroed entity value causes materialization to fail
If the user uses an INT32 entity type, and sets their entity to `0`, then type_map.py will throw an exception here https://github.com/feast-dev/feast/blob/master/sdk/python/feast/type_map.py#L207 that says `feast_value_type` is of type `None` and does not contain a `name` field.


Discussion:

Resolving patch:
diff --git a/sdk/python/feast/type_map.py b/sdk/python/feast/type_map.py
--- a/sdk/python/feast/type_map.py
+++ b/sdk/python/feast/type_map.py
@@ -330,7 +330,11 @@ def _python_value_to_proto_value(feast_value_type, value) -> ProtoValue:
 def python_value_to_proto_value(
     value: Any, feature_type: ValueType = None
 ) -> ProtoValue:
-    value_type = python_type_to_feast_value_type("", value) if value else feature_type
+    value_type = (
+        python_type_to_feast_value_type("", value)
+        if value is not None
+        else feature_type
+    )
     return _python_value_to_proto_value(value_type, value)
 
 


Test patch:
Repository: feast-dev/feast

Issue:
Bump fastavro version
**Is your feature request related to a problem? Please describe.**
The version of Fastavro that we're using is kinda old and may be buggy soon. It's also causing some version conflicts with packages that have already upgraded to the newer (1.xx) versions.

**Describe the solution you'd like**
Bump Fastavro to 1.x.x



Discussion:
Sounds good to me. @kevinhu do you want to try to take a stab at it?

Resolving patch:
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -40,7 +40,7 @@
 REQUIRED = [
     "Click==7.*",
     "colorama>=0.3.9",
-    "fastavro>=0.22.11,<0.23",
+    "fastavro>=1.1.0",
     "google-api-core>=1.23.0",
     "googleapis-common-protos==1.52.*",
     "grpcio>=1.34.0",


Test patch:
Repository: feast-dev/feast

Issue:
Dependency PyYAML 5.3.* has vulnerability issues
## Expected Behavior 

According to [CVE-2020-14343](https://nvd.nist.gov/vuln/detail/CVE-2020-14343):

> A vulnerability was discovered in the PyYAML library in versions before 5.4, where it is susceptible to arbitrary code execution when it processes untrusted YAML files through the full_load method or with the FullLoader loader. Applications that use the library to process untrusted input may be vulnerable to this flaw. This flaw allows an attacker to execute arbitrary code on the system by abusing the python/object/new constructor. This flaw is due to an incomplete fix for CVE-2020-1747. See CVE-2020-14343.

## Current Behavior

Feast Python SDK requires `PyYAML==5.3.*` version.

This not only affects Feast, but also any app depending on it, since dependencies are shared.

## Steps to reproduce

N/A

### Specifications

N/A

## Possible Solution

Bump PyYAML to a ">=5.4" version.


Discussion:

Resolving patch:
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -52,7 +52,7 @@
     "protobuf>=3.10",
     "pyarrow>=2.0.0",
     "pydantic>=1.0.0",
-    "PyYAML==5.3.*",
+    "PyYAML>=5.4.*",
     "tabulate==0.8.*",
     "tenacity>=7.*",
     "toml==0.10.*",


Test patch:
Repository: feast-dev/feast

Issue:
Add validation for project name
**Is your feature request related to a problem? Please describe.**
A follow up to https://github.com/feast-dev/feast/pull/1752 - I think project name should definitely be validated early on. Otherwise could run into an error message (https://github.com/feast-dev/feast/pull/1752#issue-700598472) that is not obviously related to the project name.

**Describe the solution you'd like**
Validation upon feast apply that checks the project name. Can use the name validation function [here](https://github.com/feast-dev/feast/blob/a548c48927e6f6858d91a93cf356b43fe7c67aad/sdk/python/feast/repo_operations.py#L390).

**Describe alternatives you've considered**
There's probably more validation coverage to be done, and it could be done at a later time if there are higher priorities at the moment.

**Additional context**
@tedhtchang to take this simple addition on per https://github.com/feast-dev/feast/pull/1752#issuecomment-891339661



Discussion:

Resolving patch:
diff --git a/sdk/python/feast/repo_config.py b/sdk/python/feast/repo_config.py
--- a/sdk/python/feast/repo_config.py
+++ b/sdk/python/feast/repo_config.py
@@ -2,7 +2,14 @@
 from typing import Any
 
 import yaml
-from pydantic import BaseModel, StrictInt, StrictStr, ValidationError, root_validator
+from pydantic import (
+    BaseModel,
+    StrictInt,
+    StrictStr,
+    ValidationError,
+    root_validator,
+    validator,
+)
 from pydantic.error_wrappers import ErrorWrapper
 from pydantic.typing import Dict, Optional, Union
 
@@ -180,6 +187,17 @@ def _validate_offline_store_config(cls, values):
 
         return values
 
+    @validator("project")
+    def _validate_project_name(cls, v):
+        from feast.repo_operations import is_valid_name
+
+        if not is_valid_name(v):
+            raise ValueError(
+                f"Project name, {v}, should only have "
+                f"alphanumerical values and underscores but not start with an underscore."
+            )
+        return v
+
 
 class FeastConfigError(Exception):
     def __init__(self, error_message, config_path):


Test patch:
diff --git a/sdk/python/tests/integration/scaffolding/test_repo_config.py b/sdk/python/tests/integration/scaffolding/test_repo_config.py
--- a/sdk/python/tests/integration/scaffolding/test_repo_config.py
+++ b/sdk/python/tests/integration/scaffolding/test_repo_config.py
@@ -153,3 +153,27 @@ def test_no_project():
         "project\n"
         "  field required (type=value_error.missing)",
     )
+
+
+def test_invalid_project_name():
+    _test_config(
+        dedent(
+            """
+        project: foo-1
+        registry: "registry.db"
+        provider: local
+        """
+        ),
+        expect_error="alphanumerical values ",
+    )
+
+    _test_config(
+        dedent(
+            """
+        project: _foo
+        registry: "registry.db"
+        provider: local
+        """
+        ),
+        expect_error="alphanumerical values ",
+    )
Repository: feast-dev/feast

Issue:
Bigquery job id is not found in locations outside of US
## Expected Behavior 
When querying for offline features with bigquery source, the job id is used to get the status of the bigquery job.
 
## Current Behavior
For a location outside of US (southamerica) the job id to get the status is not found.

## Steps to reproduce

### Specifications


## Possible Solution
Pass `bigquery.job.query.QueryJob` object to `client.get_job(job_id).state` instead of job_id as a string. `get_job` will then get the correct location automatically. 


Discussion:
Thanks for raising this @LarsKlingen. Would you be open to submitting a pull request?

Resolving patch:
diff --git a/sdk/python/feast/infra/offline_stores/bigquery.py b/sdk/python/feast/infra/offline_stores/bigquery.py
--- a/sdk/python/feast/infra/offline_stores/bigquery.py
+++ b/sdk/python/feast/infra/offline_stores/bigquery.py
@@ -261,11 +261,10 @@ def block_until_done(
     if is_test:
         retry_cadence = 0.1
 
-    def _wait_until_done(job_id):
-        if client.get_job(job_id).state in ["PENDING", "RUNNING"]:
-            raise BigQueryJobStillRunning(job_id=job_id)
+    def _wait_until_done(bq_job):
+        if client.get_job(bq_job).state in ["PENDING", "RUNNING"]:
+            raise BigQueryJobStillRunning(job_id=bq_job.job_id)
 
-    job_id = bq_job.job_id
     try:
         retryer = Retrying(
             wait=wait_fixed(retry_cadence),
@@ -273,12 +272,12 @@ def _wait_until_done(job_id):
             retry=retry_if_exception_type(BigQueryJobStillRunning),
             reraise=True,
         )
-        retryer(_wait_until_done, job_id)
+        retryer(_wait_until_done, bq_job)
 
     finally:
-        if client.get_job(job_id).state in ["PENDING", "RUNNING"]:
-            client.cancel_job(job_id)
-            raise BigQueryJobCancelled(job_id=job_id)
+        if client.get_job(bq_job).state in ["PENDING", "RUNNING"]:
+            client.cancel_job(bq_job)
+            raise BigQueryJobCancelled(job_id=bq_job.job_id)
 
         if bq_job.exception():
             raise bq_job.exception()


Test patch: