CLI tool for InfraMind CI/CD optimization engine
Project description
InfraMind CLI
Command-line tool for easy integration with InfraMind CI/CD optimization engine.
Installation
# Install from PyPI (once published)
pip install InfraMind
# Or install from source
cd cli
pip install -e .
Quick Start
# Set your InfraMind API URL (optional, defaults to localhost)
export INFRAMIND_URL=http://inframind.example.com:8081
export INFRAMIND_API_KEY=your-api-key
# Get optimization suggestions
inframind optimize --repo myorg/myrepo --branch main
# Report build results
inframind report --repo myorg/myrepo --branch main \
--duration 180 --status success --cpu 8 --memory 16384
Commands
optimize
Get optimization suggestions for your build.
inframind optimize --repo REPO --branch BRANCH [OPTIONS]
Options:
--repo TEXT Repository name (required)
--branch TEXT Branch name (default: main)
--build-type TEXT Build type (default: release)
--previous-duration INT Previous build duration in seconds
--format [human|json|env|shell] Output format (default: human)
Output formats:
human- Human-readable outputjson- JSON output for programmatic useenv- Export statements for shell evaluationshell- Variable assignments for sourcing
Examples:
# Human-readable output
inframind optimize --repo myorg/myrepo --branch main
# JSON output
inframind optimize --repo myorg/myrepo --branch main --format json
# Use in shell scripts
eval $(inframind optimize --repo myorg/myrepo --branch main --format env)
echo "Using $INFRAMIND_CPU CPUs"
# Source variables
source <(inframind optimize --repo myorg/myrepo --branch main --format shell)
report
Report build results back to InfraMind for ML training.
inframind report --repo REPO --branch BRANCH --duration SECONDS --status STATUS [OPTIONS]
Options:
--repo TEXT Repository name (required)
--branch TEXT Branch name (default: main)
--duration INT Build duration in seconds (required)
--status [success|failure] Build status (required)
--cpu INT CPU cores used
--memory INT Memory used in MB
--format [human|json] Output format (default: human)
Example:
inframind report --repo myorg/myrepo --branch main \
--duration 245 --status success --cpu 8 --memory 16384
health
Check InfraMind API health status.
inframind health [OPTIONS]
Options:
--format [human|json] Output format (default: human)
config
Manage CLI configuration (stores settings in ~/.inframind/config).
inframind config [OPTIONS]
Options:
--url TEXT Set API URL
--api-key TEXT Set API key
Example:
# Set configuration
inframind config --url http://inframind.example.com:8081 --api-key YOUR_KEY
# View current configuration
inframind config
Environment Variables
INFRAMIND_URL- API base URL (default:http://localhost:8081)INFRAMIND_API_KEY- API authentication key
Integration Examples
Jenkins Pipeline
pipeline {
stages {
stage('Optimize') {
steps {
script {
sh 'pip install InfraMind'
env.OPTS = sh(
script: "inframind optimize --repo ${env.GIT_URL} --branch ${env.BRANCH_NAME} --format shell",
returnStdout: true
).trim()
sh "source <(echo '${env.OPTS}')"
}
}
}
stage('Build') {
steps {
sh 'make build -j${INFRAMIND_CPU}'
}
}
post {
always {
sh """
inframind report --repo ${env.GIT_URL} --branch ${env.BRANCH_NAME} \
--duration \$BUILD_DURATION --status \$BUILD_STATUS
"""
}
}
}
}
GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install InfraMind CLI
run: pip install InfraMind
- name: Get Optimization Suggestions
id: optimize
env:
INFRAMIND_URL: ${{ secrets.INFRAMIND_URL }}
INFRAMIND_API_KEY: ${{ secrets.INFRAMIND_API_KEY }}
run: |
inframind optimize --repo ${{ github.repository }} --branch ${{ github.ref_name }} --format env >> $GITHUB_ENV
- name: Build
run: make build -j${INFRAMIND_CPU}
- name: Report Results
if: always()
env:
INFRAMIND_URL: ${{ secrets.INFRAMIND_URL }}
INFRAMIND_API_KEY: ${{ secrets.INFRAMIND_API_KEY }}
run: |
inframind report --repo ${{ github.repository }} --branch ${{ github.ref_name }} \
--duration ${{ job.duration }} --status ${{ job.status }}
GitLab CI
build:
stage: build
before_script:
- pip install InfraMind
- inframind optimize --repo ${CI_PROJECT_PATH} --branch ${CI_COMMIT_BRANCH} --format env > opts.env
- source opts.env
script:
- make build -j${INFRAMIND_CPU}
after_script:
- |
inframind report --repo ${CI_PROJECT_PATH} --branch ${CI_COMMIT_BRANCH} \
--duration ${CI_JOB_DURATION} --status ${CI_JOB_STATUS}
Shell Script
#!/bin/bash
# Get optimization suggestions
eval $(inframind optimize --repo myorg/myrepo --branch main --format env)
# Use the suggestions
echo "Building with $INFRAMIND_CPU CPUs and ${INFRAMIND_MEMORY}MB memory"
START_TIME=$(date +%s)
# Run your build
make build -j${INFRAMIND_CPU}
BUILD_STATUS=$?
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
# Report results
if [ $BUILD_STATUS -eq 0 ]; then
STATUS="success"
else
STATUS="failure"
fi
inframind report --repo myorg/myrepo --branch main \
--duration $DURATION --status $STATUS \
--cpu $INFRAMIND_CPU --memory $INFRAMIND_MEMORY
Development
# Install in development mode
cd cli
pip install -e .
# Run directly
python inframind.py optimize --repo test/repo --branch main
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inframind-2.1.1.tar.gz.
File metadata
- Download URL: inframind-2.1.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fa7c6144b86c449cc4f29a794893366f528b5e61b92b0da8241b98012fac15b
|
|
| MD5 |
8d210859cd72820ec1f3f3d1eceeefa4
|
|
| BLAKE2b-256 |
8c0fbb575d716cd21901c14cd23447590ad68affd5cc52f743614be19b006290
|
Provenance
The following attestation bundles were made for inframind-2.1.1.tar.gz:
Publisher:
release.yml on IdanG7/InfraMind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inframind-2.1.1.tar.gz -
Subject digest:
9fa7c6144b86c449cc4f29a794893366f528b5e61b92b0da8241b98012fac15b - Sigstore transparency entry: 685980863
- Sigstore integration time:
-
Permalink:
IdanG7/InfraMind@5cd89e7ba47e784841944bad10e232e93bea0a94 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/IdanG7
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cd89e7ba47e784841944bad10e232e93bea0a94 -
Trigger Event:
push
-
Statement type:
File details
Details for the file inframind-2.1.1-py3-none-any.whl.
File metadata
- Download URL: inframind-2.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25b1d7551b8f62b3fa2fceedbf241d7067c546b16202baed88bb39af7fcb64a
|
|
| MD5 |
4e047f6dc040ceb86695656372f6a795
|
|
| BLAKE2b-256 |
448b4719684a97801d1da30018209f6458f492bb80ecb1af62e7f167d15ff264
|
Provenance
The following attestation bundles were made for inframind-2.1.1-py3-none-any.whl:
Publisher:
release.yml on IdanG7/InfraMind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inframind-2.1.1-py3-none-any.whl -
Subject digest:
b25b1d7551b8f62b3fa2fceedbf241d7067c546b16202baed88bb39af7fcb64a - Sigstore transparency entry: 685980869
- Sigstore integration time:
-
Permalink:
IdanG7/InfraMind@5cd89e7ba47e784841944bad10e232e93bea0a94 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/IdanG7
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cd89e7ba47e784841944bad10e232e93bea0a94 -
Trigger Event:
push
-
Statement type: