Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename default value of HAYHOOKS_ADDITIONAL_PYTHONPATH #28

Closed
alex-stoica opened this issue Jun 15, 2024 · 5 comments · Fixed by #29
Closed

Rename default value of HAYHOOKS_ADDITIONAL_PYTHONPATH #28

alex-stoica opened this issue Jun 15, 2024 · 5 comments · Fixed by #29
Assignees

Comments

@alex-stoica
Copy link
Contributor

Currently, it is opt/custom-components. I recommend renaming it to opt/custom_components for improved consistency with Python naming conventions. This change will facilitate more intuitive imports, such as:
from custom_components.some_custom_component import MyCustomComponent

@masci
Copy link
Contributor

masci commented Jun 17, 2024

Hi @alex-stoica do you mind opening a quick PR? I'll review and merge!

@karbasia
Copy link

@masci @alex-stoica is there anything special needed to import custom components?

My HAYHOOKS_ADDITIONAL_PYTHONPATH is set to /opt/custom_components and I see the files on my container. When attempting to import the pipeline, I am greeted with this error message:

Error deploying pipeline: Unable to parse Haystack Pipeline ingest_pipeline: Component 'custom_components.ocr_pdf.OCRPDFToDocument' not imported.

My pipelines run fine locally (using the same custom_components folder in my local environment) and pipelines without custom components are also correctly imported.

I have a simple docker compose too:

services:
  hayhooks:
    container_name: hayhooks
    image: hayhooks:local
    ports:
      - 1416:1416
    volumes:
      - ./pipelines:/opt/pipelines
      - ./custom_components:/opt/custom_components
      - ./data:/data
    healthcheck:
      test: ["CMD-SHELL", "curl --silent --fail localhost:1416/status || exit 1"]
      interval: 120s
      timeout: 30s
      retries: 3
    env_file:
      - .env
networks:
  default:
    name: local

@karbasia
Copy link

Ok, got it. I had to remove "custom_components" from my yaml. The type simply became type: ocr_pdf.OCRPDFToDocument

@alex-stoica
Copy link
Contributor Author

@karbasia what I did to work is

    environment:
      - PYTHONPATH=/opt

In my docker file + maintained custom_components in my pipeline yaml
A working example I used is in #27 (with the only difference that - HAYHOOKS_ADDITIONAL_PYTHONPATH=/opt/custom_components is no longer necessary as this PR already was merged to the main branch

Anyway, I guess that removing custom_components works too

@karbasia
Copy link

Thanks for the info! I ended up revisiting my configuration and updating my custom_components mounts so that I can keep the custom_components in my imports and yaml.

Your solution is much cleaner though, so I'll make the necessary adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants