Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
singularity on pypi), and the versions here will coincide with these releases.

## [master](https://github.com/singularityhub/singularity-cli/tree/master)
- parser bugfixes, arg from Docker not properly parsed (0.0.19)
- adding support for SIF (oras pull) (0.1.18)
- updating CI/tests and fixing deprecations (warnings) (0.1.17)
- fixing bug with defining comments earlier (0.1.16)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def get_requirements(lookup=None):
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Unix",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
],
entry_points={"console_scripts": ["spython=spython.client:main"]},
Expand Down
2 changes: 1 addition & 1 deletion spython/image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from spython.utils import split_uri


class ImageBase(object):
class ImageBase:
def __str__(self):
protocol = getattr(self, "protocol", None)
if protocol:
Expand Down
2 changes: 1 addition & 1 deletion spython/image/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate_image_commands():

"""

class ImageClient(object):
class ImageClient:
group = "image"

from spython.main.base.logger import println
Expand Down
2 changes: 1 addition & 1 deletion spython/logger/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ETA_SMA_WINDOW = 9


class ProgressBar(object):
class ProgressBar:
def __enter__(self):
return self

Expand Down
6 changes: 3 additions & 3 deletions spython/main/parse/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..recipe import Recipe


class ParserBase(object):
class ParserBase:
"""a parser Base is intended to provide helper functions for a parser,
namely to read lines in files, and otherwise interact with outputs.
Input should be some recipe (text file to describe a container build)
Expand Down Expand Up @@ -155,6 +155,6 @@ def _replace_from_dict(self, string, args):
string: the string with replacements made
"""
for key, value in args.items():
if re.search(r"\$(" + key + r"|\{[^}]*\})", string):
string = re.sub(r"\$(" + key + r"|\{[^}]*\})", value, string)
if re.search("([$]" + key + "|[$][{]" + key + "[}])", string):
string = re.sub("([$]" + key + "|[$]{" + key + "[}])", value, string)
return string
2 changes: 1 addition & 1 deletion spython/main/parse/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.


class Recipe(object):
class Recipe:
"""a recipe includes an environment, labels, runscript or command,
and install sequence. This object is interacted with by a Parser
(intended to popualte the recipe with content) and a Writer (intended
Expand Down
2 changes: 1 addition & 1 deletion spython/main/parse/writers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from spython.utils import write_file


class WriterBase(object):
class WriterBase:
def __init__(self, recipe=None):
"""a writer base will take a recipe object (parser.base.Recipe) and
provide helpers for writing to file.
Expand Down
16 changes: 8 additions & 8 deletions spython/main/parse/writers/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ def validate_stage(self, parser):
if parser.fromHeader is None:
bot.exit("Dockerfile requires a fromHeader.")

# Parse the provided name
uri_regexes = [_reduced_uri, _default_uri, _docker_uri]
# Parse the provided name
uri_regexes = [_reduced_uri, _default_uri, _docker_uri]

for r in uri_regexes:
match = r.match(parser.fromHeader)
if match:
break
for r in uri_regexes:
match = r.match(parser.fromHeader)
if match:
break

if not match:
bot.exit("FROM header %s not valid." % parser.fromHeader)
if not match:
bot.exit("FROM header %s not valid." % parser.fromHeader)

def convert(self, runscript="/bin/bash", force=False):
"""convert is called by the parent class to convert the recipe object
Expand Down
7 changes: 5 additions & 2 deletions spython/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def test_data(installdir): # pylint: disable=redefined-outer-name
@pytest.fixture(scope="session")
def oras_container(tmp_path_factory):
folder = tmp_path_factory.mktemp("oras-img")
return folder, Client.pull(
"oras://ghcr.io/singularityhub/github-ci:latest", pull_folder=str(folder)
return (
folder,
Client.pull(
"oras://ghcr.io/singularityhub/github-ci:latest", pull_folder=str(folder)
),
)


Expand Down
2 changes: 1 addition & 1 deletion spython/tests/test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_has_no_instances():
assert instances == []


class TestInstanceFuncs(object):
class TestInstanceFuncs:
@pytest.fixture(autouse=True)
def test_instance_cmds(self, docker_container):
image = docker_container[1]
Expand Down
38 changes: 38 additions & 0 deletions spython/tests/testdata/docker2singularity/argsub.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Bootstrap: docker
From: nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04
Stage: spython-base

%files
./requirements.txt /workspace
%labels
maintainer="Dong Wang"
%post
CUDA_VERSION=11.1.1
OS_VERSION=20.04




PATH="/root/miniconda3/bin:${PATH}"
PATH="/root/miniconda3/bin:${PATH}"
DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "-c"]

apt-get update && apt-get upgrade -y &&\
apt-get install -y wget python3-pip

python3 -m pip install --upgrade pip

cd /workspace
python3 -m pip install -r /workspace/requirements.txt and &&\
rm /workspace/requirements.txt

%environment
export PATH="/root/miniconda3/bin:${PATH}"
%runscript
cd /workspace
exec /bin/bash /bin/bash "$@"
%startscript
cd /workspace
exec /bin/bash /bin/bash "$@"
25 changes: 25 additions & 0 deletions spython/tests/testdata/docker2singularity/argsub.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG CUDA_VERSION=11.1.1
ARG OS_VERSION=20.04

FROM nvidia/cuda:${CUDA_VERSION}-cudnn8-devel-ubuntu${OS_VERSION}

LABEL maintainer="Dong Wang"


ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
ARG DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y wget python3-pip

RUN python3 -m pip install --upgrade pip

WORKDIR /workspace
ADD ./requirements.txt /workspace
RUN python3 -m pip install -r /workspace/requirements.txt and &&\
rm /workspace/requirements.txt

CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion spython/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setEnvVar(name, value):
os.environ[name] = value


class ScopedEnvVar(object):
class ScopedEnvVar:
"""Temporarly change an environment variable

Usage:
Expand Down
2 changes: 1 addition & 1 deletion spython/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.


__version__ = "0.1.18"
__version__ = "0.1.19"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsoch@users.noreply.github.com"
NAME = "spython"
Expand Down