Skip to content

Commit

Permalink
Ahnlich CLI for interacting with AI and DB Server (#118)
Browse files Browse the repository at this point in the history
* Entry point into ahnlich cli

* create pool connection based on agent and WIP: add validate connection

* Fix error in validate connection

* match default port based on agent

* Connect db to cli

* Some updates on the Ahnlich cli

* Add ahnlich cli as part of the releases for docker images and github actions

* temp pin cargozig build version

* Connect ai dls to cli

* Add cargo.lock to git

* pin blake3

* pin zig to last working release version

* use zig 0.13.0

* Deploy ahnlich-cli as independent entity
  • Loading branch information
Iamdavidonuh authored Sep 30, 2024
1 parent 61c9dc8 commit c52a4d7
Show file tree
Hide file tree
Showing 18 changed files with 3,372 additions and 34 deletions.
54 changes: 31 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
name: Build Binaries
runs-on: ubuntu-latest
outputs:
bin_name: ${{ steps.get_binary_version.outputs.BIN_NAME }}
bin_suffix: ${{ steps.get_binary_version.outputs.BIN_SUFFIX }}
bin_name: ${{ steps.get_binary_type.outputs.BIN_NAME }}
bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }}
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Get Binary Version"
id: get_binary_version
- name: "Get Binary Type"
id: get_binary_type
run: |
cd ${{github.workspace}}
echo ${{ github.event.release.tag_name }}
Expand All @@ -36,41 +36,47 @@ jobs:
toolchain: 1.78.0

- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: Build Linux Release for ${{ steps.get_binary_version.outputs.BIN_NAME }}
- name: Build Linux Release for ${{ steps.get_binary_type.outputs.BIN_NAME }}
working-directory: ./ahnlich
run: |
cargo build --release --bin ${{ steps.get_binary_version.outputs.BIN_NAME }}
tar -cvzf linux-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz -C target/release ${{ steps.get_binary_version.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} linux-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz
cargo build --release --bin ${{ steps.get_binary_type.outputs.BIN_NAME }}
tar -cvzf linux-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/release ${{ steps.get_binary_type.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} linux-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash

- name: Setup Cargo ZigBuild
working-directory: ./ahnlich
run: |
cargo install --locked cargo-zigbuild
cargo install --locked cargo-zigbuild --version 0.19.1
- name: Build Aarch64 Darwin Release for ${{ steps.get_binary_version.outputs.BIN_NAME }}
- name: Build Aarch64 Darwin Release for ${{ steps.get_binary_type.outputs.BIN_NAME }}
working-directory: ./ahnlich
run: |
rustup target add aarch64-apple-darwin
cargo zigbuild --release --target aarch64-apple-darwin --bin ${{ steps.get_binary_version.outputs.BIN_NAME }}
tar -cvzf aarch64-darwin-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz -C target/aarch64-apple-darwin/release ${{ steps.get_binary_version.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} aarch64-darwin-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz
cargo zigbuild --release --target aarch64-apple-darwin --bin ${{ steps.get_binary_type.outputs.BIN_NAME }}
tar -cvzf aarch64-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/aarch64-apple-darwin/release ${{ steps.get_binary_type.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} aarch64-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash

- name: Build x86_64 Apple Darwin Release for ${{ steps.get_binary_version.outputs.BIN_NAME }}
- name: Build x86_64 Apple Darwin Release for ${{ steps.get_binary_type.outputs.BIN_NAME }}
working-directory: ./ahnlich
run: |
rustup target add x86_64-apple-darwin
cargo zigbuild --release --target x86_64-apple-darwin --bin ${{ steps.get_binary_version.outputs.BIN_NAME }}
tar -cvzf x86_64-apple-darwin-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz -C target/x86_64-apple-darwin/release ${{ steps.get_binary_version.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} x86_64-apple-darwin-${{ steps.get_binary_version.outputs.BIN_NAME }}.tar.gz
cargo zigbuild --release --target x86_64-apple-darwin --bin ${{ steps.get_binary_type.outputs.BIN_NAME }}
tar -cvzf x86_64-apple-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/x86_64-apple-darwin/release ${{ steps.get_binary_type.outputs.BIN_NAME }}
gh release upload ${{github.event.release.tag_name}} x86_64-apple-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
Expand All @@ -80,20 +86,21 @@ jobs:
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Build Windows x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_version.outputs.BIN_NAME }}
- name: Build Windows x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_type.outputs.BIN_NAME }}
uses: houseabsolute/actions-rust-cross@v0
with:
working-directory: ./ahnlich
command: build
target: x86_64-pc-windows-gnu
args: "--locked --release --bin ${{ steps.get_binary_version.outputs.BIN_NAME }}"
args: "--locked --release --bin ${{ steps.get_binary_type.outputs.BIN_NAME }}"
strip: true

- name: Package and upload x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_version.outputs.BIN_NAME }}
- name: Package and upload x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_type.outputs.BIN_NAME }}
working-directory: ./ahnlich
run: |
cd target/x86_64-pc-windows-gnu/release/ && zip ../../../win-x86_64-gnu-${{ steps.get_binary_version.outputs.BIN_NAME }}.zip ${{ steps.get_binary_version.outputs.BIN_NAME }}.exe && cd ../../../
gh release upload ${{github.event.release.tag_name}} win-x86_64-gnu-${{ steps.get_binary_version.outputs.BIN_NAME }}.zip
cd target/x86_64-pc-windows-gnu/release/ && zip ../../../win-x86_64-gnu-${{ steps.get_binary_type.outputs.BIN_NAME }}.zip ${{ steps.get_binary_type.outputs.BIN_NAME }}.exe && cd ../../../
gh release upload ${{github.event.release.tag_name}} win-x86_64-gnu-${{ steps.get_binary_type.outputs.BIN_NAME }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
Expand All @@ -102,6 +109,7 @@ jobs:
needs: build_binaries_and_publish
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
if: ${{needs.build_binaries_and_publish.outputs.bin_name != 'ahnlich-cli'}}
permissions:
packages: write
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,42 @@ create_store(

## Usage

`ahnlich-db` and `ahnlich-ai` are packaged and released as [binaries](https://github.com/deven96/ahnlich/releases) for multiple platforms alongside [docker images](https://github.com/deven96?tab=packages&repo_name=ahnlich)
`ahnlich-db`, `ahnlich-ai` and `ahnlich-cli` are packaged and released as [binaries](https://github.com/deven96/ahnlich/releases) for multiple platforms alongside [docker images](https://github.com/deven96?tab=packages&repo_name=ahnlich)

### Docker Images.

`Note`: Arguments and commands must be passed in quotes. E.G: `docker run <image_name> "ahnlich-db run --enable-tracing --port 8000"`
`Note`:
1. Arguments and commands must be passed in quotes. E.G: `docker run <image_name> "ahnlich-db run --enable-tracing --port 8000"`

2. The CLI comes packaged into the docker images.


### Ahnlich CLI.
Ahnlich ships our CLI that can be used to query either AI or DB binaries.

<p align="left"><img src="assets/cli-clear.gif" alt="ahnlich" height="auto"></p>

To run:
`ahnlich_cli ahnlich --agent .. --host .. --port ...`
where:
- Agent: Binary to connect to (ai or db)
- Host: defaults to `127.0.0.1`
- port: default is infered from the agent selected. (`AI = 1370`, `DB = 1369`)

#### Example Commands
- **DB**

- Create Store with dimension 2 and indexes author and country

`CREATESTORE test_store DIMENSION 2 PREDICATES (author, country)`
- Set In store
`SET (([1.0, 2.1], {name: Haks, category: dev}), ([3.1, 4.8], {name: Deven, category: dev})) in test_store`


#### Combining commands
CLI can process multiple commands at once as long as each command is delimited by `;`

`GETKEY ([1.0, 2.0], [3.0, 4.0]) IN test_store;CREATEPREDINDEX (name, category) in test_store`

## Development

Expand Down Expand Up @@ -79,3 +110,6 @@ The clients follow a similar process when deploying new releases.
[Example with python client](https://github.com/deven96/ahnlich/blob/main/sdk/ahnlich-client-py/README.md#deploy-to-artifactory).





Loading

0 comments on commit c52a4d7

Please sign in to comment.