Skip to content

Commit

Permalink
Issue1542 (#1543)
Browse files Browse the repository at this point in the history
Fix python 3.12 compatibility issue.
  • Loading branch information
BoPeng authored Apr 10, 2024
1 parent 4f25333 commit a511fa9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ jobs:
run: |
cd test
sh build_test_docker.sh
echo "Running tests"
python run_tests.py
6 changes: 3 additions & 3 deletions src/sos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ def get_execute_parser(desc_only=False):
],
default="default",
metavar="SIGMODE",
dest="sig_mode",
dest="__sig_mode__",
help="""How runtime signature would be handled, which can be "default"
(save and use signature, default mode in batch mode),
"force" (ignore existing signature and overwrite them while
Expand Down Expand Up @@ -1460,8 +1460,8 @@ def cmd_execute(args, workflow_args):
"config_file":
args.config,
"sig_mode":
"default" if args.sig_mode in (None,
"ignore") else args.sig_mode,
"default" if args.__sig_mode__ in (None,
"ignore") else args.__sig_mode__,
"run_mode":
"dryrun" if args.dryrun else
(args.run_mode if args.run_mode else "run"),
Expand Down
10 changes: 4 additions & 6 deletions src/sos/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,10 @@ def summarizeExecution(task_id, pulses, status="Unknown"):
accu_cpu += float(c) + float(cc)
accu_mem += float(m) + float(cm)
count += 1
if float(c) + float(cc) > peak_cpu:
peak_cpu = float(c) + float(cc)
if float(m) + float(cm) > peak_mem:
peak_mem = float(m) + float(cm)
if int(nch) > peak_nch:
peak_nch = int(nch)

peak_cpu = max(peak_cpu, float(c) + float(cc))
peak_mem = max(float(m) + float(cm), peak_mem)
peak_nch = max(int(nch), peak_nch)
try:
second_elapsed = end_time - start_time
except Exception:
Expand Down
11 changes: 8 additions & 3 deletions src/sos/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,13 @@ class file_target(path, BaseTarget):
"""A regular target for files."""

def __init__(self, *args, **kwargs):
# this is path segments
super().__init__(*args, **kwargs)
if sys.version_info[0] >= 3 and sys.version_info[1] >= 12:
# python 3.12 and above
path.__init__(self, *args, **kwargs)
else:
# python 2.10 and 3.11
path.__init__(self)
BaseTarget.__init__(self, *args, **kwargs)
if len(args) == 1 and isinstance(args[0], file_target):
self._md5 = args[0]._md5 if hasattr(args[0], '_md5') else None
else:
Expand Down Expand Up @@ -675,7 +680,7 @@ def __new__(cls, path=None, name=None, suffix=None, prefix=None, dir=None):
if cls is Path:
cls = WindowsPath if os.name == "nt" else PosixPath
filename = request_answer_from_controller(["sos_tempfile", path, name, suffix, prefix, dir])
return cls._from_parts([filename])
return file_target(filename)


class paths(Sequence, os.PathLike):
Expand Down
10 changes: 6 additions & 4 deletions test/build_test_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ docker rmi eg_sshd
# copy the public key here
cp ~/.ssh/id_rsa.pub authorized_keys

python_version=$(python --version | cut -d. -f2)
# create a docker file
#
cat > Dockerfile << 'HERE'
FROM python:3.10
echo "FROM python:3.${python_version}" > Dockerfile

cat >> Dockerfile << 'HERE'
RUN apt-get update && apt-get install -y openssh-server rsync task-spooler
RUN mkdir /var/run/sshd
Expand All @@ -41,8 +43,8 @@ RUN [ -d /root/.ssh ] || mkdir -p /root/.ssh
ADD authorized_keys /root/.ssh/authorized_keys
ARG SHA=LATEST
RUN SHA=$SHA git clone http://github.com/vatlab/sos sos
RUN pip install sos sos-pbs
RUN pip install git+https://github.com/vatlab/sos
RUN pip install sos-pbs
RUN echo "export TS_SLOTS=10" >> /root/.bash_profile
Expand Down

0 comments on commit a511fa9

Please sign in to comment.