Image-Text-to-Text
Transformers
ONNX
Safetensors
English
idefics3
conversational

Got an error of AttributeError: 'str' object has no attribute 'with_suffix'

#15
by EliasKim - opened

I got an error of

File "/home/ubuntu/workspace/docling/.venv/lib/python3.12/site-packages/docling_core/types/doc/document.py", line 2747, in _get_output_paths
artifacts_dir = filename.with_suffix("")
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'with_suffix'

Any help?

Thank you.

Docling org

Hello Elias,
Can you please post what code or line that triggered this?

I got the same error, in this line:

doc.save_as_markdown(output_path_md)

My solution:

    output_path_md = os.path.join(OUTPUT_DIR, output_filename_md)
    markdown_content = doc.export_to_markdown()

    with open(output_path_md, "w") as file:
        file.write(markdown_content)

For me, the following worked:
from pathlib import Path
results = doc.save_as_html(Path(output_filename))

Hello Elias,
Can you please post what code or line that triggered this?

When I run the example code on Model Card page, Fast Batch Inference Using VLLM, I got the error following in the docling-core module.

Traceback (most recent call last):
File "/home/ubuntu/workspace/docling/test.py", line 61, in
doc.save_as_markdown(output_path_md)
File "/home/ubuntu/workspace/docling/.venv/lib/python3.12/site-packages/docling_core/types/doc/document.py", line 2575, in save_as_markdown
artifacts_dir, reference_path = self._get_output_paths(filename, artifacts_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/workspace/docling/.venv/lib/python3.12/site-packages/docling_core/types/doc/document.py", line 2749, in _get_output_paths
artifacts_dir = artifacts_dir.with_name(artifacts_dir.name + "_artifacts")
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'with_name'

Docling org

Sorry for the confusion, the code examples in the readme have been fixed!

asnassar changed discussion status to closed

Sign up or log in to comment