Skip to main content

sgr

Build status Coverage Status PyPI version Discord chat room Follow

Overview

sgr is the CLI for Splitgraph, a serverless API for data-driven Web applications.

With addition of the optional sgr Engine component, sgr can become a stand-alone tool for building, versioning and querying reproducible datasets. We use it as the storage engine for Splitgraph. It's inspired by Docker and Git, so it feels familiar. And it's powered by PostgreSQL, so it works seamlessly with existing tools in the Postgres ecosystem. Use sgr to package your data into self-contained Splitgraph data images that you can share with other sgr instances.

To install the sgr CLI or a local sgr Engine, see the Installation section of this readme.

Build and Query Versioned, Reproducible Datasets

Splitfiles give you a declarative language, inspired by Dockerfiles, for expressing data transformations in ordinary SQL familiar to any researcher or business analyst. You can reference other images, or even other databases, with a simple JOIN.

When you build data images with Splitfiles, you get provenance tracking of the resulting data: it's possible to find out what sources went into every dataset and know when to rebuild it if the sources ever change. You can easily integrate sgr your existing CI pipelines, to keep your data up-to-date and stay on top of changes to upstream sources.

Splitgraph images are also version-controlled, and you can manipulate them with Git-like operations through a CLI. You can check out any image into a PostgreSQL schema and interact with it using any PostgreSQL client. sgr will capture your changes to the data, and then you can commit them as delta-compressed changesets that you can package into new images.

sgr supports PostgreSQL foreign data wrappers. We call this feature mounting. With mounting, you can query other databases (like PostgreSQL/MongoDB/MySQL) or open data providers (like Socrata) from your sgr instance with plain SQL. You can even snapshot the results or use them in Splitfiles.

Components

The code in this repository contains:

  • sgr CLI: sgr is the main command line tool used to work with Splitgraph "images" (data snapshots). Use it to ingest data, work with Splitfiles, and push data to Splitgraph.
  • sgr Engine: a Docker image of the latest Postgres with sgr and other required extensions pre-installed.
  • Splitgraph Python library: All sgr functionality is available in the Python API, offering first-class support for data science workflows including Jupyter notebooks and Pandas dataframes.

Docs

We also recommend reading our Blog, including some of our favorite posts:

Installation

Pre-requisites:

  • Docker is required to run the sgr Engine. sgr must have access to Docker. You either need to install Docker locally or have access to a remote Docker socket.

You can get the sgr single binary from the releases page. Optionally, you can run sgr engine add to create an engine.

For Linux and OSX, once Docker is running, install sgr with a single script:

$ bash -c "$(curl -sL https://github.com/splitgraph/sgr/releases/latest/download/install.sh)"

This will download the sgr binary and set up the sgr Engine Docker container.

See the installation guide for more installation methods.

Quick start guide

You can follow the quick start guide that will guide you through the basics of using sgr with Splitgraph or standalone.

Alternatively, sgr comes with plenty of examples to get you started.

If you're stuck or have any questions, check out the documentation or join our Discord channel!

Contributing

Setting up a development environment

  • sgr requires Python 3.7 or later.
  • Install Poetry: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python to manage dependencies
  • Install pre-commit hooks (we use Black to format code)
  • git clone --recurse-submodules https://github.com/splitgraph/sgr.git
  • poetry install
  • To build the engine Docker image: cd engine && make

Running tests

The test suite requires docker-compose. You will also need to add these lines to your /etc/hosts or equivalent:

127.0.0.1       local_engine
127.0.0.1       remote_engine
127.0.0.1       objectstorage

To run the core test suite, do

docker-compose -f test/architecture/docker-compose.core.yml up -d
poetry run pytest -m "not mounting and not example"

To run the test suite related to "mounting" and importing data from other databases (PostgreSQL, MySQL, Mongo), do

docker-compose -f test/architecture/docker-compose.core.yml -f test/architecture/docker-compose.mounting.yml up -d
poetry run pytest -m mounting

Finally, to test the example projects, do

# Example projects spin up their own engines
docker-compose -f test/architecture/docker-compose.core.yml -f test/architecture/docker-compose.core.yml down -v
poetry run pytest -m example

All of these tests run in CI.

Metadata

Release files for splitgraph 0.3.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splitgraph 0.3.12
File Size Uploaded
splitgraph-0.3.12.tar.gz 319.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for splitgraph 0.3.12
File Interpreter ABI Platform
splitgraph-0.3.12-py3-none-any.whl Python 3 none any Details

Total release size: 697.3 kB

Release files / splitgraph-0.3.12.tar.gz

Download URL splitgraph-0.3.12.tar.gz
Size 319.8 kB
Tags Source
SHA-256 checksum
How to use checksums
76a4476002b5ac5a2b9fba36b6fcffd85b878bcc25f5aae411387e04a5532459
BLAKE2b-256 checksum
How to use checksums
dd617d6cf822edb39d2426f6f185c7fc4de0ad4b80e0da3e5f50d94952795c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.4 Linux/5.15.0-1013-gcp

Release files / splitgraph-0.3.12-py3-none-any.whl

Download URL splitgraph-0.3.12-py3-none-any.whl
Size 377.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c6fd816eeca13232c6d73f6bac3597871f39fd086a63560608148519bb89346
BLAKE2b-256 checksum
How to use checksums
b5729976ef687a7299cf17741106049f0de4bc689f6ec18a94faede54e57c64a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.4 Linux/5.15.0-1013-gcp

Release history Release notifications | RSS feed

This release

0.3.12 This release

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.13

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page