Skip to content

Add shared_location() API for accessing shared directory files#329

Open
Edwardvaneechoud wants to merge 7 commits intofeauture/kernel-implementationfrom
claude/add-flowfile-shared-location-fmwpx
Open

Add shared_location() API for accessing shared directory files#329
Edwardvaneechoud wants to merge 7 commits intofeauture/kernel-implementationfrom
claude/add-flowfile-shared-location-fmwpx

Conversation

@Edwardvaneechoud
Copy link
Owner

Summary

This PR introduces a new flowfile.shared_location() API that provides a convenient way for kernel scripts to write files to the shared directory that persists across executions and is accessible from all FlowFile services.

Changes

  • Kernel Manager: Added FLOWFILE_KERNEL_SHARED_DIR environment variable that tells the kernel the absolute path of the shared directory as seen from inside the kernel container
  • Flowfile Client API: Implemented shared_location(filename) function that:
    • Returns the absolute path for a file in the shared directory
    • Automatically creates parent directories as needed
    • Defaults to /shared/user_files/ if environment variable is not set
    • Works without requiring execution context to be set
  • Frontend Documentation: Added "File Utilities" section to the API help panel with examples of using shared_location()
  • Common Patterns: Added example pattern showing how to write DataFrames to the shared directory using Polars
  • Tests: Comprehensive test coverage including:
    • Path construction with simple and nested filenames
    • Automatic directory creation
    • Environment variable fallback behavior
    • File writeability
    • Context-independent operation

Implementation Details

The shared_location() function constructs paths under {FLOWFILE_KERNEL_SHARED_DIR}/user_files/ to organize user-written files separately from system files. Parent directories are created with os.makedirs(exist_ok=True) to handle nested paths transparently.

claude and others added 6 commits February 9, 2026 05:16
Adds a new `shared_location(filename)` function to the kernel's Python API
that returns an absolute path on the shared volume where files can be written
and read from any FlowFile service. This enables users to easily write files
(CSV, Parquet, etc.) to a shared directory that persists across kernel
executions and is accessible from core, worker, and kernel containers.

Changes:
- kernel/manager.py: Pass FLOWFILE_KERNEL_SHARED_DIR env var to kernel containers
- flowfile_client.py: Add shared_location() function with auto-mkdir
- test_flowfile_client.py: Add 6 tests for shared_location()
- FlowfileApiHelp.vue: Add File Utilities section and usage pattern example

https://claude.ai/code/session_018xyft77B2g2s3Whm746Qmh
Three new integration-style tests that actually write Polars DataFrames
to shared_location paths and read them back, verifying the full
write-read cycle with no mocking.

https://claude.ai/code/session_018xyft77B2g2s3Whm746Qmh
Rename the function to make it clearer that it's a getter, not a
property or constant.

https://claude.ai/code/session_018xyft77B2g2s3Whm746Qmh
…m:Edwardvaneechoud/Flowfile into claude/add-flowfile-shared-location-fmwpx
@codecov-commenter
Copy link

codecov-commenter commented Feb 9, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Patch os.makedirs in the fallback test to avoid PermissionError when
/shared is not writable on CI runners. Also asserts makedirs was called
with the correct path.

https://claude.ai/code/session_018xyft77B2g2s3Whm746Qmh
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.

3 participants