Code Monkey home page Code Monkey logo

checkpoint's Introduction

Checkpoint

CircleCI Go Report Card

Checkpoint provides a simple means of recording and acting on checkpoints in scripting environments and in particular shell scripts. It allows the user to define appropriate checkpoints in the execution of a script and to skip past those points if the checkpoint has been previously 'completed', ie, deemed as being done. The intent is to allow users to develop scripts incrementally but without having to re-execute all prior steps in a script whilst implementing/iterating on later ones.

set -e
source <(checkpoint use $0)
trap completed EXIT

completed step1 || <action>
completed step2 || <action>

if ! completed step3; then
   <action>
   completed step4 || <action>
fi

Reaching each step implicitly transitions the currently active one to being complete; alternatively the current step can be explicitly marked as complete using completed without an argument. Note that completed is a shell function defined in the context of the shell via the source statement. This shell function tests the exit status of the previous command and will not execute the next step if that command failed.

Another anticipated common use case is to guard the execution of a script based on the arrival or generation of new data.

proposed="date-for-example"

source <(checkpoint use $(basename $proposed))
trap completed EXIT

if completed ready; then
  echo "already-done"
  exit 0
fi

exit 0

Limitations

A linear sequential control flow is currently the only supported execution mode.

Currenly only unix shells are supported, in particular only bash and zsh have been tested, but since little is required of the shell it should work with all other unix-like shells. In particular, the source step only sets an environment variable and defines the step shell function

Session Management and Inspection

Simple checkpoint management is available to list and delete sessions.

checkpoint list
checkpoint delete c4518f9acbeb9d3ac4c7970e899460258cc0f7a923003b73bb0a28fa0f050f99
checkpoint delete c4518f9acbeb9d3ac4c7970e899460258cc0f7a923003b73bb0a28fa0f050f99 step1

The detailed metadata and state associated with a session is available in both raw JSON form (dump) or as a summary (state).

checkpoint dump c4518f9acbeb9d3ac4c7970e899460258cc0f7a923003b73bb0a28fa0f050f99
checkpoint state c4518f9acbeb9d3ac4c7970e899460258cc0f7a923003b73bb0a28fa0f050f99

State Storage

The execution state is currently stored in the user's home directory as files, under $HOME/.checkpointstate/..., but other state stores are anticipated such as dynamodb to allow for execution from other environments such as aws lambda.

checkpoint's People

Contributors

cosnicolaou avatar

Watchers

 avatar  avatar

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.