创建一个每个人都可以从数据开始为通用人工智能做出贡献的世界。
Oxen 的核心是一个用 Rust 编写的数据版本控制库。它的目标是快速、可靠且易于使用。它被设计为以多种方式使用,从简单的命令行工具到要同步的远程服务器,再到集成到其他生态系统(例如 python)中。
可以在此处找到 Oxen.ai 工具链的文档。
transformers
库的模型datasets
集库下载数据集Oxen 纯粹是用 Rust 编写的?您应该使用 rustup 安装 Rust 工具链:https://www.rust-lang.org/tools/install。
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
如果您是开发人员并且想要了解有关添加代码或整体架构的更多信息,请从这里开始。否则,将快速启动以确保一切正常。
cargo build
如果在 intel mac 上,您可能需要使用以下内容进行构建
$ rustup target install x86_64-apple-darwin
$ cargo build --target x86_64-apple-darwin
如果在 Windows 上,您可能需要将以下目录添加到“INCLUDE”环境变量中
"C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.29.30133include"
"C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.29.27023include"
"C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsLlvmlibclang12.0.0include"
这些是示例路径,并且会因机器而异。如果您通过 Microsoft Visual Studio 构建工具安装“C++ Clang tools for Windows”,则可以从 Visual Studio 安装中的“BuildToolsVCTools”下找到这些目录
您可以使用模具链接器来加速构建(MIT 许可的 macOS 版本已出售)。
使用以下说明安装已售出的货物并配置货物以将其用于构建 Oxen:
git clone --depth=1 --single-branch https://github.com/bluewhalesystems/sold.git
mkdir sold/build
cd sold/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ ..
cmake --build . -j $(nproc)
sudo cmake --install .
然后在 Oxen 存储库根目录中创建.cargo/config.toml
并包含以下内容:
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/ld64.mold"]
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/ld64.mold"]
对于带有 Apple Silicon 的 macOS ,您可以使用 lld 链接器。
brew install llvm
然后使用以下内容在 Oxen 存储库根目录中创建.cargo/config.toml
:
[target.aarch64-apple-darwin]
rustflags = [ "-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld", ]
要从命令行运行 Oxen,请将Oxen/target/debug
目录添加到“PATH”环境变量中
export PATH="$PATH:/path/to/Oxen/target/debug"
在 Windows 上,您可以使用
$env:PATH += ";/path/to/Oxen/target/debug"
初始化一个新的存储库或克隆现有的存储库
oxen init
oxen clone https://hub.oxen.ai/namespace/repository
这将在当前目录中创建.oxen
目录并允许您运行 Oxen CLI 命令
oxen status
oxen add images/
oxen commit -m "added images"
oxen push origin main
要运行本地 Oxen 服务器,请生成配置文件和令牌来对用户进行身份验证
./target/debug/oxen-server add-user --email [email protected] --name Ox --output user_config.toml
将配置复制到默认位置
mkdir ~/.oxen
mv user_config.toml ~/.oxen/user_config.toml
cp ~/.oxen/user_config.toml data/test/config/user_config.toml
设置要将数据同步到的位置。默认同步目录是./data/
要更改它,请将 SYNC_DIR 环境变量设置为路径。
export SYNC_DIR=/path/to/sync/dir
您还可以在 /src/server 目录中创建一个 .env.local 文件,其中包含 SYNC_DIR 变量,以避免每次运行服务器时都进行设置。
运行服务器
./target/debug/oxen-server start
要通过实时重新加载运行服务器,请首先安装 Cargo-Watch
cargo install cargo-watch
在Windows上,您可能需要使用cargo-watch --locked
cargo install cargo-watch --locked
然后像这样运行服务器
cargo watch -- cargo run --bin oxen-server start
如果您安装了 Nix,则可以使用 flake 来构建和运行服务器。这将自动安装和配置 Linux 和 macOS 所需的构建工具链依赖项。
nix build .#oxen-server
nix build .#oxen-cli
nix build .#liboxen
nix run .#oxen-server -- start
nix run .#oxen-cli -- init
要在 Nix dev shell 中使用标准 Rust 工具链进行开发:
nix develop -c $SHELL
cargo build
cargo run --bin oxen-server start
cargo run --bin oxen start
该 flake 还提供了构建 OCI (Docker) 镜像的衍生版本,以及构建和运行oxen
和oxen-server
所需的最小依赖集。
nix build .#oci-oxen-server
nix build .#oci-oxen-cli
这将导出 OCI 图像并可以加载:
docker load -i result
通过执行以下设置步骤,确保您的用户已配置并且服务器正在默认端口和主机上运行:
# Configure a user
mkdir ./data/test/runs
./target/debug/oxen-server add-user --email [email protected] --name Ox --output user_config.toml
cp user_config.toml data/test/config/user_config.toml
# Start the oxen-server
./target/debug/oxen-server start
注意:测试会打开大量文件句柄,因此如果运行所有内容,请限制测试线程数。
在运行测试之前,您还可以增加系统允许 ulimit 打开的文件数:
ulimit -n 10240
cargo test -- --test-threads=$(nproc)
运行特定测试可以更快(在编译和运行时方面)。要运行特定的库测试:
cargo test --lib test_get_metadata_text_readme
运行特定的集成测试
cargo test --test test_rm test_rm_directory_restore_directory
使用所有调试输出运行并运行特定测试
env RUST_LOG=warn,liboxen=debug,integration_test=debug cargo test -- --nocapture test_command_push_clone_pull_push
要设置不同的测试主机,您可以设置OXEN_TEST_HOST
环境变量
env OXEN_TEST_HOST=0.0.0.0:4000 cargo test
远程存储库具有与本地存储库相同的内部结构,但所有数据都位于 .oxen 目录中,并且不会复制到“本地工作区”中。
服务器默认为 localhost 3000
set SERVER 0.0.0.0:3000
您可以从上面的配置文件(~/.oxen/user_config.toml)获取您的身份验证令牌
set TOKEN <YOUR_TOKEN>
curl -H "Authorization: Bearer $TOKEN" "http://$SERVER/api/repos"
curl -H "Authorization: Bearer $TOKEN" -X POST -d '{"name": "MyRepo"}' "http://$SERVER/api/repos"
创建泊坞窗图像
docker build -t oxen/server:0.6.0 .
在端口 3000 上运行容器,并将本地文件系统从主机上的 /var/oxen/data 挂载到容器中的 /var/oxen/data 。
docker run -d -v /var/oxen/data:/var/oxen/data -p 3000:3001 --name oxen oxen/server:0.6.0
或者使用 docker compose
docker-compose up -d reverse-proxy
docker-compose up -d --scale oxen=4 --no-recreate