From 2f91866e4eafcbf5187484ba593c9d36d0c09e94 Mon Sep 17 00:00:00 2001 From: basile Date: Tue, 14 Mar 2023 11:56:59 -0400 Subject: [PATCH 1/2] add procedure to configure non-annexing of docker metadata --- .../resources/procedures/cfg_containers.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 datalad_container/resources/procedures/cfg_containers.py diff --git a/datalad_container/resources/procedures/cfg_containers.py b/datalad_container/resources/procedures/cfg_containers.py new file mode 100644 index 00000000..bb2ef30c --- /dev/null +++ b/datalad_container/resources/procedures/cfg_containers.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Procedure to configure dataset for containers +""" + +import sys + +from datalad.distribution.dataset import require_dataset +from datalad.support import path as op + +ds = require_dataset( + sys.argv[1], + check_installed=True, + purpose='Containers dataset configuration') + +# unless taken care of by the template already, each item in here +# will get its own .gitattributes entry to keep it out of the annex +# give relative path to dataset root (use platform notation) +force_in_git = [ + op.join('environments','**','*.json'), + op.join('environments','*','image','repositories'), +] +# make an attempt to discover the prospective change in .gitattributes +# to decide what needs to be done, and make this procedure idempotent +# (for simple cases) +attr_fpath = op.join(ds.path, '.datalad', '.gitattributes') +if op.lexists(attr_fpath): + with open(attr_fpath, 'rb') as f: + attrs = f.read().decode() +else: + attrs = '' + +# amend gitattributes, if needed +ds.repo.set_gitattributes([ + (path, {'annex.largefiles': 'nothing'}) + for path in force_in_git + if '{} annex.largefiles=nothing'.format(path) not in attrs +], attrfile=attr_fpath) + +# leave clean +ds.save( + path=[attr_fpath], + message="Apply default containers dataset setup", + to_git=True, +) From c1ffe671a385e162001f3011451e59ad535248f5 Mon Sep 17 00:00:00 2001 From: Basile Date: Tue, 21 Mar 2023 08:52:35 -0400 Subject: [PATCH 2/2] Update datalad_container/resources/procedures/cfg_containers.py Co-authored-by: Yaroslav Halchenko --- datalad_container/resources/procedures/cfg_containers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datalad_container/resources/procedures/cfg_containers.py b/datalad_container/resources/procedures/cfg_containers.py index bb2ef30c..8dd19186 100644 --- a/datalad_container/resources/procedures/cfg_containers.py +++ b/datalad_container/resources/procedures/cfg_containers.py @@ -16,8 +16,8 @@ # will get its own .gitattributes entry to keep it out of the annex # give relative path to dataset root (use platform notation) force_in_git = [ - op.join('environments','**','*.json'), - op.join('environments','*','image','repositories'), + 'environments/**/*.json', + 'environments/*/image/repositories', ] # make an attempt to discover the prospective change in .gitattributes # to decide what needs to be done, and make this procedure idempotent