Skip to content

Commit 5c6f91c

Browse files
committed
Add ImageGeneratorsHub as submodule and update installation scripts
- Add ImageGeneratorsHub as git submodule - Update install.sh to initialize submodules instead of cloning separately - Update install-oneliner.sh to clone with --recursive flag - Update service manager to properly handle ImageGeneratorsHub submodule - Fix ImageGeneratorsHub path to be within needle home directory
1 parent 0aa00f5 commit 5c6f91c

File tree

5 files changed

+41
-24
lines changed

5 files changed

+41
-24
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ImageGeneratorsHub"]
2+
path = ImageGeneratorsHub
3+
url = git@github.com:UIC-InDeXLab/ImageGeneratorsHub.git

ImageGeneratorsHub

Submodule ImageGeneratorsHub added at 8f45ad8

install-oneliner.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ print_success "Selected ${CONFIG_MODE} configuration"
111111
TEMP_DIR=$(mktemp -d)
112112
print_status "Using temporary directory: $TEMP_DIR"
113113

114-
# Clone repository
115-
print_status "Cloning Needle repository..."
114+
# Clone repository with submodules
115+
print_status "Cloning Needle repository with submodules..."
116116
cd "$TEMP_DIR"
117-
git clone https://github.com/UIC-InDeXLab/Needle.git
117+
git clone --recursive https://github.com/UIC-InDeXLab/Needle.git
118118
cd Needle
119119

120120
# Make install script executable and run it

install.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,22 @@ else
165165
fi
166166
fi
167167

168-
### Step 3: Clone ImageGeneratorsHub if needed
169-
print_status "Setting up ImageGeneratorsHub..."
170-
171-
if [ -d "${IMAGE_GEN_HUB_DIR}" ]; then
172-
print_warning "ImageGeneratorsHub directory already exists. Updating..."
173-
cd "${IMAGE_GEN_HUB_DIR}"
174-
git pull origin main
175-
cd "${NEEDLE_DIR}"
168+
### Step 3: Initialize and update submodules
169+
print_status "Setting up ImageGeneratorsHub submodule..."
170+
171+
# Initialize and update submodules
172+
print_status "Initializing git submodules..."
173+
git submodule init
174+
git submodule update --recursive
175+
176+
# Check if ImageGeneratorsHub submodule is properly initialized
177+
if [ -d "ImageGeneratorsHub" ] && [ -f "ImageGeneratorsHub/.git" ]; then
178+
print_success "ImageGeneratorsHub submodule initialized"
179+
IMAGE_GEN_HUB_DIR="${NEEDLE_DIR}/ImageGeneratorsHub"
180+
print_status "ImageGeneratorsHub directory: $IMAGE_GEN_HUB_DIR"
176181
else
177-
print_status "Cloning ImageGeneratorsHub repository..."
178-
cd "${NEEDLE_DIR}/.."
179-
git clone git@github.com:UIC-InDeXLab/ImageGeneratorsHub.git
180-
cd "${NEEDLE_DIR}"
182+
print_error "Failed to initialize ImageGeneratorsHub submodule"
183+
exit 1
181184
fi
182185

183186
### Step 4: Setup Backend Virtual Environment

needlectl/cli/service.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _get_service_pid(self, pid_file: Path) -> Optional[int]:
4949
except (OSError, ValueError, FileNotFoundError):
5050
return None
5151

52-
def _start_virtual_env_service(self, service_name: str, command: list, pid_file: Path, log_file: Path, working_dir: Path = None):
52+
def _start_virtual_env_service(self, service_name: str, command: list, pid_file: Path, log_file: Path, working_dir: Path = None, env_vars: dict = None):
5353
"""Start a virtual environment service."""
5454
if self._is_service_running(pid_file):
5555
typer.echo(f"{service_name} is already running (PID: {self._get_service_pid(pid_file)})")
@@ -61,13 +61,19 @@ def _start_virtual_env_service(self, service_name: str, command: list, pid_file:
6161
# Use provided working directory or default to needle_home
6262
cwd = working_dir if working_dir else self.needle_home
6363

64+
# Prepare environment variables
65+
env = os.environ.copy()
66+
if env_vars:
67+
env.update(env_vars)
68+
6469
# Start service in background
6570
with open(log_file, 'w') as log_f:
6671
process = subprocess.Popen(
6772
command,
6873
stdout=log_f,
6974
stderr=subprocess.STDOUT,
70-
cwd=cwd
75+
cwd=cwd,
76+
env=env
7177
)
7278

7379
# Save PID
@@ -118,17 +124,17 @@ def start_services(self):
118124
time.sleep(15)
119125

120126
# Start image generator hub
121-
if (self.needle_home.parent / "ImageGeneratorsHub").exists():
127+
image_gen_dir = self.needle_home / "ImageGeneratorsHub"
128+
if image_gen_dir.exists() and (image_gen_dir / ".venv").exists():
122129
typer.echo("Starting image-generator-hub...")
123-
image_gen_dir = self.needle_home.parent / "ImageGeneratorsHub"
130+
python_path = image_gen_dir / ".venv" / "bin" / "python"
124131
command = [
125-
"bash", "-c",
126-
f"cd {image_gen_dir} && source .venv/bin/activate && uvicorn main:app --host 0.0.0.0 --port 8010"
132+
str(python_path), "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8010"
127133
]
128134
log_file = self.needle_home / "logs" / "image-generator-hub.log"
129-
self._start_virtual_env_service("Image-generator-hub", command, self.image_gen_pid_file, log_file)
135+
self._start_virtual_env_service("Image-generator-hub", command, self.image_gen_pid_file, log_file, image_gen_dir)
130136
else:
131-
typer.echo("Warning: ImageGeneratorsHub not found. Image generation will not be available.")
137+
typer.echo("Warning: ImageGeneratorsHub not found or virtual environment not set up. Image generation will not be available.")
132138

133139
# Start backend
134140
typer.echo("Starting Needle backend...")
@@ -138,7 +144,11 @@ def start_services(self):
138144
str(python_path), "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"
139145
]
140146
log_file = self.needle_home / "logs" / "backend.log"
141-
self._start_virtual_env_service("Backend", command, self.backend_pid_file, log_file, backend_dir)
147+
# Set the config directory path to the correct location
148+
env_vars = {
149+
"SERVICE__CONFIG_DIR_PATH": str(self.needle_home / "configs" / "fast")
150+
}
151+
self._start_virtual_env_service("Backend", command, self.backend_pid_file, log_file, backend_dir, env_vars)
142152

143153
typer.echo("All services started!")
144154
typer.echo("🌐 Access Points:")

0 commit comments

Comments
 (0)