Skip to content

Reintroduce advance dependencies in Code Node while using Python3 #27239

@Tomahawkd

Description

@Tomahawkd

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Currently users have to configure python-requirement.txt in sandbox to add custom dependencies before the sandbox startup. This is very inconvinient for users to add dependencies for their workflow especially when the user needs a new dependency. They have to shut down the sandbox, add dependencies to python-requirement.txt and finally restart the sandbox. You can refer current sandbox dependency management implementation here.

My proposal is reintroduce advanced dependencies. I'm not trying to revert #7494, but let users to add more dependencies based on current. The full step is as follows:

  1. The user adds dependencies from web interface, such as:
Image
  1. The api service post a request to sandbox service with following data:
{
    "language": "python3",
    "code": "xxx",
    "preload": "xxx",
    "enable_network": true, // this always true from api service
    "dependencies": [{"name": "pyyaml", "version": ""}] // My proposal
}
  1. The sandbox service detects if there is custom dependencies. If not, run the code using current implementation. Otherwise, the sandbox will use uv to create a virtual environment and install dependencies. You can checkout my changes on sanbox: feat: custom dependency on request dify-sandbox#190

2. Additional context or comments

Some discussion on user interface: I found there is a dependency picker which is used to select dependency. Maybe we can reuse this to help the user to search dependencies. I tried to use https://pypi.org/simple/ (don't open it, it is very big) to collect and search dependencies but it will make UI laggy. Perhaps there is some search API we can use (but I haven't discovered one).

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions