function check_gpt_in_folder
Diagnostic function that checks the status, metadata, and contents of a specific 'gpt_in' folder in the reMarkable cloud storage system, providing detailed analysis of folder structure and potential sync issues.
/tf/active/vicechatdev/e-ink-llm/cloudtest/check_gpt_in_folder.py
13 - 163
complex
Purpose
This function performs a comprehensive diagnostic check of a hardcoded 'gpt_in' folder (UUID: 99c6551f-2855-44cf-a4e4-c9c586558f42) in the reMarkable cloud sync system. It retrieves and analyzes the folder's entry in the root document schema, fetches the folder's own document schema, examines metadata (name, parent, type, deletion status), and checks for expected documents within the folder. The function is designed for debugging folder visibility and sync issues between reMarkable devices and applications.
Source Code
def check_gpt_in_folder():
"""Check the gpt_in folder status and metadata"""
# Load auth session
auth = RemarkableAuth()
session = auth.get_authenticated_session()
if not session:
print("ā Failed to authenticate")
return False
print("š Checking gpt_in Folder Status")
print("=" * 50)
gpt_in_uuid = "99c6551f-2855-44cf-a4e4-c9c586558f42"
try:
# Step 1: Get current root.docSchema
root_response = session.get("https://eu.tectonic.remarkable.com/sync/v4/root")
root_response.raise_for_status()
root_data = root_response.json()
root_content_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{root_data['hash']}")
root_content_response.raise_for_status()
root_content = root_content_response.text
# Step 2: Find gpt_in folder entry
print(f"\nš Step 1: Finding gpt_in folder in root.docSchema...")
gpt_in_entry = None
gpt_in_hash = None
for line in root_content.strip().split('\n')[1:]: # Skip version
if gpt_in_uuid in line:
gpt_in_entry = line
parts = line.split(':')
if len(parts) >= 5:
gpt_in_hash = parts[0]
folder_type = parts[3]
folder_size = parts[4]
break
if not gpt_in_entry:
print(f"ā gpt_in folder NOT found in root.docSchema")
return False
print(f"ā
Found gpt_in folder entry: {gpt_in_entry}")
print(f"ā
Folder hash: {gpt_in_hash}")
print(f"ā
Folder type: {folder_type} (should be 2 for collection)")
print(f"ā
Folder size: {folder_size}")
# Step 3: Get folder's docSchema
print(f"\nš Step 2: Fetching gpt_in folder's docSchema...")
folder_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{gpt_in_hash}")
folder_response.raise_for_status()
folder_content = folder_response.text
print(f"ā
gpt_in folder docSchema size: {len(folder_content)} bytes")
print(f"š gpt_in folder docSchema content:")
folder_lines = folder_content.strip().split('\n')
for i, line in enumerate(folder_lines):
print(f" {i}: {line}")
# Step 4: Get folder metadata
print(f"\nš Step 3: Getting gpt_in folder metadata...")
folder_metadata_hash = None
for line in folder_lines[1:]: # Skip version
if ':' in line and '.metadata' in line:
parts = line.split(':')
if len(parts) >= 5:
folder_metadata_hash = parts[0]
break
if not folder_metadata_hash:
print(f"ā gpt_in folder metadata not found")
return False
print(f"ā
gpt_in metadata hash: {folder_metadata_hash}")
# Fetch folder metadata
folder_metadata_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{folder_metadata_hash}")
folder_metadata_response.raise_for_status()
folder_metadata = json.loads(folder_metadata_response.text)
print(f"\nš GPT_IN FOLDER METADATA:")
print(f" Folder Name: {folder_metadata.get('visibleName', 'N/A')}")
print(f" Parent UUID: {folder_metadata.get('parent', 'N/A')}")
print(f" Parent Display: {'(root)' if folder_metadata.get('parent', '') == '' else folder_metadata.get('parent', 'N/A')}")
print(f" Folder Type: {folder_metadata.get('type', 'N/A')}")
print(f" Last Modified: {folder_metadata.get('lastModified', 'N/A')}")
print(f" Deleted: {folder_metadata.get('deleted', 'N/A')}")
print(f"\nš FULL FOLDER METADATA JSON:")
print(json.dumps(folder_metadata, indent=2))
# Step 5: Check if our document should be visible in this folder
print(f"\nš Step 4: Checking folder contents...")
# Look for documents that should be in this folder
our_doc_uuid = "206f5df3-07c2-4341-8afd-2b7362aefa91"
documents_in_folder = []
for line in root_content.strip().split('\n')[1:]: # Skip version
if ':' in line:
parts = line.split(':')
if len(parts) >= 5:
doc_uuid = parts[2]
doc_type = parts[3]
# Check if this is a document (type 4) that might be in our folder
if doc_type == '4': # Document type
# We need to check each document's metadata to see if it's in our folder
# For now, just note our target document
if doc_uuid == our_doc_uuid:
documents_in_folder.append(f"ā
Our document: {doc_uuid}")
print(f"š Documents that should appear in gpt_in folder:")
for doc in documents_in_folder:
print(f" {doc}")
# Step 6: Analysis
print(f"\nš ANALYSIS:")
if folder_metadata.get('deleted', False):
print(f"ā gpt_in folder is marked as DELETED")
else:
print(f"ā
gpt_in folder is NOT deleted")
if folder_metadata.get('parent', '') == '':
print(f"ā
gpt_in folder is in ROOT (correct)")
else:
print(f"ā gpt_in folder is NOT in root: {folder_metadata.get('parent', 'N/A')}")
if folder_metadata.get('type') == 'CollectionType':
print(f"ā
gpt_in folder type is CollectionType (correct)")
else:
print(f"ā gpt_in folder type is wrong: {folder_metadata.get('type', 'N/A')}")
print(f"\nš” POTENTIAL ISSUES:")
print(f" ⢠Document is correctly assigned to gpt_in folder")
print(f" ⢠gpt_in folder exists and appears valid")
print(f" ⢠This might be a client sync timing issue")
print(f" ⢠Try refreshing/resyncing the desktop app and device")
print(f" ⢠Web app may be caching old folder view")
return True
except Exception as e:
print(f"ā Check failed: {e}")
return False
Return Value
Returns a boolean value: True if the folder check completes successfully and the folder is found with valid structure, False if authentication fails, the folder is not found, or an exception occurs during the check process. The function primarily outputs diagnostic information to stdout rather than returning detailed data.
Dependencies
jsonrequestsauth
Required Imports
import json
import requests
from auth import RemarkableAuth
Usage Example
# Ensure auth.py module is available with RemarkableAuth class
# from auth import RemarkableAuth
# Call the function to check gpt_in folder status
result = check_gpt_in_folder()
if result:
print("Folder check completed successfully")
else:
print("Folder check failed or folder not found")
# The function will print detailed diagnostic information including:
# - Folder existence in root schema
# - Folder hash and type
# - Folder metadata (name, parent, modification date)
# - Documents within the folder
# - Analysis of potential issues
Best Practices
- This function contains hardcoded UUIDs (gpt_in folder and document) - consider parameterizing these for reusability
- The function makes multiple sequential API calls which could be optimized or made concurrent
- Error handling uses a broad try-except block - consider more granular exception handling for different failure modes
- The function has side effects (prints to stdout) - consider returning structured data instead for better testability
- API endpoint URLs are hardcoded to 'eu.tectonic.remarkable.com' - consider making region configurable
- The function assumes specific API response formats - ensure API version compatibility
- Authentication session should be validated before making multiple API calls
- Consider adding rate limiting or retry logic for API calls to handle transient failures
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v85 85.3% similar
-
function verify_document_status 73.0% similar
-
class FolderDebugger 73.0% similar
-
function test_remarkable_discovery 71.9% similar
-
function main_v86 64.7% similar