Skip to content

CHORE: Replaced Flask with Haystack - #2

Merged
michelle-hadfield-nava merged 28 commits into
mainfrom
mHadfield/1106-feat-replace-flask-with-haystack
Aug 19, 2025
Merged

CHORE: Replaced Flask with Haystack#2
michelle-hadfield-nava merged 28 commits into
mainfrom
mHadfield/1106-feat-replace-flask-with-haystack

Conversation

@michelle-hadfield-nava

@michelle-hadfield-nava michelle-hadfield-nava commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

Ticket

https://navalabs.atlassian.net/browse/DST-1106

Changes

  1. Remove Flask API
    2)Add Haystack

Context for reviewers

TBD

Testing

TBD

Preview environment for app

♻️ Environment destroyed ♻️

Comment thread app/Dockerfile Outdated
Co-authored-by: Kevin Boyer <kevinboyer@navapbc.com>
Comment thread app/Dockerfile Outdated
@michelle-hadfield-nava michelle-hadfield-nava changed the title DO NOT MERGE - CHORE: Removed code that refers to Flask and APIFlask CHORE: Replaced Flask with Haystack Aug 14, 2025
@michelle-hadfield-nava
michelle-hadfield-nava marked this pull request as ready for review August 14, 2025 21:25
Copilot AI review requested due to automatic review settings August 14, 2025 21:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces Flask/APIFlask with Haystack as the core framework, transitioning from a general-purpose web API to a specialized AI/ML pipeline framework.

Key Changes:

  • Completely replaced Flask/APIFlask with Haystack and Hayhooks for building AI pipelines
  • Removed all Flask-specific functionality including user management, database layers, and authentication
  • Added sample Haystack pipeline infrastructure with pipeline wrapper and YAML configuration

Reviewed Changes

Copilot reviewed 65 out of 73 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/src/app.py Core application replaced with Hayhooks app instead of Flask
app/pyproject.toml Dependencies updated to use Haystack ecosystem instead of Flask
app/src/pipelines/ New directory structure for Haystack AI pipelines
infra/modules/service/main.tf Infrastructure change to disable read-only root filesystem
docs/ Documentation and decision records removed (no longer relevant)
Comments suppressed due to low confidence (1)

app/src/app_config.py:9

  • Outdated comment references Flask documentation which is no longer relevant since the application now uses Hayhooks instead of Flask.
    host: str = "127.0.0.1"

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread infra/modules/service/main.tf
Comment thread app/pyproject.toml Outdated
Comment thread app/src/app.py Outdated
Comment thread docs/decisions/0000-use-markdown-architectural-decision-records.md
Comment thread docs/decisions/index.md
Comment thread app/pyproject.toml Outdated
Comment thread app/pyproject.toml Outdated
Comment thread app/pyproject.toml Outdated
Comment thread docs/app/api-details.md Outdated
Comment thread docs/app/technical-overview.md
Comment thread app/Dockerfile Outdated
Comment thread app/docker-compose.yml
michelle-hadfield-nava and others added 4 commits August 15, 2025 08:50
Co-authored-by: Yoom Lam <yoom@navapbc.com>
Co-authored-by: Yoom Lam <yoom@navapbc.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

This comment was marked as outdated.

@KevinJBoyer KevinJBoyer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looks like there a few linter / formatting / test errors to clean up, but we're almost to the finish line on this one!

Comment thread app/docker-compose.yml
Comment thread app/docker-compose.yml
Comment thread app/docker-compose.yml
args:
- RUN_UID=${RUN_UID:-4000}
- RUN_USER=${RUN_USER:-app}
command: ["poetry", "run", "flask", "--app", "src.app", "run", "--host", "0.0.0.0", "--port", "8080", "--reload"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my own understanding, does this work because the Dockerfile has the appropriate command already?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should we have the command here are well?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the main difference is that the docker-compose.yml (which is only used for local development) includes a --reload for hot reloading the app when the source files change, but I couldn't find out how to enable the same in hayhooks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't come across hotloading for hayhooks. I believe hayhooks, upon startup, loads and precompiles the Python files. One can add or remove pipelines using the hayhooks API, but hotloading for an existing pipeline is not yet a feature.

Comment thread app/local.env Outdated
Comment thread app/src/app.py Outdated
Comment thread app/src/app.py Outdated
Comment thread app/Dockerfile Outdated
Comment thread app/.dockleconfig
…mmands left over from troubleshooting, linted

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the Flask web framework with Haystack, transitioning from a Flask-based API application to a Haystack-based LLM application framework. The change removes the existing Flask API infrastructure and implements a new Haystack pipeline system for building applications powered by large language models.

  • Removed Flask API endpoints, authentication, and database integration components
  • Added Haystack framework dependencies and pipeline configuration
  • Updated infrastructure to support the new Haystack application architecture

Reviewed Changes

Copilot reviewed 49 out of 58 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
infra/modules/service/main.tf Updated ECS task definition to disable read-only root filesystem
docs/app/technical-overview.md Replaced Flask documentation with Haystack framework description
docs/app/api-details.md Removed entire Flask API documentation file
app/src/app.py Replaced Flask application with Hayhooks application and health endpoint
app/pyproject.toml Updated dependencies from Flask to Haystack and changed Python version
app/src/pipelines/sample_pipeline/ Added new Haystack pipeline implementation
Multiple test files Removed Flask-specific test files and configurations
Multiple service files Removed user management service layer files
Multiple API files Removed Flask API routes, schemas, and blueprints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

before passing the request to the route handler.
In the `api_key` security scheme, the `X-Auth` points to the
function that is run to do the authentication.
TODO update

Copilot AI Aug 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authentication section contains a placeholder 'TODO update' comment. This should be updated with proper documentation for how authentication works in the new Haystack application, or the section should be removed if authentication is not applicable.

Suggested change
TODO update
n/a - Authentication is not yet implemented for this API.

Copilot uses AI. Check for mistakes.
- RUN_UID=${RUN_UID:-4000}
- RUN_USER=${RUN_USER:-app}
env_file: local.env
# TODO - Update this to work with Haystack

Copilot AI Aug 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug configuration contains a TODO comment indicating it needs to be updated for Haystack. This should be addressed to ensure debugging functionality works with the new framework.

Copilot uses AI. Check for mistakes.
networkMode = "awsvpc",
essential = true,
readonlyRootFilesystem = !var.enable_command_execution,
readonlyRootFilesystem = false,

Copilot AI Aug 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting readonlyRootFilesystem to false reduces container security by allowing the container to write to its root filesystem. This should be justified or reverted to true with proper volume mounts for writable directories.

Suggested change
readonlyRootFilesystem = false,
readonlyRootFilesystem = true,

Copilot uses AI. Check for mistakes.
Comment thread app/Dockerfile Outdated
Co-authored-by: Kevin Boyer <kevinboyer@navapbc.com>
Comment thread app/Dockerfile Outdated
Comment thread app/local.env Outdated
Comment thread app/docker-compose.yml Outdated
Comment thread app/__init__.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah -- it's the addition of app/__init__.py that's causing the issue. Delete this file (and I think you should restore app/src/api/__init__.py) and the linter runs correctly

michelle-hadfield-nava and others added 2 commits August 19, 2025 10:20
Co-authored-by: Kevin Boyer <kevinboyer@navapbc.com>

@KevinJBoyer KevinJBoyer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! To keep this sprint unblocked, we'll address the package updates / vulnerability scans in a tech debt PR :)

Comment thread app/.dockleconfig
# DOCKLE_ACCEPT_FILES="file1,path/to/file2,file3/path,etc"

# The apiflask/settings file is a stub file that apiflask creates, and has no sensitive data in. We are ignoring it since it is unused
DOCKLE_ACCEPT_FILES=app/.venv/lib/python3.13/site-packages/apiflask/settings.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an earlier version of this PR that ignored the haystack file, you could bring that change back in before merging, or we can bring it in to the tech debt PR

@michelle-hadfield-nava
michelle-hadfield-nava merged commit 92ed849 into main Aug 19, 2025
17 of 20 checks passed
@michelle-hadfield-nava
michelle-hadfield-nava deleted the mHadfield/1106-feat-replace-flask-with-haystack branch August 19, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants