Skip to content

Reproducible and automatically configure development environments #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.public
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GROK_MAGNET_LINK=magnet:?xt=urn:btih:5f96d43576e3d386c9ba65b883210a393b68210e&tr=https%3A%2F%2Facademictorrents.com%2Fannounce.php&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dotenv .env.public
dotenv_if_exists
use flake
layout python
3 changes: 3 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruff check ./
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: test
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.direnv/
/.venv/
checkpoints/*
!checkpoints/README.md
__pycache__/
14 changes: 14 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[private]
@default:
just --list --unsorted

# Run the sample prompt against the model
test:
python run.py

# Download the weights for the Grok model
download-weights:
transmission-cli \
--download-dir ./checkpoints \
$GROK_MAGNET_LINK
ln -s ./checkpoints/grok-1/ckpt-0 ./checkpoints/ckpt-0
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ pip install huggingface_hub[hf_transfer]
huggingface-cli download xai-org/grok-1 --repo-type model --include ckpt-0/* --local-dir checkpoints --local-dir-use-symlinks False
```

# Reproducible Environment

Those familiar with `nix` and `direnv` can use a reproducible development environment.

```sh
cd ~/src/grok-1
direnv allow .
just --list
just download-weights
just test
```

# License

The code and associated Grok-1 weights in this release are licensed under the
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python311;
in
{
devShells.default = pkgs.mkShell {

# build-time
nativeBuildInputs = with pkgs; [
bashInteractive
];

# run-time
buildInputs = (with pkgs; [
transmission
just
]) ++ (with python.pkgs; [
setuptools
wheel
venvShellHook
pkgs.ruff
]);

# python setup
src = null;
venvDir = ".venv";
postVenv = ''
unset SOURCE_DATE_EPOCH
'';
postShellHook = ''
unset SOURCE_DATE_EPOCH
unset LD_PRELOAD
PYTHONPATH=$PWD/$venvDir/${python.sitePackages}:$PYTHONPATH
pip install --require-virtualenv -r requirements.txt | grep -v 'already satisfied'
git config --local core.hooksPath .github/hooks
'';

};
}
);
}