0

I have a Vertex AI pipeline that uses a Python component.

@component(
    base_image="python:3.9",
    packages_to_install=[lots!],      
)

def my_comp(
parms
) -> str:
    from google.cloud import aiplatform
    aiplatform.init(project=project, location=location)
    bill=x.y()  

and in x.py:

class y:

How do I use x.y in the component? I have tried importing into the component and the jupyter notebook that creates the whole pipeline but the component doesn't see it. I have tried from x import y and also import x. x.py is in the same folder as the jupyter notebook.

schoon
  • 2,858
  • 3
  • 46
  • 78
  • Please specify actual file names, code, and error messages. For import issues, exact details often are important. – John Hanley Apr 20 '23 at 17:31
  • Ok thanks. I don't have access right now but as a general concept should what I'm doing be possible? Ie import to the component from a local.py? – schoon Apr 21 '23 at 05:14

1 Answers1

0

You can't just load a class from a local file.

Each component runs a standalone container (defined in the @component decorator) that does not have access to your local machine or anything outside itself.

If you need a library that you cannot just pip install and make use of the packages_to_install input, your best solution is probably to create a custom container that includes it, and update the base_image keyword input.

100tifiko
  • 361
  • 1
  • 10