Spaces:
Runtime error
Runtime error
seanpedrickcase
commited on
Commit
•
b4b7a67
1
Parent(s):
5f5c87a
Fixed sts region issue. Added some references to pyinstaller exe creation.
Browse files- .dockerignore +2 -0
- .gitignore +2 -0
- AddressMatcher_0.1.spec +46 -0
- Dockerfile +2 -2
- how_to_create_exe_dist.txt +35 -0
- tools/aws_functions.py +1 -1
.dockerignore
CHANGED
@@ -7,9 +7,11 @@
|
|
7 |
*.pkl
|
8 |
*.env
|
9 |
*.zip
|
|
|
10 |
test/*
|
11 |
deprecated_models/*
|
12 |
experiments/*
|
|
|
13 |
.ipynb_checkpoints/*
|
14 |
orchestration/*
|
15 |
.vscode/*
|
|
|
7 |
*.pkl
|
8 |
*.env
|
9 |
*.zip
|
10 |
+
*.pth
|
11 |
test/*
|
12 |
deprecated_models/*
|
13 |
experiments/*
|
14 |
+
build_deps/*
|
15 |
.ipynb_checkpoints/*
|
16 |
orchestration/*
|
17 |
.vscode/*
|
.gitignore
CHANGED
@@ -7,9 +7,11 @@
|
|
7 |
*.pkl
|
8 |
*.env
|
9 |
*.zip
|
|
|
10 |
test/*
|
11 |
deprecated_models/*
|
12 |
.ipynb_checkpoints/*
|
13 |
orchestration/*
|
14 |
experiments/*
|
|
|
15 |
.vscode/*
|
|
|
7 |
*.pkl
|
8 |
*.env
|
9 |
*.zip
|
10 |
+
*.pth
|
11 |
test/*
|
12 |
deprecated_models/*
|
13 |
.ipynb_checkpoints/*
|
14 |
orchestration/*
|
15 |
experiments/*
|
16 |
+
build_deps/*
|
17 |
.vscode/*
|
AddressMatcher_0.1.spec
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- mode: python ; coding: utf-8 -*-
|
2 |
+
from PyInstaller.utils.hooks import collect_data_files
|
3 |
+
|
4 |
+
datas = []
|
5 |
+
datas += collect_data_files('gradio_client')
|
6 |
+
datas += collect_data_files('gradio')
|
7 |
+
|
8 |
+
|
9 |
+
a = Analysis(
|
10 |
+
['app.py'],
|
11 |
+
pathex=[],
|
12 |
+
binaries=[],
|
13 |
+
datas=datas,
|
14 |
+
hiddenimports=['pyarrow.vendored.version'],
|
15 |
+
hookspath=['build_deps\\\\'],
|
16 |
+
hooksconfig={},
|
17 |
+
runtime_hooks=[],
|
18 |
+
excludes=[],
|
19 |
+
noarchive=False,
|
20 |
+
optimize=0,
|
21 |
+
module_collection_mode={
|
22 |
+
'gradio': 'py', # Collect gradio package as source .py files
|
23 |
+
}
|
24 |
+
)
|
25 |
+
pyz = PYZ(a.pure)
|
26 |
+
|
27 |
+
exe = EXE(
|
28 |
+
pyz,
|
29 |
+
a.scripts,
|
30 |
+
a.binaries,
|
31 |
+
a.datas,
|
32 |
+
[],
|
33 |
+
name='AddressMatcher_0.1',
|
34 |
+
debug=False,
|
35 |
+
bootloader_ignore_signals=False,
|
36 |
+
strip=False,
|
37 |
+
upx=True,
|
38 |
+
upx_exclude=[],
|
39 |
+
runtime_tmpdir=None,
|
40 |
+
console=True,
|
41 |
+
disable_windowed_traceback=False,
|
42 |
+
argv_emulation=False,
|
43 |
+
target_arch=None,
|
44 |
+
codesign_identity=None,
|
45 |
+
entitlements_file=None,
|
46 |
+
)
|
Dockerfile
CHANGED
@@ -14,8 +14,8 @@ RUN useradd -m -u 1000 user
|
|
14 |
# Change ownership of /home/user directory
|
15 |
RUN chown -R user:user /home/user
|
16 |
|
17 |
-
#
|
18 |
-
RUN mkdir -p /home/user/output && chown -R user:user /home/user/output
|
19 |
|
20 |
# Switch to the "user" user
|
21 |
USER user
|
|
|
14 |
# Change ownership of /home/user directory
|
15 |
RUN chown -R user:user /home/user
|
16 |
|
17 |
+
# Make output folder
|
18 |
+
RUN mkdir -p /home/user/app/output && chown -R user:user /home/user/app/output
|
19 |
|
20 |
# Switch to the "user" user
|
21 |
USER user
|
how_to_create_exe_dist.txt
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1. Create minimal environment to run the app in conda. E.g. 'conda create --name new_env'
|
2 |
+
|
3 |
+
2. Activate the environment 'conda activate new_env'
|
4 |
+
|
5 |
+
3. cd to this folder. Install packages from requirements.txt using 'pip install -r requirements.txt'
|
6 |
+
|
7 |
+
NOTE: for ensuring that spaCy models are loaded into the program correctly in requirements.txt, follow this guide: https://spacy.io/usage/models#models-download
|
8 |
+
|
9 |
+
6. If necessary, create hook- files to tell pyinstaller to include specific packages in the exe build. Examples are provided for gradio and en_core_web_sm (a spaCy model). Put these in the build_deps\ subfolder
|
10 |
+
|
11 |
+
7. pip install pyinstaller
|
12 |
+
|
13 |
+
8. In command line, cd to the folder that contains app.py.
|
14 |
+
|
15 |
+
9.Run the following, assuming you want to make one single .exe file (This helped me: https://github.com/pyinstaller/pyinstaller/issues/8108):
|
16 |
+
|
17 |
+
a) In command line: pyi-makespec --additional-hooks-dir="build_deps\\" --collect-data=gradio_client --collect-data=gradio --hidden-import pyarrow.vendored.version --onefile --name AddressMatcher_0.1 app.py
|
18 |
+
|
19 |
+
b) Open the created spec file in Notepad. Add the following to the end of the Analysis section then save:
|
20 |
+
|
21 |
+
a = Analysis(
|
22 |
+
...
|
23 |
+
module_collection_mode={
|
24 |
+
'gradio': 'py', # Collect gradio package as source .py files
|
25 |
+
}
|
26 |
+
)
|
27 |
+
|
28 |
+
c) Back in command line, run this: pyinstaller --clean --noconfirm AddressMatcher_0.1.spec
|
29 |
+
|
30 |
+
|
31 |
+
9. A 'dist' folder will be created with the executable inside along with all dependencies('dist\data_text_search').
|
32 |
+
|
33 |
+
10. In 'dist\data_text_search' try double clicking on the .exe file. After a short delay, the command prompt should inform you about the IP address of the app that is now running. Copy the IP address. **Do not close this window!**
|
34 |
+
|
35 |
+
11. In an Internet browser, navigate to the indicated IP address. The app should now be running in your browser window.
|
tools/aws_functions.py
CHANGED
@@ -24,7 +24,7 @@ except Exception as e:
|
|
24 |
|
25 |
|
26 |
def get_assumed_role_info():
|
27 |
-
sts = boto3.client('sts')
|
28 |
response = sts.get_caller_identity()
|
29 |
|
30 |
# Extract ARN of the assumed role
|
|
|
24 |
|
25 |
|
26 |
def get_assumed_role_info():
|
27 |
+
sts = boto3.client('sts', region_name='eu-west-2')
|
28 |
response = sts.get_caller_identity()
|
29 |
|
30 |
# Extract ARN of the assumed role
|