Repositories
Learn how to use the Repository classes.
Repository Classes
There are a few basic python classes you can use to interact with Oxen repositories. The full list of Python APIs can be found in the API Documentation.
Remote vs Local
Oxen has the concept of Remote Repositories and Local Repositories. One of the core tenets of Oxen is that data should feel like it is local, even if it is not. Hence the APIs for Local vs Remote are very similar, the only difference is where you are performing the operation.
Remote Repositories
Remote Repositories only download pointers and metadata, so that you can interact with the data as if it was local.
Here is the full documentation for the RemoteRepo.
Integrate with Pandas
The fastest way to integrate Oxen into your existing workflow is to use the fact that Oxen give you direct access to files and directories given a specific revision.
For example let’s load a data file given a specific commit into Pandas
All the files are also accessible directly over http, which removes some of the boiler plate as long as the files are of a reasonable size.
The url structure is https://hub.oxen.ai/api/repos/:namespace/:repo_name/file/:revision/:file_path
Add Files
Oxen has the concept of Remote Workspaces that make it easy to add data to a remote repository without ever downloading it locally.
Local Repositories
Local Repositories have all the files versioned and accessible on your local machine. They duplicate the data between your working directory and a hidden .oxen directory so that you can quickly swap between versions and run experiments.
If you are creating a new repository from scratch, this is a great place to start. The workflow is very similar to git in terms of initializing a repository, adding data, committing, and pushing to a remote.
Let’s walk through some basic operations.
Init
Assuming you are creating a brand new repository, first you will have to create an empty directory, point your LocalRepo
to it and run init()
.
Add Files
Now let’s create a README.md file and add it to the local staging area.
You should see that we have one file added [README.md]
Commit Staged Files
With your README.md staged you can now commit with a message
🎉 Congratulations you have just versioned your first file! Now to sync it with the rest of your team.
Configure Remote
The easiest way to create a remote is in the Oxen Hub web interface.
Then once you have a remote created, set the remote on the repo object.
Push to Remote
With your remote set and auth key configured, you are ready to push the data!