Skip to content

[BUG] #5

@jonhilgart22

Description

@jonhilgart22

Bug Description

A clear and concise description of what the bug is.

dspy failing for parallel extractions

  Item 11: dspy.settings can only be changed by the thread that initially configured it.
  Item 63: dspy.settings can only be changed by the thread that initially configured it.
  Item 16: dspy.settings can only be changed by the thread that initially configured it.
  Item 29: dspy.settings can only be changed by the thread that initially configured it.
  Item 54: dspy.settings can only be changed by the thread that initially configured it.
  ... and 60 more errors
2025-10-09 18:37:28.101 | ERROR    | pacific.deps.logs:error:79 - Traceback:
Traceback (most recent call last):
  File "/Users/jonathanhilgart/code/pacific-server-3/pacific/data/docetl/organization/langstruct_extraction.py", line 416, in extract_organization_metrics_langstruct
    # Use LangStruct's batch extraction - handles parallelization internally
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonathanhilgart/Library/Caches/pypoetry/virtualenvs/pacific-VPF9xZkC-py3.12/lib/python3.12/site-packages/langstruct/api.py", line 302, in extract
    return self._extract_parallel(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonathanhilgart/Library/Caches/pypoetry/virtualenvs/pacific-VPF9xZkC-py3.12/lib/python3.12/site-packages/langstruct/api.py", line 377, in _extract_parallel
    result.raise_if_failed()
  File "/Users/jonathanhilgart/Library/Caches/pypoetry/virtualenvs/pacific-VPF9xZkC-py3.12/lib/python3.12/site-packages/langstruct/parallel.py", line 90, in raise_if_failed
    raise RuntimeError(msg)
RuntimeError: Failed to process 65 items:
  Item 11: dspy.settings can only be changed by the thread that initially configured it.
  Item 63: dspy.settings can only be changed by the thread that initially configured it.
  Item 16: dspy.settings can only be changed by the thread that initially configured it.
  Item 29: dspy.settings can only be changed by the thread that initially configured it.
  Item 54: dspy.settings can only be changed by the thread that initially configured it.
  ... and 60 more errors

Reproduction Steps

Steps to reproduce the behavior:

  1. Go to '...'
  2. Run '...'
  3. See error

Expected Behavior

A clear and concise description of what you expected to happen.

Actual Behavior

A clear and concise description of what actually happened.

Error Message

Paste any error messages or stack traces here

Environment

  • LangStruct version: [e.g., 0.1.0]
  • Python version: [e.g., 3.12.0]
  • Operating System: [e.g., macOS 14.0, Ubuntu 22.04, Windows 11]
  • LLM Provider: [e.g., OpenAI GPT-4, Google Gemini]

Minimal Code Example

from langstruct import LangStruct

# Minimal code that reproduces the issue
extractor = LangStruct(example={"name": "John"})
result = extractor.extract("Some text")  # This fails

Additional Context

Add any other context about the problem here, such as:

  • Does this happen with all models or just specific ones?
  • Is this related to a specific type of text/document?
  • Any workarounds you've found?

Checklist

  • I have searched existing issues to make sure this isn't a duplicate
  • I have provided a minimal code example that reproduces the issue
  • I have included the complete error message/stack trace
  • I have specified my environment details

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions