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

Batch run visualization feature does not work in VS Code #3857

Open
tcsatheesh opened this issue Nov 15, 2024 · 17 comments
Open

Batch run visualization feature does not work in VS Code #3857

tcsatheesh opened this issue Nov 15, 2024 · 17 comments
Labels
bug Something isn't working no-recent-activity There has been no recent activity on this issue/pull request

Comments

@tcsatheesh
Copy link

Describe the bug
After a batch run when we select the visualization feature the vs code shows a blank page.

How To Reproduce the bug

  1. Create a standard flow
  2. Run the batch run
  3. Select the batch run in the batch run history
  4. Click on Visualization
  5. A blank page shows up.

Expected behavior
The visualization of the run.

Screenshots
Its an empty screen. Note I can see the html in the temp folder and when I try to open it a browser I get this in the browser console
"GET https://sdk-bulk-test-endpoint.azureedge.net/bulk-test-details/view/0.0.35/bulkTestDetails.min.js net::ERR_ABORTED 409 (Conflict)"

Running Information(please complete the following information):

  • Promptflow Package Version using pf -v: [e.g. 0.0.102309906]
    pf -v
    {
    "promptflow": "1.16.1",
    "promptflow-core": "1.16.1",
    "promptflow-devkit": "1.16.1",
    "promptflow-tracing": "1.16.1"
    }

Executable 'C:\projects\machine_learning\venv\promptflow\Scripts\python.exe'
Python (Windows) 3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)]

  • Operating System: [e.g. Ubuntu 20.04, Windows 11]
    Windows 11
  • Python Version using python --version: [e.g. python==3.10.12]
    python --version
    Python 3.11.9
    Additional context
    Add any other context about the problem here.
@tcsatheesh tcsatheesh added the bug Something isn't working label Nov 15, 2024
@tcsatheesh tcsatheesh changed the title [BUG] Batch run visualization feature does not work in VS Code Nov 15, 2024
@SophieBoule99
Copy link

I am facing the exact same issue.

@polikeiji
Copy link

I'm facing the same issue when accessing the HTML generated by pf run visualize. I think the JS file "bulkTestDetails.min.js" is not accessible in public. I'm wondering if it's the cause of the issue.

$ curl https://sdk-bulk-test-endpoint.azureedge.net/bulk-test-details/view/0.0.35/bulkTestDetails.min.js
...
< HTTP/2 409 
< date: Tue, 03 Dec 2024 04:49:56 GMT
< content-type: application/xml
< content-length: 248
< x-ms-request-id: 82869c26-e01e-0023-4b3e-452444000000
< x-ms-version: 2009-09-19
< x-azure-ref: 20241203T044956Z-167dd484d77qjrlwhC1TYOa6y80000000ku000000000xcqw
< x-fd-int-roxy-purgeid: 50215840
< x-cache: TCP_MISS
< 
<?xml version="1.0" encoding="utf-8"?><Error><Code>PublicAccessNotPermitted</Code><Message>Public access is not permitted on this storage account.
RequestId:82869c26-e01e-0023-4b3e-452444000000
* Connection #0 to host sdk-bulk-test-endpoint.azureedge.net left intact
Time:2024-12-03T04:49:56.9351917Z</Message></Error>

@Ethan-cw
Copy link

I am facing the exact same issue too.

@snw55
Copy link

snw55 commented Dec 16, 2024

+1

@saradhipb
Copy link

When can we expect the issue will be fixed?

@ali-el-moussawi-octo
Copy link

Hello.
Thank you for this great tool
Please we are facing the same issue, we are not able to view the generated html.
When can we expect the issue to be fixed please ?
Best regards

@ali-el-moussawi-octo
Copy link

I'm facing the same issue when accessing the HTML generated by pf run visualize. I think the JS file "bulkTestDetails.min.js" is not accessible in public. I'm wondering if it's the cause of the issue.

$ curl https://sdk-bulk-test-endpoint.azureedge.net/bulk-test-details/view/0.0.35/bulkTestDetails.min.js
...
< HTTP/2 409
< date: Tue, 03 Dec 2024 04:49:56 GMT
< content-type: application/xml
< content-length: 248
< x-ms-request-id: 82869c26-e01e-0023-4b3e-452444000000
< x-ms-version: 2009-09-19
< x-azure-ref: 20241203T044956Z-167dd484d77qjrlwhC1TYOa6y80000000ku000000000xcqw
< x-fd-int-roxy-purgeid: 50215840
< x-cache: TCP_MISS
<

PublicAccessNotPermittedPublic access is not permitted on this storage account.

RequestId:82869c26-e01e-0023-4b3e-452444000000

  • Connection #0 to host sdk-bulk-test-endpoint.azureedge.net left intact
    Time:2024-12-03T04:49:56.9351917Z

+1

@Siu-Keung
Copy link

+1

@gbaeke
Copy link

gbaeke commented Jan 6, 2025

+1

Thank you for fixing it soon!

@ali-el-moussawi-octo
Copy link

Hello,
Thank you for your work.
Any luck fixing this soon ?
I tried to search the internet for a cached version of https://sdk-bulk-test-endpoint.azureedge.net/bulk-test-details/view/0.0.35/bulkTestDetails.min.js but with no success...
Is there a way to get this .js file ?
Best regards

@jgruppen
Copy link

+1

@khchan
Copy link

khchan commented Jan 27, 2025

Hacky workaround - the bulkTestDetails.min.js is still available in git here: https://raw.githubusercontent.com/microsoft/promptflow/8bc2250ae9231093f1d3f2767a786363caa7e5b0/src/promptflow/promptflow/_sdk/data/bulkTestDetails.min.js so you can download it locally then modify the script path here to point to the local file on your machine.

@ali-el-moussawi-octo
Copy link

Hacky workaround - the bulkTestDetails.min.js is still available in git here: https://raw.githubusercontent.com/microsoft/promptflow/8bc2250ae9231093f1d3f2767a786363caa7e5b0/src/promptflow/promptflow/_sdk/data/bulkTestDetails.min.js so you can download it locally then modify the script path here to point to the local file on your machine.

You saved the day ! Thank you !
I had tried to search the web for the file but could not find it, thank you !
The .js is about 3Mb and in my project the pf-visualize.html file is douzens of Mb heavy, so I will paste it inline instead of saving to a local file.

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 Feb 26, 2025
@NinaBundschuh
Copy link

Still not working without using this hacky workaround :(

@gbaeke
Copy link

gbaeke commented Mar 4, 2025

I created this Python script to run pf visualize run, grab the html with the bad link, replace the bad link with a local version of the js file etc...

#!/usr/bin/env python3

import argparse
import os
import re
import shutil
import subprocess
import sys
import urllib.request
from datetime import datetime
from bs4 import BeautifulSoup

def get_run_name():
    """Get run name from command line argument or prompt the user"""
    parser = argparse.ArgumentParser(description='Visualize a PromptFlow run and modify the HTML output.')
    parser.add_argument('--run-name', '-r', help='The name of the run to visualize')
    args = parser.parse_args()
    
    run_name = args.run_name
    if not run_name:
        run_name = input("Enter the run name to visualize: ")
    
    return run_name

def ensure_js_file_exists():
    """Check if flow_visualize.js exists, if not download it"""
    js_path = 'flow_visualize.js'

    # Build full path from current folder
    js_path = os.path.join(os.getcwd(), 'flow_visualize.js')
    
    if not os.path.exists(js_path):
        print(f"flow_visualize.js not found at {js_path}, downloading it...")
        js_url = "https://raw.githubusercontent.com/microsoft/promptflow/8bc2250ae9231093f1d3f2767a786363caa7e5b0/src/promptflow/promptflow/_sdk/data/bulkTestDetails.min.js"
        
        try:
            # Create directory if it doesn't exist
            os.makedirs(os.path.dirname(js_path), exist_ok=True)
            
            # Download the file
            urllib.request.urlretrieve(js_url, js_path)
            print(f"Successfully downloaded flow_visualize.js to {js_path}")
        except Exception as e:
            print(f"Error downloading flow_visualize.js: {e}")
            sys.exit(1)
    else:
        print(f"flow_visualize.js already exists at {js_path}")

def run_pf_visualize(run_name):
    """Run the pf visualize command and return the output"""
    cmd = ["pf", "run", "visualize", "-n", run_name]
    print(f"Running command: {' '.join(cmd)}")
    
    try:
        result = subprocess.run(cmd, capture_output=True, text=True, check=True)
        return result.stdout
    except subprocess.CalledProcessError as e:
        print(f"Error running pf visualize: {e}")
        print(f"Error output: {e.stderr}")
        sys.exit(1)

def extract_html_path(output):
    """Extract the HTML file path from the command output"""
    match = re.search(r"The HTML file is generated at '([^']+)'", output)
    if match:
        return match.group(1)
    else:
        print("Could not find HTML file path in the output:")
        print(output)
        sys.exit(1)

def copy_html_file(source_path):
    """Copy the HTML file to the local directory with a timestamp"""
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = f"flow_visualization_{timestamp}.html"
    
    try:
        shutil.copy2(source_path, filename)
        print(f"HTML file copied to: {filename}")
        return filename
    except Exception as e:
        print(f"Error copying file: {e}")
        sys.exit(1)

def modify_html_file(filename):
    """Replace the last script tag in the HTML file"""
    try:
        with open(filename, 'r', encoding='utf-8') as file:
            soup = BeautifulSoup(file, 'html.parser')
        
        # Find all script tags
        script_tags = soup.find_all('script')
        
        if script_tags:
            # Replace the last script tag
            new_script = soup.new_tag('script')
            new_script['src'] = 'flow_visualize.js'
            script_tags[-1].replace_with(new_script)
            
            # Write the modified HTML back to the file
            with open(filename, 'w', encoding='utf-8') as file:
                file.write(str(soup))
            
            print(f"Successfully modified {filename} - replaced last script tag")
        else:
            print(f"No script tags found in {filename}")
    
    except Exception as e:
        print(f"Error modifying HTML file: {e}")
        sys.exit(1)

def main():
    # Ensure the JS file exists before proceeding
    ensure_js_file_exists()
    
    run_name = get_run_name()
    output = run_pf_visualize(run_name)
    html_path = extract_html_path(output)
    local_file = copy_html_file(html_path)
    modify_html_file(local_file)
    
    # Open the modified HTML file in the default web browser
    print(f"Opening {local_file} in the default web browser...")
    try:
        # For macOS
        subprocess.run(["open", local_file], check=True)
        print("Browser opened successfully.")
    except subprocess.CalledProcessError as e:
        print(f"Error opening browser: {e}")
        print("Please open the HTML file manually.")
    
    print("Process completed successfully!")

if __name__ == "__main__":
    main()  

Works for my needs.

@github-actions github-actions bot removed the no-recent-activity There has been no recent activity on this issue/pull request label Mar 4, 2025
Copy link

github-actions bot commented Apr 3, 2025

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 Apr 3, 2025
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