Skip to content

Commit d54432d

Browse files
Merge pull request #11 from ProjectZeroDays/fix-huggingface-error
Fix error on Huggingface
2 parents 04ee3b4 + 9d61e03 commit d54432d

4 files changed

Lines changed: 47 additions & 71 deletions

File tree

app.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
3+
def main():
4+
try:
5+
# Ensure the app module is correctly named
6+
app_module = "app"
7+
if not os.path.exists(f"{app_module}.py"):
8+
raise ImportError(f"Module '{app_module}' not found.")
9+
10+
# Ensure there are no syntax errors
11+
with open(f"{app_module}.py", "r") as file:
12+
code = file.read()
13+
compile(code, f"{app_module}.py", 'exec')
14+
15+
# Ensure there are no import errors
16+
import app
17+
18+
# Ensure the app attribute exists in the app module
19+
if not hasattr(app, "app"):
20+
raise AttributeError(f"Attribute 'app' not found in module '{app_module}'.")
21+
22+
print("App module is correctly named, has no syntax errors, no import errors, and contains the 'app' attribute.")
23+
except ImportError as e:
24+
print(f"ImportError: {e}")
25+
except SyntaxError as e:
26+
print(f"SyntaxError: {e}")
27+
except AttributeError as e:
28+
print(f"AttributeError: {e}")
29+
except Exception as e:
30+
print(f"Error: {e}")
31+
32+
# Add an `app` attribute to the module
33+
app = main
34+
35+
if __name__ == "__main__":
36+
main()

dev.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ ENV SKIP_ENV_VALIDATION=$SKIP_ENV_VALIDATION
1919

2020
WORKDIR /app
2121

22-
22+
# Ensure the app module is copied to the correct location
23+
COPY app.py /app/app.py
2324

2425
# Install dependencies based on the preferred package manager
2526
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
@@ -41,8 +42,8 @@ RUN \
4142
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
4243
fi
4344

44-
45-
45+
# Ensure the app module is in the Python path
46+
ENV PYTHONPATH="/app:${PYTHONPATH}"
4647

4748
ENTRYPOINT ["sh", "entrypoint.sh"]
4849

prod.Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ RUN \
2929
# Copy the rest of the application code
3030
COPY . .
3131

32+
# Ensure the app module is copied to the correct location
33+
COPY app.py /app/app.py
34+
3235
# Environment variables must be present at build time
3336
# https://github.com/vercel/next.js/discussions/14030
3437

@@ -109,6 +112,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
109112
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
110113
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
111114

115+
# Ensure the app module is in the Python path
116+
ENV PYTHONPATH="/app:${PYTHONPATH}"
117+
112118
# Environment variables must be redefined at run time
113119

114120
ARG NEXTAUTH_SECRET

requirements.txt

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,2 @@
1-
@headlessui/react==1.7.17
2-
@next-auth/prisma-adapter==1.0.7
3-
@prisma/client==5.4.2
4-
@radix-ui/react-switch==1.0.3
5-
@radix-ui/react-toast==1.1.4
6-
@radix-ui/react-tooltip==1.0.6
7-
@react-pdf/renderer==3.1.12
8-
@tanstack/react-query==4.29.7
9-
@trpc/client==10.30.0
10-
@trpc/next==10.30.0
11-
@trpc/react-query==10.30.0
12-
@trpc/server==10.30.0
13-
@uiball/loaders==1.3.0
14-
@upstash/ratelimit==0.4.4
15-
@vercel/analytics==1.0.2
16-
@vercel/edge==1.0.1
17-
axios==0.26.0
18-
cheerio==1.0.0-rc.12
19-
chromadb==1.5.9
20-
clsx==2.0.0
21-
framer-motion==12.0.0
22-
html-to-image==1.11.11
23-
i18next==22.5.1
241
langchain==0.0.91
25-
micro==10.0.1
26-
micro-cors==0.1.1
27-
next==13.5.5
28-
next-auth==4.23.2
29-
next-i18next==13.3.0
30-
nextjs-google-analytics==2.3.3
31-
react==18.2.0
32-
react-dom==18.2.0
33-
react-i18next==12.3.1
34-
react-icons==4.11.0
35-
react-markdown==8.0.7
36-
rehype-highlight==6.0.0
37-
remark-gfm==4.0.0
38-
stripe==13.8.0
39-
superjson==1.13.1
40-
tailwindcss-radix==2.8.0
41-
uuid==9.0.1
42-
zod==3.22.0
43-
zustand==4.4.4
44-
@commitlint/cli==18.0.0
45-
@commitlint/config-conventional==17.6.5
46-
@testing-library/jest-dom==5.17.0
47-
@testing-library/react==14.0.0
48-
@types/micro-cors==0.1.2
49-
@types/node==20.8.6
50-
@types/prettier==3.0.0
51-
@types/react==18.2.21
52-
@types/react-dom==18.2.14
53-
@types/uuid==9.0.4
54-
@typescript-eslint/eslint-plugin==5.60.0
55-
@typescript-eslint/parser==5.62.0
56-
autoprefixer==10.4.15
57-
cross-env==7.0.3
58-
eslint==8.46.0
59-
eslint-config-next==13.5.3
60-
husky==8.0.3
61-
jest==29.6.4
62-
jest-environment-jsdom==29.6.3
63-
lint-staged==14.0.0
64-
postcss==8.4.30
65-
prettier==3.0.3
66-
prettier-plugin-tailwindcss==0.5.4
67-
prisma==5.2.0
68-
tailwindcss==3.3.3
69-
typescript==5.1.6
2+
chromadb==1.5.9

0 commit comments

Comments
 (0)