bytedance-1 / NATIVE_SYMLINK_SOLUTION.md
drdata's picture
Upload folder using huggingface_hub
1b89842 verified

A newer version of the Gradio SDK is available: 6.1.0

Upgrade

βœ… NATIVE SYMBOLIC LINK SOLUTION - WORKING PERFECTLY!

Solution Overview

Your app.py now creates native symbolic links directly in the cache directory pointing to actual directories, making BytePlus work seamlessly without any extra scripts.

How the Native Symlink Solution Works

Directory Structure:

/Users/data/SGS-1/
β”œβ”€β”€ Generated/          ← Real directory (755 permissions)
β”œβ”€β”€ static/            ← Real directory (755 permissions)  
β”œβ”€β”€ view_session/      ← Real directory (755 permissions)
└── .cache/            ← Hidden cache directory (700 permissions)
    β”œβ”€β”€ app.py         ← BytePlus application
    β”œβ”€β”€ Generated      ← Symlink β†’ /Users/data/SGS-1/Generated
    β”œβ”€β”€ static         ← Symlink β†’ /Users/data/SGS-1/static
    └── view_session   ← Symlink β†’ /Users/data/SGS-1/view_session

Process Flow:

  1. Setup: Creates actual directories in root with 755 permissions
  2. Download: Downloads BytePlus space to .cache/
  3. Native Symlinks: Creates symbolic links IN cache pointing TO root directories
  4. Launch: BytePlus runs from cache but accesses directories natively via symlinks

Key Function: create_native_symlinks_in_cache()

  • Creates real directories in root path
  • Sets proper 755 permissions for access
  • Creates symbolic links FROM cache TO actual directories
  • Verifies each symlink works correctly
  • Provides comprehensive error handling with fallbacks

Verification Results

βœ… Structure Confirmed:

  • Root: Real directories (drwxr-xr-x permissions)
  • Cache: Symbolic links (lrwxr-xr-x pointing to root)
  • Permissions: 755 on directories (readable/writable)

βœ… Functionality Tested:

  • βœ… Cache/Generated accessible: Directory can be accessed via cache symlink
  • βœ… Cache/Generated writable: Files can be created via cache symlink
  • βœ… File Creation: touch .cache/Generated/test.txt creates file in root Generated/
  • βœ… App Launch: BytePlus launches successfully at http://127.0.0.1:7860

βœ… Native Operation:

  • BytePlus running from cache can read/write to directories
  • No circular references or broken links
  • No extra scripts or manual setup required
  • Works transparently with existing BytePlus code

Key Features

🎯 Single Script Solution

  • Everything handled in one app.py file
  • No external dependencies or helper scripts
  • Native symlink creation using Python's Path.symlink_to()

πŸ” Proper Security

  • Cache directory remains hidden and restrictive (700)
  • Working directories have proper access permissions (755)
  • Maintains security while enabling functionality

πŸ›‘οΈ Error Handling

  • Fallback to regular directories if symlinks fail
  • Comprehensive error messages and status reporting
  • Graceful handling of existing files/directories

πŸš€ Automatic Operation

  • Creates directories automatically if they don't exist
  • Sets proper permissions automatically
  • Verifies symlink functionality before proceeding

Output Messages Guide

Success Indicators:

  • βœ… Created native symlink: .cache/Generated -> /Users/data/SGS-1/Generated
  • βœ… Verified: Generated is accessible from cache
  • πŸŽ‰ Launching BytePlus Image Generation Studio...

What This Achieves:

  • BytePlus app runs from cache but accesses directories in root
  • All file operations work seamlessly through native symlinks
  • No manual permission fixes or setup required
  • Compatible with BytePlus existing code expectations

Command to Run:

python app.py

The native symbolic link solution is now working perfectly and provides seamless directory access for BytePlus without any extra scripts!