Skip to content

Commit

Permalink
revert 188 (#189)
Browse files Browse the repository at this point in the history
* revert 188

* Bump version: 1.3.87 → 1.3.88-dev0

* Bump version: 1.3.88-dev0 → 1.3.88

---------

Co-authored-by: Volodymyr Savchenko <[email protected]>
  • Loading branch information
volodymyrss and Volodymyr Savchenko authored Jun 20, 2024
1 parent 34334ca commit ac4c3e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
26 changes: 4 additions & 22 deletions nb2workflow/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def import_repo(repo_source, target):
return checksumdir.dirhash(target)


def prepare_image(repo_source, from_image, service=True, nb2w_path=None, runprefix="",
entrypoint=None, extra_docker_commands=[]):
def prepare_image(repo_source, from_image, service=True, nb2w_path=None, runprefix="", entrypoint=None):

tempdir = tempfile.mkdtemp()

Expand All @@ -48,8 +47,6 @@ def prepare_image(repo_source, from_image, service=True, nb2w_path=None, runpref

dockerfile.append("FROM {}".format(from_image))
dockerfile.append("ARG REPO_PATH=./{}".format(rel_repo_path))
for ec in extra_docker_commands:
dockerfile.append(ec)

pipconf = os.path.join(repo_path, 'pip.conf')
logger.info("using pipconf %s", pipconf)
Expand Down Expand Up @@ -97,19 +94,15 @@ def prepare_image(repo_source, from_image, service=True, nb2w_path=None, runpref
return tempdir


def build_image(tempdir, tag_image, nb2workflow_revision, extra_arguments=None):
def build_image(tempdir, tag_image, nb2workflow_revision):
cli = docker.from_env()

buildargs=dict(nb2workflow_revision=nb2workflow_revision)
if extra_arguments is not None:
buildargs.update(extra_arguments)

print("-- building image, tagging as", tag_image)
r = cli.api.build(
path=tempdir,
tag=tag_image,
quiet=False,
buildargs=buildargs,
buildargs=dict(nb2workflow_revision=nb2workflow_revision),
# stream=True,
rm=True,
)
Expand Down Expand Up @@ -144,8 +137,6 @@ def main():
metavar='location', type=str, default=None)
parser.add_argument('--docker-command', type=str, default=None)
parser.add_argument('--entrypoint', type=str, default=None)
parser.add_argument('--extra-docker-commands', type=str, default=None)
parser.add_argument('--extra-build-arguments', type=str, default=None)

args = parser.parse_args()

Expand All @@ -160,29 +151,20 @@ def main():
if args.tag_image == "":
tag_image = os.path.basename(os.path.abspath(repo_path))

extra_docker_commands=[]
if args.extra_docker_commands is not None:
#print("Extra Docker command is ", args.extra_docker_commands)
extra_docker_commands= args.extra_docker_commands.split(';')

tempdir = prepare_image(
repo_path, args.from_image,
service=not args.job,
nb2w_path=args.nb2wpath,
runprefix=args.docker_run_prefix,
entrypoint=args.entrypoint,
extra_docker_commands=extra_docker_commands
)

if args.store_dockerfile:
shutil.copy(os.path.join(tempdir, "Dockerfile"), args.store_dockerfile)
print("\033[31mstored Dockerfile as\033[0m", args.store_dockerfile)

if args.build:
extra_build_arguments=None
if args.extra_build_arguments is not None:
extra_build_arguments = json.loads(args.extra_build_arguments)
build_result = build_image(tempdir, tag_image, args.nb2wrev, extra_build_arguments)
build_result = build_image(tempdir, tag_image, args.nb2wrev)

if build_result is None:
raise Exception("failed to build")
Expand Down
1 change: 0 additions & 1 deletion nb2workflow/nbadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ def extract_parameters(self):
('parameters', 'input_parameters'),
('system-parameters', 'system_parameters'),
('injected-parameters', 'input_parameters'),
('refs', 'source_parameters'),
]:
if tag in cell.metadata.get('tags', []):
pars = self.extract_parameters_from_cell(cell)
Expand Down

0 comments on commit ac4c3e2

Please sign in to comment.