Skip to content

Commit b7c879a

Browse files
authored
Merge branch 'main' into add/dllm-plugin
2 parents 6b38002 + e6e58df commit b7c879a

File tree

88 files changed

+1095
-821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1095
-821
lines changed

install.sh

Lines changed: 2 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -479,123 +479,6 @@ doctor() {
479479

480480
}
481481

482-
##############################
483-
## Optional: Install Mountpoint for Amazon S3 (Linux only)
484-
##############################
485-
486-
install_s3_mounting() {
487-
title "Install S3 Mounting Tools"
488-
489-
# Only proceed if TFL_MULTITENANT is exactly "true"
490-
if [[ "${TFL_MULTITENANT:-}" != "true" ]]; then
491-
echo "Skipping S3 mounting install because TFL_MULTITENANT is not 'true'."
492-
return 0
493-
fi
494-
495-
if [[ -n "${TLAB_ON_MACOS}" ]]; then
496-
install_s3fs_macos
497-
else
498-
install_mountpoint_linux
499-
fi
500-
}
501-
502-
install_s3fs_macos() {
503-
title "Install s3fs for macOS S3 Mounting"
504-
505-
if command -v s3fs >/dev/null 2>&1; then
506-
ohai "✅ s3fs already installed (s3fs found)."
507-
return 0
508-
fi
509-
510-
# Check if Homebrew is installed
511-
if ! command -v brew >/dev/null 2>&1; then
512-
echo "Installing Homebrew first..."
513-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
514-
515-
# Add Homebrew to PATH for Apple Silicon Macs
516-
if [[ $(uname -m) == "arm64" ]]; then
517-
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
518-
eval "$(/opt/homebrew/bin/brew shellenv)"
519-
fi
520-
fi
521-
522-
echo "Installing macFUSE (required for s3fs)..."
523-
brew install --cask macfuse
524-
525-
echo "Installing s3fs using Homebrew..."
526-
brew install gromgit/fuse/s3fs-mac
527-
528-
if command -v s3fs >/dev/null 2>&1; then
529-
ohai "✅ s3fs installed successfully."
530-
else
531-
warn "s3fs installation may have failed; 's3fs' not found."
532-
return 1
533-
fi
534-
}
535-
536-
install_mountpoint_linux() {
537-
title "Install Mountpoint for Amazon S3 (Linux only)"
538-
539-
if command -v mount-s3 >/dev/null 2>&1; then
540-
ohai "✅ Mountpoint for Amazon S3 already installed (mount-s3 found)."
541-
return 0
542-
fi
543-
544-
ARCH=$(uname -m)
545-
if [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
546-
MP_ARCH="arm64"
547-
else
548-
MP_ARCH="x86_64"
549-
fi
550-
551-
TMP_DIR=$(mktemp -d)
552-
cleanup() { rm -rf "$TMP_DIR" 2>/dev/null || true; }
553-
trap cleanup EXIT
554-
555-
if command -v apt-get >/dev/null 2>&1; then
556-
echo "Detected apt-based system. Installing .deb package."
557-
DEB_URL="https://s3.amazonaws.com/mountpoint-s3-release/latest/${MP_ARCH}/mount-s3.deb"
558-
echo "Downloading: $DEB_URL"
559-
wget -q "$DEB_URL" -O "$TMP_DIR/mount-s3.deb"
560-
sudo apt-get install -y "$TMP_DIR/mount-s3.deb"
561-
elif command -v yum >/dev/null 2>&1; then
562-
echo "Detected yum-based system. Installing .rpm package."
563-
RPM_URL="https://s3.amazonaws.com/mountpoint-s3-release/latest/${MP_ARCH}/mount-s3.rpm"
564-
echo "Downloading: $RPM_URL"
565-
wget -q "$RPM_URL" -O "$TMP_DIR/mount-s3.rpm"
566-
sudo yum install -y "$TMP_DIR/mount-s3.rpm"
567-
elif command -v dnf >/dev/null 2>&1; then
568-
echo "Detected dnf-based system. Installing .rpm package."
569-
RPM_URL="https://s3.amazonaws.com/mountpoint-s3-release/latest/${MP_ARCH}/mount-s3.rpm"
570-
echo "Downloading: $RPM_URL"
571-
wget -q "$RPM_URL" -O "$TMP_DIR/mount-s3.rpm"
572-
sudo dnf install -y "$TMP_DIR/mount-s3.rpm"
573-
else
574-
warn "Unsupported Linux package manager for automatic Mountpoint install. Please install manually."
575-
return 1
576-
fi
577-
578-
if command -v mount-s3 >/dev/null 2>&1; then
579-
ohai "✅ Mountpoint for Amazon S3 installed successfully."
580-
else
581-
warn "Mountpoint for Amazon S3 installation may have failed; 'mount-s3' not found."
582-
fi
583-
}
584-
585-
install_mounting() {
586-
title "Step 5: Install Mounting (S3)"
587-
echo "🌘 Step 5: START"
588-
589-
# This wrapper ensures we only run mounting installers when multitenant is truthy
590-
if [[ "${TFL_MULTITENANT:-}" == "true" ]]; then
591-
install_s3_mounting || true
592-
else
593-
echo "Skipping mounting installation because TFL_MULTITENANT is not 'true'."
594-
fi
595-
596-
echo "🌕 Step 5: COMPLETE"
597-
}
598-
599482
print_success_message() {
600483
title "Installation Complete"
601484
echo "------------------------------------------"
@@ -614,11 +497,8 @@ print_success_message() {
614497
}
615498

616499
# Load .env configuration (prefer current dir, then fallback to app src dir)
617-
TFL_MULTITENANT=${TFL_MULTITENANT:-}
618500
load_env_from_file "${RUN_DIR}/.env"
619-
if [ -z "${TFL_MULTITENANT:-}" ]; then
620-
load_env_from_file "${TLAB_CODE_DIR}/.env"
621-
fi
501+
load_env_from_file "${TLAB_CODE_DIR}/.env"
622502

623503
# Check if there are positional arguments; if not, perform full install
624504
if [[ "$#" -eq 0 ]]; then
@@ -627,7 +507,6 @@ if [[ "$#" -eq 0 ]]; then
627507
install_conda
628508
create_conda_environment
629509
install_dependencies
630-
install_mounting
631510
print_success_message
632511
else
633512
for arg in "$@"; do
@@ -644,9 +523,6 @@ else
644523
install_dependencies)
645524
install_dependencies
646525
;;
647-
install_mounting)
648-
install_mounting
649-
;;
650526
doctor)
651527
doctor
652528
;;
@@ -658,8 +534,7 @@ else
658534
;;
659535
*)
660536
# Print allowed arguments
661-
echo "Allowed arguments: [download_transformer_lab, install_conda, create_conda_environment, install_dependencies, install_mounting] or leave blank to perform a full installation."
662-
echo "To enable multitenant setup, set TFL_MULTITENANT=true in a local .env file."
537+
echo "Allowed arguments: [download_transformer_lab, install_conda, create_conda_environment, install_dependencies] or leave blank to perform a full installation."
663538
abort "❌ Unknown argument: $arg"
664539
;;
665540
esac

run.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ EOF
179179
echo "⚠️ AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY not set, skipping AWS setup"
180180
fi
181181

182-
# # Mount S3 bucket using AWS credentials from ~/.aws
183-
# if [ -n "$BUCKET_NAME" ]; then
184-
# echo "☁️ Mounting S3 bucket '$BUCKET_NAME' to remote workspace"
185-
# mount-s3 --profile transformerlab-s3 "$BUCKET_NAME" "$REMOTE_WORKSPACE_DIR"
186-
# else
187-
# echo "⚠️ BUCKET_NAME not set in environment variables, skipping S3 mount"
188-
# echo "💡 Please set BUCKET_NAME in your .env file"
189-
# fi
190182
fi
191183

192184
echo "▶️ Starting the API server:"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
"""Increment plugin versions by 0.0.1 (patch version)
3+
4+
This script increments the patch version (third number) in all plugin index.json files.
5+
For example, 3.4.2 becomes 3.4.3, or 1.0.27 becomes 1.0.28.
6+
7+
Usage:
8+
python increment_plugin_versions.py
9+
10+
Run from the transformerlab-api directory or from this scripts directory.
11+
"""
12+
13+
import json
14+
import sys
15+
from pathlib import Path
16+
17+
def increment_version(version_str):
18+
"""Increment patch version by 1 (e.g., 3.4.2 -> 3.4.3)"""
19+
parts = version_str.split('.')
20+
if len(parts) == 3:
21+
major, minor, patch = parts
22+
new_patch = str(int(patch) + 1)
23+
return f"{major}.{minor}.{new_patch}"
24+
else:
25+
# Handle edge cases - if version format is unexpected, try to increment last part
26+
print(f"Warning: Unexpected version format: {version_str}")
27+
if len(parts) >= 1:
28+
parts[-1] = str(int(parts[-1]) + 1)
29+
return '.'.join(parts)
30+
return version_str
31+
32+
def process_plugin_index(plugin_path):
33+
"""Read, update version, and write index.json"""
34+
index_path = plugin_path / "index.json"
35+
if not index_path.exists():
36+
print(f"Warning: {index_path} does not exist")
37+
return False
38+
39+
try:
40+
with open(index_path, 'r', encoding='utf-8') as f:
41+
data = json.load(f)
42+
43+
if 'version' not in data:
44+
print(f"Warning: {index_path} does not have a version field")
45+
return False
46+
47+
old_version = data['version']
48+
new_version = increment_version(old_version)
49+
data['version'] = new_version
50+
51+
with open(index_path, 'w', encoding='utf-8') as f:
52+
json.dump(data, f, indent=2, ensure_ascii=False)
53+
f.write('\n') # Add newline at end
54+
55+
print(f"Updated {plugin_path.name}: {old_version} -> {new_version}")
56+
return True
57+
except Exception as e:
58+
print(f"Error processing {index_path}: {e}")
59+
return False
60+
61+
def main():
62+
# Get the script directory and find transformerlab-api root
63+
script_dir = Path(__file__).parent.resolve()
64+
65+
# Try to find transformerlab-api root (should be parent of scripts)
66+
api_root = script_dir.parent
67+
plugins_dir = api_root / "transformerlab" / "plugins"
68+
69+
if not plugins_dir.exists():
70+
print(f"Error: {plugins_dir} does not exist")
71+
print(f"Script is in: {script_dir}")
72+
print(f"Looking for plugins in: {plugins_dir}")
73+
sys.exit(1)
74+
75+
plugin_dirs = [d for d in plugins_dir.iterdir() if d.is_dir()]
76+
print(f"Found {len(plugin_dirs)} plugin directories")
77+
print(f"Processing plugins in: {plugins_dir}\n")
78+
79+
updated = 0
80+
for plugin_dir in sorted(plugin_dirs):
81+
if process_plugin_index(plugin_dir):
82+
updated += 1
83+
84+
print(f"\nSuccessfully updated {updated} plugins")
85+
86+
if __name__ == "__main__":
87+
main()
88+

test/api/test_diffusion.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ def test_delete_image_from_history_not_found(client):
318318
with (
319319
patch("transformerlab.routers.experiment.diffusion.get_history_file_path", return_value="/fake/history.json"),
320320
patch("transformerlab.routers.experiment.diffusion.storage.exists", return_value=True),
321-
patch("transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data='[{"id": "other-id", "image_path": "/fake/path.png"}]')),
321+
patch(
322+
"transformerlab.routers.experiment.diffusion.storage.open",
323+
mock_open(read_data='[{"id": "other-id", "image_path": "/fake/path.png"}]'),
324+
),
322325
):
323326
resp = client.delete("/experiment/test-exp-name/diffusion/history/non-existent-id")
324327
assert resp.status_code == 500
@@ -334,7 +337,10 @@ def test_create_dataset_from_history_success(client):
334337
patch("transformerlab.routers.experiment.diffusion.storage.makedirs"),
335338
patch("transformerlab.routers.experiment.diffusion.storage.exists", return_value=True),
336339
patch("transformerlab.routers.experiment.diffusion.storage.isdir", return_value=True),
337-
patch("transformerlab.routers.experiment.diffusion.storage.ls", return_value=["/fake/path/folder/0.png", "/fake/path/folder/1.png"]),
340+
patch(
341+
"transformerlab.routers.experiment.diffusion.storage.ls",
342+
return_value=["/fake/path/folder/0.png", "/fake/path/folder/1.png"],
343+
),
338344
patch("transformerlab.routers.experiment.diffusion.storage.copy_file"),
339345
patch("transformerlab.routers.experiment.diffusion.storage.open", mock_open()),
340346
):
@@ -666,7 +672,9 @@ def test_load_history_with_pagination():
666672
with (
667673
patch("transformerlab.routers.experiment.diffusion.get_history_file_path", return_value="/fake/history.json"),
668674
patch("transformerlab.routers.experiment.diffusion.storage.exists", return_value=True),
669-
patch("transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))),
675+
patch(
676+
"transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))
677+
),
670678
):
671679
from transformerlab.routers.experiment.diffusion import load_history
672680

@@ -770,7 +778,9 @@ def test_find_image_by_id_success():
770778
with (
771779
patch("transformerlab.routers.experiment.diffusion.get_history_file_path", return_value="/fake/history.json"),
772780
patch("transformerlab.routers.experiment.diffusion.storage.exists", return_value=True),
773-
patch("transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))),
781+
patch(
782+
"transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))
783+
),
774784
):
775785
from transformerlab.routers.experiment.diffusion import find_image_by_id
776786

@@ -817,7 +827,9 @@ def test_find_image_by_id_not_found(client):
817827
with (
818828
patch("transformerlab.routers.experiment.diffusion.get_history_file_path", return_value="/fake/history.json"),
819829
patch("transformerlab.routers.experiment.diffusion.storage.exists", return_value=True),
820-
patch("transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))),
830+
patch(
831+
"transformerlab.routers.experiment.diffusion.storage.open", mock_open(read_data=json.dumps(history_data))
832+
),
821833
):
822834
from transformerlab.routers.experiment.diffusion import find_image_by_id
823835

0 commit comments

Comments
 (0)