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

[BUG] pf flow serve is broken in promptflow==1.10.0 (NotADirectoryError) #3058

Closed
asos-oliverfrost opened this issue Apr 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working no-recent-activity There has been no recent activity on this issue/pull request

Comments

@asos-oliverfrost
Copy link

asos-oliverfrost commented Apr 28, 2024

Clearly state that you are going to take on implementing it, if that's the case. You can request that the issue be assigned to you.

I'm happy to implement this seems straightforward (possible solution provided below, please confirm if this is the expected behaviour)

Describe the bug

Serving the interactive chat UI appears to have broken. Flask app 'promptflow.core._serving.app' does not start successfully, resulting in an exception and the local app server doesn't open in a browser.

How To Reproduce the bug

Using the following flow.dag.yaml:

$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
  question:
    type: string
    is_chat_input: true
nodes:
- name: parrot
  type: python
  source:
    type: code
    path: ./parrot.py
  inputs:
    question: ${inputs.question}
outputs:
  answer:
    type: string
    reference: ${parrot.output}
    is_chat_output: true

and parrot.py (both files in the same source directory):

from promptflow.core import tool

@tool
def print_hi(question: str):
    return question.upper()

To reproduce the error, run any of the following pf commands below:

pf flow serve --source ./
pf flow serve --source .
pf flow serve --source flow.dag.yaml

Exception raised:

  File "/Users/oliver.frost/.pyenv/versions/3.11.4/lib/python3.11/site-packages/promptflow/_sdk/_utils/serve_utils.py", line 112, in serve_python_flow
    os.chdir(flow_dir)
NotADirectoryError: [Errno 20] Not a directory: '/Users/oliver.frost/PycharmProjects/pf-bug-example/flow.dag.yaml'

Issue resolves when you adjust _resolve_python_flow_additional_includes() to return the parent of the source instead, included below:

def _resolve_python_flow_additional_includes(source) -> Path:
    # Resolve flow additional includes
    from promptflow.client import load_flow

    flow = load_flow(source)
    from promptflow._sdk.operations import FlowOperations

    with FlowOperations._resolve_additional_includes(flow.path) as resolved_flow_path:
        if resolved_flow_path == flow.path:
            # HERE
            return source.parent

Expected behavior

Flask app 'promptflow.core._serving.app' serves successfully and a browser window opens:

Screenshot 2024-04-28 at 09 56 54

Screenshots

Screenshot 2024-04-28 at 09 48 59 Above: the reproducible example in PyCharm. Screenshot 2024-04-28 at 09 54 00 ^ above: same error reproduced in Python 3.9.x

Running Information(please complete the following information):

  • Promptflow == 1.10.0
  • Operating System: Mac OS X 14.4.1 (23E224)
  • Python Version 3.11.4
@asos-oliverfrost asos-oliverfrost added the bug Something isn't working label Apr 28, 2024
@asos-oliverfrost asos-oliverfrost changed the title [BUG] [BUG] pf flow serve is broken in promptflow==1.10.0 Apr 28, 2024
@asos-oliverfrost asos-oliverfrost changed the title [BUG] pf flow serve is broken in promptflow==1.10.0 [BUG] pf flow serve is broken in promptflow==1.10.0 (NotADirectoryError) Apr 28, 2024
@brynn-code
Copy link
Contributor

@asos-oliverfrost Thanks for reporting this! We will fix this asap in the postfix 1.10.1.

@asos-oliverfrost
Copy link
Author

Thanks for the reply! I was hoping to take a crack at this, as we've worked a lot with promptflow and I was hoping to become more active as a contributor :)

@brynn-code
Copy link
Contributor

Haha, thank you, we are fixing this here #3070 because this related to some code refine works not so long ago, and this breaks 1.10.0 so it's a little hurry to ship the fix in 1.10.1, I believe you've been our contributor by reporting this, really appreciate it, and contribute code changes will not be too far for you 😆, thanks again. @asos-oliverfrost

Copy link

Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue/pull request label May 30, 2024
@brynn-code
Copy link
Contributor

Close as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-recent-activity There has been no recent activity on this issue/pull request
Projects
None yet
Development

No branches or pull requests

3 participants