Skip to content

Commit c12623e

Browse files
committed
fix: s5cmd is missing in local mode
1 parent d39d722 commit c12623e

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

src/pipeline/pipeline.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import importlib
66
import json
77
import logging
8+
import urllib.request
9+
import zipfile
810
from concurrent.futures import as_completed,ProcessPoolExecutor
911

1012
from utils.common import download_file_from_s3_by_s5cmd
@@ -24,6 +26,9 @@
2426

2527
logger = get_logger(__name__)
2628

29+
# Global constants
30+
S5CMD_PATH = "./s5cmd"
31+
2732

2833
def parse_args():
2934
parser = argparse.ArgumentParser()
@@ -241,19 +246,46 @@ def get_executable_model(args):
241246
return execute_model
242247

243248
def download_s5cmd():
244-
assert os.system('curl https://github.com/peak/s5cmd/releases/download/v2.0.0/s5cmd_2.0.0_Linux-64bit.tar.gz -L -o /tmp/s5cmd.tar.gz') == 0
245-
assert os.system("mkdir -p /tmp/s5cmd && tar -xvf /tmp/s5cmd.tar.gz -C /tmp/s5cmd") == 0
246-
assert os.system(f"cp /tmp/s5cmd/s5cmd .") == 0
249+
"""Download s5cmd binary using S3 URL (always use us-east-1 for local deployment)"""
250+
# Check if s5cmd already exists
251+
if os.path.exists(S5CMD_PATH):
252+
return S5CMD_PATH
253+
254+
s5cmd_url = "https://aws-gcr-solutions-us-east-1.s3.us-east-1.amazonaws.com/easy-model-deployer/pipeline/s5cmd.zip"
255+
256+
try:
257+
# Download and extract
258+
zip_path = S5CMD_PATH + ".zip"
259+
urllib.request.urlretrieve(s5cmd_url, zip_path)
260+
261+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
262+
zip_ref.extractall(".")
263+
264+
os.remove(zip_path) # Clean up zip file
265+
266+
# Make s5cmd executable
267+
if os.path.exists(S5CMD_PATH):
268+
os.chmod(S5CMD_PATH, os.stat(S5CMD_PATH).st_mode | 0o755)
269+
return S5CMD_PATH
270+
else:
271+
raise FileNotFoundError("Required component(s5cmd) installation failed")
272+
273+
except Exception as e:
274+
raise RuntimeError("Required component(s5cmd) download failed")
247275

248276
if __name__ == "__main__":
249277
t0 = time.time()
250278
start_time = time.time()
251279
args = parse_args()
252-
if not (check_cn_region(args.region) or args.region == LOCAL_REGION):
253-
download_s5cmd()
254-
255-
s5_cmd_path = "./s5cmd"
256-
os.chmod(s5_cmd_path, os.stat(s5_cmd_path).st_mode | 0o100)
280+
281+
# Download s5cmd
282+
download_s5cmd()
283+
284+
if not os.path.exists(S5CMD_PATH):
285+
logger.error("Required component(s5cmd) not found")
286+
sys.exit(1)
287+
288+
os.chmod(S5CMD_PATH, os.stat(S5CMD_PATH).st_mode | 0o100)
257289
extra_params = args.extra_params
258290
for k,v in extra_params.items():
259291
setattr(args,k,v)

0 commit comments

Comments
 (0)