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

Update executable template #2567

Merged
merged 75 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
5bef68f
update
Mar 20, 2024
3e029a3
Merge branch 'main' into dev/chenyin/pf_service
Mar 20, 2024
95c9008
flake8
Mar 20, 2024
4cf6853
typo
Mar 21, 2024
9783dfd
show log file
Mar 21, 2024
9e7293c
Merge branch 'main' into dev/chenyin/pf_service
Mar 22, 2024
e02fba9
update msi pf
Mar 22, 2024
00ac975
update linux install
Mar 22, 2024
f0d7280
update linux install
Mar 22, 2024
34fff6c
flake8
Mar 22, 2024
ffec639
update description
Mar 26, 2024
1019ff5
Merge branch 'main' into dev/chenyin/pf_service
Mar 26, 2024
e1a65e2
Merge branch 'main' into dev/chenyin/pf_service
Mar 27, 2024
6e4b201
Merge branch 'main' into dev/chenyin/pf_service
Mar 28, 2024
5a2ee9f
update test
Mar 28, 2024
c8b12f7
update
Mar 28, 2024
c34a1d7
Merge branch 'main' into dev/chenyin/pf_service
Mar 28, 2024
242e58e
Fix
crazygao Mar 28, 2024
b7f860f
Fix
crazygao Mar 28, 2024
b14aeb9
Merge branch 'main' into dev/chenyin/pf_service
Mar 29, 2024
696c1cf
Fix
crazygao Mar 29, 2024
9a448bb
Fix
crazygao Mar 29, 2024
efe4e18
Merge branch 'main' into yigao/fix_upgrade
crazygao Mar 29, 2024
d42afca
Merge branch 'yigao/fix_upgrade' of github.com:microsoft/promptflow i…
crazygao Mar 29, 2024
e013424
remove pfs in toml
Mar 29, 2024
b200128
test ci
Mar 29, 2024
5ab7ab7
add logger to debug
Mar 29, 2024
71d3b10
update pf entry
Mar 29, 2024
0b89e73
revert
Mar 29, 2024
1468ac0
revert
Mar 29, 2024
337c040
Fix
crazygao Mar 29, 2024
70b8c62
Fix
crazygao Mar 29, 2024
ed66543
Merge branch 'main' into dev/chenyin/pf_service
Mar 29, 2024
fc71324
Fix
crazygao Mar 29, 2024
faa0e13
Merge branch 'main' into dev/chenyin/pf_service
Mar 29, 2024
ebbd9af
Merge branch 'main' into yigao/fix_upgrade
crazygao Mar 29, 2024
8fe5461
Fix
crazygao Mar 29, 2024
d2cabaf
Fix
crazygao Mar 29, 2024
74cd93c
Merge branch 'main' into yigao/fix_upgrade
crazygao Mar 29, 2024
7324751
Merge branch 'main' into dev/chenyin/pf_service
Mar 30, 2024
989fcbf
update
Mar 30, 2024
38bc484
Merge branch 'dev/chenyin/pf_service' into dev/chenyin/update_executable
Mar 30, 2024
6a2cbb2
update
Mar 30, 2024
5be1f10
update
Mar 30, 2024
01ceb49
update
Mar 30, 2024
ef1efa7
support start pf
Apr 1, 2024
a3587e3
Fix
crazygao Apr 1, 2024
640ab12
update streamlit entry code
Apr 1, 2024
f69d5d7
[Internal] _skip_tracing_local_setup should also skip trace related s…
riddlexu Mar 29, 2024
d9f8bde
[Internal][Executor] Add try-catch to handle HttpError or UnexpectedE…
PeiwenGaoMS Mar 29, 2024
b683c8e
[devkit][bugfix] Use SQLAlchemy 1.x style ORM (#2560)
zhengfeiwang Mar 31, 2024
7a7bcbe
Update test matrix (#2539)
brynn-code Apr 1, 2024
722b339
Fix
crazygao Apr 1, 2024
e460a3e
Fix
crazygao Apr 1, 2024
e1476b8
Merge branch 'main' into dev/chenyin/update_executable
Apr 1, 2024
2b5c836
Merge branch 'main' into yigao/fix_upgrade
crazygao Apr 1, 2024
aa33be0
Fix
crazygao Apr 1, 2024
29e3781
Fix
crazygao Apr 1, 2024
3b003af
flake8
crazygao Apr 1, 2024
c0788a9
update
Apr 1, 2024
8a33bf3
Merge branch 'yigao/fix_upgrade' into dev/chenyin/update_executable
Apr 1, 2024
7b0ac3a
remove debug
Apr 1, 2024
806f1cd
Merge branch 'main' into dev/chenyin/update_executable
Apr 1, 2024
d94f0cd
remove toml import
Apr 1, 2024
01a86ea
Merge branch 'main' into dev/chenyin/update_executable
Apr 1, 2024
1e54bcf
Merge branch 'main' into dev/chenyin/update_executable
Apr 1, 2024
99affcf
update linux argvs
Apr 1, 2024
498dbe8
onefile mode and add x for pf in linux
Apr 1, 2024
57d9050
update
Apr 1, 2024
ff0cc4e
typo
Apr 2, 2024
258657b
Merge branch 'main' into dev/chenyin/update_executable
Apr 2, 2024
2a8bb85
add promptflow-evals in doc ci
Apr 2, 2024
b51b08a
update
Apr 2, 2024
faf244b
revert
Apr 2, 2024
00fe9f3
Merge branch 'main' into dev/chenyin/update_executable
Apr 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
"STARTF",
"mltable",
"setenv",
"cscript",
"nologo",
"wscript",
"raisvc",
"evals"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,101 +43,14 @@ Exported files & its dependencies are located in the same folder. The structure
### A template script of the entry file
PyInstaller reads a spec file or Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files, including the active Python interpreter, and puts them with your script in a single folder, or optionally in a single executable file.

We provide a Python entry script named `app.py` as the entry point for the bundled app, which enables you to serve a flow folder as an endpoint.

```python
import os
import sys

from promptflow._cli._pf._connection import create_connection
from streamlit.web import cli as st_cli
from streamlit.runtime import exists

from main import start

def is_yaml_file(file_path):
_, file_extension = os.path.splitext(file_path)
return file_extension.lower() in ('.yaml', '.yml')

def create_connections(directory_path) -> None:
for root, dirs, files in os.walk(directory_path):
for file in files:
file_path = os.path.join(root, file)
if is_yaml_file(file_path):
create_connection(file_path)


if __name__ == "__main__":
create_connections(os.path.join(os.path.dirname(__file__), "connections"))
if exists():
start()
else:
main_script = os.path.join(os.path.dirname(__file__), "main.py")
sys.argv = ["streamlit", "run", main_script, "--global.developmentMode=false"]
st_cli.main(prog_name="streamlit")

```
We provide a Python entry script named [app.py](https://github.com/microsoft/promptflow/blob/main/src/promptflow-devkit/promptflow/_sdk/data/executable/app.py) as the entry point for the bundled app, which enables you to serve a flow folder as an endpoint.


### A template script of the spec file
The spec file tells PyInstaller how to process your script. It encodes the script names and most of the options you give to the pyinstaller command. The spec file is actually executable Python code. PyInstaller builds the app by executing the contents of the spec file.

To streamline this process, we offer a `app.spec` spec file that bundles the application into a single file. For additional information on spec files, you can refer to the [Using Spec Files](https://pyinstaller.org/en/stable/spec-files.html). Please replace `streamlit_runtime_interpreter_path` with the path of streamlit runtime interpreter in your environment.

```spec
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import copy_metadata

datas = [('connections', 'connections'), ('flow', 'flow'), ('settings.json', '.'), ('main.py', '.'), ('{{streamlit_runtime_interpreter_path}}', './streamlit/runtime')]
datas += collect_data_files('streamlit')
datas += copy_metadata('streamlit')
datas += collect_data_files('keyrings.alt', include_py_files=True)
datas += copy_metadata('keyrings.alt')
datas += collect_data_files('streamlit_quill')

block_cipher = None


a = Analysis(
['app.py', 'main.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=['bs4'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='app',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
```
To streamline this process, we offer a [app.spec.jinja2](https://github.com/microsoft/promptflow/blob/main/src/promptflow-devkit/promptflow/_sdk/data/executable/app.spec.jinja2) spec template file that bundles the application into a single file. For additional information on spec files, you can refer to the [Using Spec Files](https://pyinstaller.org/en/stable/spec-files.html). Please replace `streamlit_runtime_interpreter_path` with the path of streamlit runtime interpreter in your environment.


### The bundled application using Pyinstaller
Once you've build a flow as executable format following [Build a flow as executable format](#build-a-flow-as-executable-format).
Expand Down Expand Up @@ -168,4 +81,4 @@ To your users, the app is self-contained. They do not need to install any partic
1. Note that Python 3.10.0 contains a bug making it unsupportable by PyInstaller. PyInstaller will also not work with beta releases of Python 3.13.

## Next steps
- Try the example [here](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/flow-deploy)
- Try the example [here](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/flow-deploy/distribute-flow-as-executable-app)
Original file line number Diff line number Diff line change
Expand Up @@ -39,101 +39,16 @@ Exported files & its dependencies are located in the same folder. The structure
### A template script of the entry file
PyInstaller reads a spec file or Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files, including the active Python interpreter, and puts them with your script in a single folder, or optionally in a single executable file.

We provide a Python entry script named `app.py` as the entry point for the bundled app, which enables you to serve a flow folder as an endpoint.

```python
import os
import sys

from promptflow._cli._pf._connection import create_connection
from streamlit.web import cli as st_cli
from streamlit.runtime import exists

from main import start

def is_yaml_file(file_path):
_, file_extension = os.path.splitext(file_path)
return file_extension.lower() in ('.yaml', '.yml')

def create_connections(directory_path) -> None:
for root, dirs, files in os.walk(directory_path):
for file in files:
file_path = os.path.join(root, file)
if is_yaml_file(file_path):
create_connection(file_path)


if __name__ == "__main__":
create_connections(os.path.join(os.path.dirname(__file__), "connections"))
if exists():
start()
else:
main_script = os.path.join(os.path.dirname(__file__), "main.py")
sys.argv = ["streamlit", "run", main_script, "--global.developmentMode=false"]
st_cli.main(prog_name="streamlit")
```
:::
We provide a Python entry script named [app.py](https://github.com/microsoft/promptflow/blob/main/src/promptflow-devkit/promptflow/_sdk/data/executable/app.py) as the entry point for the bundled app, which enables you to serve a flow folder as an endpoint.



### A template script of the spec file
The spec file tells PyInstaller how to process your script. It encodes the script names and most of the options you give to the pyinstaller command. The spec file is actually executable Python code. PyInstaller builds the app by executing the contents of the spec file.

To streamline this process, we offer a `app.spec` spec file that bundles the application into a single file. For additional information on spec files, you can refer to the [Using Spec Files](https://pyinstaller.org/en/stable/spec-files.html).
To streamline this process, we offer a [app.spec.jinja2](https://github.com/microsoft/promptflow/blob/main/src/promptflow-devkit/promptflow/_sdk/data/executable/app.spec.jinja2) spec template file that bundles the application into a single file. For additional information on spec files, you can refer to the [Using Spec Files](https://pyinstaller.org/en/stable/spec-files.html).
Please replace {{streamlit_runtime_interpreter_path}} with the path of streamlit runtime interpreter in your environment.

```spec
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import copy_metadata

datas = [('connections', 'connections'), ('flow', 'flow'), ('settings.json', '.'), ('main.py', '.'), ('{{streamlit_runtime_interpreter_path}}', './streamlit/runtime')]
datas += collect_data_files('streamlit')
datas += copy_metadata('streamlit')
datas += collect_data_files('keyrings.alt', include_py_files=True)
datas += copy_metadata('keyrings.alt')

block_cipher = None


a = Analysis(
['app.py', 'main.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=['bs4'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='app',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
```

### The bundled application using Pyinstaller
Once you've build a flow as executable format following [Build a flow as executable format](#build-a-flow-as-executable-format).
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading