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

feat: read flows from local directory at startup #1989

Merged

Conversation

nicoloboschi
Copy link
Contributor

This PR adds the ability to load JSON flows from a local directory configured under LANGFLOW_LOAD_FLOWS_PATH (unset by default)

The UUID used is inferred from the filename if .json or from the json itself. if neither are set, a new uuid is set.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 28, 2024
Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langflow ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 3:59pm

Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

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

This looks awesome @nicoloboschi ! Thank you.

continue

logger.info(f"Creating new flow: {flow_id}")
flow["user_id"] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

If the user_id is None no User will be able to use the Flows.

What do you think would be a alternative to this?

Copy link
Contributor Author

@nicoloboschi nicoloboschi May 28, 2024

Choose a reason for hiding this comment

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

@ogabrielluiz good point. I've only tested it with AUTO_LOGIN=true and calling the flow with the superuser token (and that works)

For users, I think this can't be supported yet because I believe there's no concept of shared flows (which might be cool to add in the future) and binding the user_id is hard if you export/import from/to different langflow environments

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what we can do is have a flag for adding all of them to all users or to superusers only. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

LANGFLOW_LOAD_FLOWS_TO_ALL_USERS should be ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem of creating the same flow for all the users is that you are forced to change the uuid (because it's the PK of the table) and you lose the ability to compute API endpoints automatically.

I think we can let this option work with AUTO_LOGIN=true only.
I'll add a check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the flows for the superuser, please review again

@nicoloboschi nicoloboschi force-pushed the read-json-flows-from-directory branch from b987bda to 0a04a3e Compare May 30, 2024 15:39
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 30, 2024
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 30, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 30, 2024
@ogabrielluiz ogabrielluiz merged commit 7abfb0b into langflow-ai:dev May 30, 2024
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants