Code Monkey home page Code Monkey logo

cmdline_provenance's People

Contributors

damienirving avatar znicholls avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

cmdline_provenance's Issues

versioneer

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?

Handling notebooks

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.

Git advice for online documentation

It might be worth adding some notes to the online documentation to explain how to automate adding some git information to command logs.

  1. Install gitpython
$ conda install gitpython
  1. Use 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
  1. Now access information like the git hash and code url:
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
  1. Add that information to the new log:
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

Git issues?

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...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.