'Generator[Dict[str,pyobj]]' object has no attribute '__to_py__'
darklord1807 opened this issue · 1 comments
Hello,
Getting below error:
internal.codon:592:36-49: error: 'Generator[Dict[str,pyobj]]' object has no attribute 'to_py'
├─ :942:942: error: during the realization of to_py(slf: Tuple[pyobj,Generator[Dict[str,pyobj]]])
├─ python.codon:1187:19-35: error: during the realization of to_py(self: Tuple[pyobj,Generator[Dict[str,pyobj]]])
├─ load_access_log_file.py:110:13-72: error: during the realization of call(self: pyobj, *args: Tuple[pyobj,Generator[Dict[str,pyobj]]], **kwargs: KwTuple.N0)
╰─ load_access_log_file.py:146:1-52: error: during the realization of bulk_index_to_elasticsearch(es: pyobj, index: str, folder_path: str, chunk_size: int)
Code:
def bulk_index_to_elasticsearch(es, index, folder_path, chunk_size=10000):
"""Index logs to Elasticsearch in bulk."""
count = 0
for chunk in read_logs_with_pandas(folder_path, chunk_size):
count = count + 1
try:
elasticsearch.helpers.bulk(es, doc_generator(chunk, index))
except elasticsearch.helpers.BulkIndexError as e:
print(f"{len(e.errors)} documents failed to index.")
for error in e.errors:
# Each 'error' is a dictionary representing the error details
print(error)
print("Indexed: " + str(count * chunk_size))
Kindly advise
Codon generators are currently not translatable to Python. You can collect them (via list()
) and pass them to Python function.