lfcrepo
: Interface to git repos with large-file control¶
This module provides the LFCRepo
, which provides tools for
interacting with Git repositories. This includes actions to hash, store,
and transfer large files tracked with lfc
.
- class lfc.lfcrepo.LFCRepo(where=None)¶
LFC interface to individual repositories
- Call:
>>> repo = LFCRepo(where=None)
- Inputs:
- where: {
None
} |str
Location of repo (
None
->os.getcwd()
)
- where: {
- bare¶
True
|False
– Whether this instance is in a bare repository
- check_cache(flfc: str)¶
Check if large file is in local cache
- Call:
>>> status = repo.check_cache(flfc)
- Inputs:
- repo:
GitRepo
Interface to git repository
- fname:
str
Name of file
- repo:
- Outputs:
- status:
True
|False
Whether file is present in local cache
- status:
- Versions:
2022-12-28
@ddalle
: v1.0
- close_lfc_portal(remote=None)¶
Close large file transfer portal, if any
- Call:
>>> repo.close_lfc_portal(remote=None)
- Inputs:
- repo:
GitRepo
Interface to git repository
- remote: {
None
} |str
Name of remote, or default
- repo:
- Versions:
2022-12-20
@ddalle
: v1.02023-10-26
@ddalle
: v1.1; multiple portals
- find_lfc_files(pattern=None, ext=None, mode=None, **kw) list ¶
Find all large file stubs
- Call:
>>> lfcfiles = repo.find_lfc_files(pattern=None, ext=None)
- Inputs:
- repo:
GitRepo
Interface to git repository
- pattern: {
None
} |str
Pattern to restrict search of large file stubs
- ext: {
None
} |".lfc"
|".dvc"
Optional manual working stub extension to use
- repo:
- Outputs:
- Versions:
2022-12-20
@ddalle
: v1.02022-12-28
@ddalle
: v1.1; bug fix for empty result- 2023-10-26
@ddalle
: v2.0 use
ls_tree()
instead of callinggit ls-files
works with
lfc add data/
or similar
- 2023-10-26
2023-11-08
@ddalle
: v2.1; add mode
- genr8_lfc_filename(fname: str, ext=None) str ¶
Produce name of large file stub
- Call:
>>> flfc = repo.genr8_lfc_filename(fname)
- Inputs:
- repo:
GitRepo
Interface to git repository
- fname:
str
Name of file, either original file or metadata stub
- ext: {
None
} |".dvc"
|".lfc"
Large file metadata stub file extension
- repo:
- Outputs:
- flfc:
str
Name of large file metadata stub file
- flfc:
- Versions:
2022-12-21
@ddalle
: v1.0
- genr8_lfc_glob(*fnames, mode=None)¶
Generate list of
.lfc
files matchin one or more pattern
- genr8_lfc_ofilename(fname: str) str ¶
Produce name of original large file
This strips the
.lfc
or.dvc
extension if necessary.
- get_cachedir()¶
Get name of large file cache folder
- Call:
>>> fdir = repo.get_cachedir()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- fdir:
str
Absolute path to large file cache
- fdir:
- Versions:
2022-12-19
@ddalle
: v1.02022-12-22
@ddalle
: v1.1: bare repo omits “.lfc”
- get_lfc_autopull() int ¶
Get the LFC mode for auto-pull
0
: do not auto-pull files1
: auto-pull all files2
: auto-pull all mode-2 files (default)
- Call:
>>> mode = repo.get_lfc_autopull()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- mode:
int
Files of LCF files to automatically push
- mode:
- get_lfc_autopush() int ¶
Get the LFC mode for auto-push
0
: do not auto-push files1
: auto-push all files2
: auto-push all mode-2 files (default)
- Call:
>>> mode = repo.get_lfc_autopush()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- mode:
int
Files of LCF files to automatically push
- mode:
- get_lfc_configfile(ext=None)¶
Get name of LFC configuration file
In a bare repo, this will return the path relative to the root, e.g.
".lfc/config"
. In a working repo, it will return the absolute path.- Call:
>>> fcfg = repo.get_lfc_configfile(ext=None)
- Inputs:
- repo:
GitRepo
Interface to git repository
- ext: {
None
} |".lfc"
|".dvc"
Optional manual override for file extension
- repo:
- Outputs:
- fcfg:
str
Name of large file client configuration
- fcfg:
- Versions:
2022-12-20
@ddalle
: v1.02022-12-28
@ddalle
: v1.1; optional ext input
- get_lfc_ext(vdef='.lfc')¶
Get name of large file utility
- Call:
>>> ext = repo.get_lfc_ext(vdef=".lfc")
- Inputs:
- repo:
GitRepo
Interface to git repository
- vdef: {
".lfc"
} |".dvc"
Preferred default if neither is present
- repo:
- Outputs:
- ext:
".dvc"
|".lfc"
Working extenion to use for large file stubs
- ext:
- Versions:
2022-12-19
@ddalle
: v1.02022-12-22
@ddalle
: v2.0; valid for bare repos
- get_lfc_hash(fname: str, ref=None)¶
Get hash code used by LFC for a large file
- Call:
>>> hashcode = repo.read_lfc_file(fname, ref=None)
- Inputs:
- Outputs:
- hashcode:
str
SHA-256 hash code from LFC file (MD-5 if added by DVC)
- hashcode:
- Versions:
2011-12-22
@ddalle
: v1.0
- get_lfc_remote_url(remote=None)¶
Get URL for a large file client remote
- get_lfcdir()¶
Get path to large file root dir
- Call:
>>> fdir = repo.get_lfcdir()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- fdir:
str
Path to LFC/DVC settings dir,
.lfc
or.dvc
- fdir:
- Versions:
2022-12-19
@ddalle
: v1.0
- lfc_add(*fnames, **kw)¶
Add one or more large files
- lfc_config_get(fullopt: str, vdef=None) str ¶
Get an option from the large file client configuration
- Call:
>>> val = repo.lfc_config_get(section, opt)
- Inputs:
- Outputs:
- val:
str
Raw value of LCF config option
- val:
- Raises:
GitutilsKeyError
if either section or opt is missing from the LFC config (unless vdef is set)
- Versions:
2022-12-27
@ddalle
: v1.0
- lfc_init(**kw)¶
Initialize a git repo for Large File Control
- Call:
>>> repo.lfc_init()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Versions:
2022-12-28
@ddalle
: v1.02023-10-25
@ddalle
: v1.1; better double-call behavior
- lfc_install_hooks(*a, **kw)¶
Install full set of git-hooks for this repo
- Call:
>>> repo.lfc_install_hooks()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- lfc_install_post_merge(*a, **kw)¶
Install
post-merge
hook to auto-pull mode=2 files- Call:
>>> repo.lfc_install_post_merge()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- lfc_install_pre_push(*a, **kw)¶
Install
pre-push
hook to auto-push some files- Call:
>>> repo.lfc_install_pre_push()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- lfc_pull(*fnames, **kw)¶
Pull one or more large files from remote cache
- Call:
>>> repo.lfc_pull(*fnames, **kw)
- Inputs:
- Versions:
2022-12-28
@ddalle
: v1.02023-11-08
@ddalle
: v1.1; add mode
- lfc_push(*fnames, **kw)¶
Push one or more large files to remote cache
- lfc_replace_dvc()¶
Fully subsitute local large file control in place of DVC
This command will move all
.dvc
metadata stub files to the same name but with.lfc
as the extension. It will also move the.dvc/
folder to.lfc/
and remove the.dvc/plots/
folder and.dvcignore
file.If both
.dvc/
and.lfc/
exist, this function will merge the caches so that any files in.dvc/cache/
are copied into.lfc/cache/
.It does not recompute any hashes as LFC can work with MD-5 hashes. It does not compute any new ones, but it can still utilize the old ones and have the two intermixed.
- Call:
>>> repo.lfc_replace_dvc()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Versions:
2022-12-28
@ddalle
: v1.02023-03-17
@ddalle
: v1.1; delete .dvc/plots first2023-10-27
@ddalle
: v1.2; merge caches
- lfc_set_mode(*fnames, **kw)¶
Set LFC mode for one or more files
- lfc_show(fname: str, ref=None, **kw)¶
Show the contents of an LFC file from a local cache
- Call:
>>> contents = repo.lfc_show(fname)
- Inputs:
- Outputs:
- contents:
bytes
Contents of large file read from LFC cache
- contents:
- Versions:
2011-12-22
@ddalle
: v1.0
- make_cachedir()¶
Create large file cache folder if necessary
- Call:
>>> repo.make_cachedir()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Versions:
2022-12-19
@ddalle
: v1.0
- make_lfc_config()¶
Read large file client config file, or access current
- Call:
>>> config = repo.make_lfc_config()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- config:
configparser.ConfigParser
Python interface to LFC configuration
- config:
- Versions:
2022-12-22
@ddalle
: v1.0
- make_lfc_portal(remote=None) SSHPortal ¶
Open SSH/SFTP portal for large files
- Call:
>>> portal = repo.make_lfc_portal(slot="lfc_portal")
- Inputs:
- repo:
GitRepo
Interface to git repository
- remote: {
None
} |str
Name of remote, or default
- repo:
- Outputs:
- portal:
None
|shellutils.SSHPortal
Persistent file transfer portal
- portal:
- Versions:
2022-12-20
@ddalle
: v1.02023-10-26
@ddalle
: v1.1; multiple portals
- read_lfc_config()¶
Read large file client config file, even on bare repo
- Call:
>>> config = repo.read_lfc_config()
- Inputs:
- repo:
GitRepo
Interface to git repository
- repo:
- Outputs:
- config:
configparser.ConfigParser
Python interface to LFC configuration
- config:
- Versions:
2022-12-22
@ddalle
: v1.0
- read_lfc_file(fname: str, ref=None, ext=None)¶
Read status information from large file stub
- Call:
>>> info = repo.read_lfc_file(fname, ref=None, ext=None)
- Inputs:
- Outputs:
- Versions:
2011-12-20
@ddalle
: v1.0
- read_lfc_mode(fname: str, ref=None, ext=None) int ¶
Read LFC file mode for a tracked file
- Call:
>>> mode = repo.read_lfc_mode(fname, ref=None)
- Inputs:
- Outputs:
- mode:
1
|2
LFC file mode:
1
: Only push/pull file on-demand2
: Automatically push/pull most recent version
- mode:
- Versions:
2023-11-08
@ddalle
: v1.0
- resolve_lfc_remote_name(remote=None)¶
Resolve default LFC remote, if necessary
- write_lfc_config(config)¶
Write current large file configuration to file
- Call:
>>> repo.write_lfc_config(config)
- Inputs:
- repo:
GitRepo
Interface to git repository
- config:
configparser.ConfigParser
Python interface to LFC configuration
- repo:
- Versions:
2022-12-27
@ddalle
: v1.0