Developer Center

Resources to get you started with Algorithmia

Using Git with Algorithmia

Updated

Every algorithm on Algorithmia has a dedicated git repository. Using this repository allows you to seamlessly integrate Algorithmia with your current workflows, such as your code editor, IDE, or deployment pipelines. If you’re unfamiliar with git we recommend this brief guide.

Demo for Git

Accessing a repository

You can clone existing algorithms from the following endpoint:

    git clone https://git.algorithmia.com/git/:username/:algoname.git

Replace the :username and :algoname parts with the correct values, case sensitive. If you are part of an organization, replace :username with the name of your org.

Committing changes to an algorithm

First pull from origin to make sure you have the latest changes to the master branch.

git pull origin master

Then add your changes as usual.

git -A your_file_to_commit
git commit -m "Message about commit changes"

Once ready, push to Algorithmia.

git push origin master

Everything will behave as a normal git repository, with the additional post-commit hook that will compile your master branch, create a private REST API endpoint, and print out that API endpoint to your console.

The output of git push will print a last line that looks something like this:

Remote: build successful for algo://:username/:algoname/:hash

This endpoint is private to you only (and your organization if you are part of one), and behaves just like a public/published algorithm except for the fact that it is not listed in the marketplace and will only accept calls from your API keys. This is a great way to run regression tests against an algorithm before making it available to others.

Testing your changes

With the private REST API endpoint in hand, you can run your unit tests against it or manually test that algorithm from the command line using the Algorithmia CLI. Testing using the CLI will be something similar to:

algo run :username/:algoname/:hash -d "<JSON_INPUT>"

See the Algorithmia CLI for more options.

Managing branches

Branches are allowed and will be accepted in pushes, however Algorithmia will not compile branches other than master.

Algorithmia will only compile the head of the master branch on each push. It will not compile intermediate commits if they are all pushed together as a batch. Finally, Algorithmia will reject any push which contains non-fast-forward commits. This is to prevent changing the history of an algorithm, and potentially breaking Algorithmia’s versioning.

Initializing a repository

As of today, you will need to manually create an algorithm from the web interface in order to initialize a repository. Once a repository is initialized you can clone it as shown above. The web interface is currently necessary in order to specify name and permissions for an algorithm.