Script Development / Uploading User Python Modules
In some cases, the Python modules required by users are not published on the PyPI platform but exist directly as files.
At this time, these files can be uploaded to the user-python-packages/ directory in the DataFlux Func resource catalog and referenced directly in scripts.
1. Uploading Python Modules
Users can choose the upload method based on their actual situation. There is no difference in the result.
Direct Upload to the Host Machine
If the user has access to the host machine, they can directly upload Python files/directories to the {installation directory}/data/resources/user-python-packages/ directory using their preferred SSH tool, etc.
The default installation directory is /usr/local/dataflux-func. If unsure, you can use cat /etc/dataflux-func to check.
Uploading Using "File Management"
If the user does not have access to the host machine, they can enable "Manage / Experimental Features / Enable File Management" and then upload files in "Manage / File Management".
To prevent the uploaded zip archive from damaging the directory structure after extraction, extraction in "File Management" will forcibly create a directory.
Therefore, if the uploaded zip archive itself has a directory layer, there will be an extra layer of directory structure after extraction.
Based on the actual situation, move the Python module's directory to user-python-packages/xxxxx.
Go to the user-python-packages/ directory and confirm the Python package directory to be uploaded.
2. Using the Uploaded Python Module
Assuming the uploaded Python module is as follows:
| my_pkg/__init__.py | |
|---|---|
1 | |
| my_pkg/hello_world.py | |
|---|---|
1 2 | |
Then, you can directly import and use this module in a script, for example:
| Python | |
|---|---|
1 2 3 4 5 | |
3. Precautions
Be careful not to let self-uploaded Python modules have the same name as other Python modules, and do not delete or rename directories that originally exist in extra-python-packages.