Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ jobs:
unzip -o *.zip
rm *.zip
ls -l

- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@ cython_debug/

images/

dist/
dist/*
!dist/README.md
tests/inputs/PictoPy.thumbnails/
79 changes: 0 additions & 79 deletions backend/app/custom_logging.py

This file was deleted.

10 changes: 0 additions & 10 deletions backend/app/logging_config.json

This file was deleted.

29 changes: 25 additions & 4 deletions backend/app/utils/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def _start_frozen_sync_service() -> bool:
# Get the directory where the current executable is located
if getattr(sys, "frozen", False):
# When frozen, sys.executable points to the main executable
app_dir = Path(sys.executable).parent
app_dir = Path(sys.executable).parent.parent
else:
# Fallback (shouldn't happen in this function)
app_dir = Path(__file__).parent.parent.parent.parent

# Look for the PictoPy_Sync directory and executable
sync_dir = app_dir / "PictoPy_Sync"
# Look for the sync-microservice directory and executable
sync_dir = app_dir / "sync-microservice"

# Determine executable name based on platform
system = platform.system().lower()
Expand Down Expand Up @@ -233,7 +233,28 @@ def _start_fastapi_service(python_executable: Path, service_path: Path) -> bool:

# Command to start FastAPI dev server
print(python_executable)
cmd = [str(python_executable), "-m", "fastapi", "dev", "--port", "8001"]
host = "127.0.0.1"
port = "8001"
# On Windows, use a different approach with scripts path

if platform.system().lower() == "windows":
# Use uvicorn directly to run the FastAPI app
cmd = [
str(python_executable),
"-m",
"uvicorn",
"main:app",
"--host",
host,
"--port",
port,
"--reload", # Add reload flag for development convenience
]
else:
# For non-Windows platforms
cmd = [str(python_executable), "-m", "fastapi", "dev", "--port", "8001"]

logger.info(f"Executing command: {' '.join(cmd)}")

# Start the process (non-blocking)
process = subprocess.Popen(
Expand Down
4 changes: 2 additions & 2 deletions backend/dist/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Do not delete this file.
## Do not delete the "dist" folder.

This file is essential for the development environment to start.
This folder is essential for the development environment to start.
16 changes: 9 additions & 7 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from app.routes.face_clusters import router as face_clusters_router
from app.routes.user_preferences import router as user_preferences_router
from fastapi.openapi.utils import get_openapi
from app.custom_logging import CustomizeLogger


@asynccontextmanager
Expand Down Expand Up @@ -66,8 +65,6 @@ async def lifespan(app: FastAPI):
],
)

app.logger = CustomizeLogger.make_logger("app/logging_config.json")


def generate_openapi_json():
try:
Expand All @@ -90,9 +87,9 @@ def generate_openapi_json():

with open(openapi_path, "w") as f:
json.dump(openapi_schema, f, indent=2)
app.logger.info(f"OpenAPI JSON generated at {openapi_path}")
print(f"OpenAPI JSON generated at {openapi_path}")
except Exception as e:
app.logger.error(f"Failed to generate openapi.json: {e}")
print(f"Failed to generate openapi.json: {e}")


# Add CORS middleware
Expand All @@ -106,7 +103,7 @@ def generate_openapi_json():


# Basic health check endpoint
@app.get("/", tags=["Health"])
@app.get("/health", tags=["Health"])
async def root():
return {"message": "PictoPy Server is up and running!"}

Expand All @@ -125,6 +122,11 @@ async def root():
# Entry point for running with: python3 main.py
if __name__ == "__main__":
multiprocessing.freeze_support() # Required for Windows
config = Config(app=app, host="0.0.0.0", port=8000, log_config=None)
config = Config(
app=app,
host="0.0.0.0",
port=8000,
log_level="info",
)
server = Server(config)
server.run()
Loading