damienirving / cmdline_provenance Goto Github PK
View Code? Open in Web Editor NEWUtilities for capturing the history of commands used to produce a given output
Home Page: http://cmdline-provenance.readthedocs.io/en/latest/
License: MIT License
Utilities for capturing the history of commands used to produce a given output
Home Page: http://cmdline-provenance.readthedocs.io/en/latest/
License: MIT License
versioneer allows the version of the package to be included within the package automatically based on the git tree. This can be helpful as it means users of the package can easily check the version of the package they're using via <package>.__version__
e.g. cmdline_provenance.__version__
. Is adding this something of interest @DamienIrving?
At the moment if you run cmdprov.new_log()
from a jupyter notebook it will return the command that was run in the background to launch the notebook, which isn't particularly helpful. Instead, the log entry needs to list the name of the notebook.
@MitchellBlack had a go at rolling his own function to get the notebook name at MitchellBlack@d8f1fc9, or the ipynbname library might also be an option.
It might be worth adding some notes to the online documentation to explain how to automate adding some git information to command logs.
gitpython
$ conda install gitpython
sys.path[0]
(which returns the directory your script is in) to get the repository directory. (If your script isn't in the top level directory of the repo, you might need to use something like repo_dir = '/'.join(script_dir.split('/')[:-1])
):import sys
repo_dir = sys.path[0]
import git
print(repo_dir)
/Users/damien/Desktop/data-carpentry
repo = git.Repo(repo_dir)
hash = str(repo.heads[0].commit)
print(hash)
b7f46dafe58cd3be5118766816a3fc190f21a50b
code_url = repo.remotes[0].url.split('.git')[0]
print(code_url)
https://github.com/DamienIrving/data-carpentry
import cmdline_provenance as cmdprov
cmdprov.new_log(code_url=code_url, extra_notes=[f'Git hash: {hash}'])
Fri Apr 16 11:56:38 2021: /Users/damien/opt/anaconda3/envs/pyaos-lesson/bin/jupyter notebook /Users/damien/Desktop/data-carpentry/Untitled.ipynb (https://github.com/DamienIrving/data-carpentry)
Extra notes:
Git hash: b7f46dafe58cd3be5118766816a3fc190f21a50b
@znicholls is helping make cmdline_provenance
installable via conda:
conda-forge/staged-recipes#10801
At the AMOS 2021 Data Carpentry workshop a couple of participants (the rest were fine) were getting git related errors when trying to use cmdline_provenance
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.