Skip to content

Commit

Permalink
Fix download actions
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Feb 17, 2024
1 parent 04098e4 commit e91450e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
17 changes: 14 additions & 3 deletions src/sos/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,38 @@
#
# Copyright (c) Bo Peng and the University of Texas MD Anderson Cancer Center
# Distributed under the terms of the 3-clause BSD License.

import copy
import gzip
import os
import shlex
import shutil
import subprocess
import sys
import tarfile
import tempfile
import textwrap
import time
import urllib
import urllib.error
import urllib.parse
import urllib.request
import uuid
import zipfile
from collections.abc import Sequence
from concurrent.futures import ProcessPoolExecutor
from functools import wraps
from typing import Any, Callable, Dict, List, Tuple, Union

from tqdm import tqdm as ProgressBar

from .controller import send_message_to_controller
from .eval import interpolate
from .messages import decode_msg, encode_msg
from .parser import SoS_Script
from .syntax import SOS_ACTION_OPTIONS
from .targets import executable, file_target, path, paths, sos_targets
from .utils import (TimeoutInterProcessLock, env, load_config_files,
short_repr, textMD5, transcribe)
from .utils import (TimeoutInterProcessLock, env, fileMD5, get_traceback,
load_config_files, short_repr, textMD5, transcribe)

__all__ = [
"SoS_Action",
Expand Down Expand Up @@ -758,6 +767,7 @@ def script(script, interpreter="", suffix="", args="", entrypoint="", **kwargs):
# download file with progress bar
#


def downloadURL(URL, dest, decompress=False, index=None):
dest = os.path.abspath(os.path.expanduser(dest))
dest_dir, filename = os.path.split(dest)
Expand Down Expand Up @@ -953,6 +963,7 @@ def downloadURL(URL, dest, decompress=False, index=None):
os.remove(dest_tmp)
return os.path.isfile(dest)


@SoS_Action(acceptable_args=["URLs", "workdir", "dest_dir", "dest_file", "decompress", "max_jobs"])
def download(URLs, dest_dir=".", dest_file=None, decompress=False, max_jobs=5):
"""Download files from specified URL, which should be space, tab or
Expand Down
17 changes: 1 addition & 16 deletions src/sos/functions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import gzip
import tarfile
import urllib
import urllib.error
import urllib.parse
import urllib.request
import zipfile
from concurrent.futures import ProcessPoolExecutor

import pkg_resources
from tqdm import tqdm as ProgressBar

from .utils import (StopInputGroup, TerminateExecution, env, fileMD5,
get_traceback)
from .utils import (StopInputGroup, TerminateExecution, env)

# g_action_map = {}


# def _load_actions():
# global g_action_map # pylint: disable=global-variable-not-assigned
# for _entrypoint in pkg_resources.iter_entry_points(group="sos_actions"):
Expand All @@ -31,7 +17,6 @@
# # look for sos version requirement
# get_logger().warning(f"Failed to load script running action {_entrypoint.name}: {e}")


# def sos_run_script(action, script, *args, **kwargs):
# '''Call script-execution actions.'''
# if not g_action_map:
Expand Down
2 changes: 0 additions & 2 deletions test/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# Copyright (c) Bo Peng and the University of Texas MD Anderson Cancer Center
# Distributed under the terms of the 3-clause BSD License.

import os
import shutil
import subprocess
Expand Down Expand Up @@ -841,7 +840,6 @@ def test_remote_output(clear_now_and_after):
assert res.read() == "100"



def test_runtime_max_walltime():
"""Test server max_walltime option"""
# only warning messages will be yielded
Expand Down

0 comments on commit e91450e

Please sign in to comment.