From fd63ecbd1a68b90f5a89247e2d2d86d2c4365f29 Mon Sep 17 00:00:00 2001 From: brotoskyj Date: Mon, 20 Oct 2025 16:52:08 -0400 Subject: [PATCH] Redid build.sh and removed files --- .gitignore | 2 ++ Cargo.lock | 10 ++++++++++ Cargo.toml | 2 +- airlock_libs.pyi | 37 +++++++++++++++++++++++++++++++++++++ build.sh | 5 ----- pythontest.py | 3 --- src/services.rs | 5 +++-- 7 files changed, 53 insertions(+), 11 deletions(-) delete mode 100644 build.sh delete mode 100644 pythontest.py diff --git a/.gitignore b/.gitignore index ea8c4bf..84ed743 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +build.sh +pythontest.py \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 7026315..781f38e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -719,6 +719,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc1989dbf2b60852e0782c7487ebf0b4c7f43161ffe820849b56cf05f945cee1" dependencies = [ + "python3-dll-a", "target-lexicon", ] @@ -757,6 +758,15 @@ dependencies = [ "syn", ] +[[package]] +name = "python3-dll-a" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d381ef313ae70b4da5f95f8a4de773c6aa5cd28f73adec4b4a31df70b66780d8" +dependencies = [ + "cc", +] + [[package]] name = "quote" version = "1.0.41" diff --git a/Cargo.toml b/Cargo.toml index dd657b2..ac01ddc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.27.0", features = ["extension-module"] } +pyo3 = { version = "0.27.0", features = ["extension-module", "generate-import-lib"] } reqwest = "0.12.24" serde = "1.0.228" diff --git a/airlock_libs.pyi b/airlock_libs.pyi index 045e768..35b8ad9 100644 --- a/airlock_libs.pyi +++ b/airlock_libs.pyi @@ -1,4 +1,41 @@ from typing import Dict, List, Optional +class AirlockAPIWrapper: + """ + A wrapper class for interacting with the Airlock API. + Provides methods for managing agents, policies, hashes, OTPs, and execution history. + """ + + def __init__(self, base_url: str, api_key: str): + """ + Initialize the API wrapper. + + Parameters: + - base_url (str): Base URL of the Airlock API. + - api_key (str): API key for authentication. + """ + self.base_url = base_url.rstrip("/") + self.api_key = api_key + self.headers = {"X-APIKey": self.api_key} + def pull_policy_exec_histories(self, type: List[str], checkpoint: str, policy: List[str]) -> str: """Retrieve execution history logs.""" + +def api(AirlockAPIWrapper): + """ + An implementation of the python AirlockAPIWrapper class to pass Python data into Rust + + Parameters + ---------- + base_url : str + (Required) Base URL of the Airlock API, this should be in your .env file. + api_key : str + (Required) API Key for your profile in airlock, this should be in your credential manager. + headers : {"X-APIKey": self.api_key} + + ```def __init__(self, base_url: str, api_key: str): + self.base_url = base_ur.rstrip("/") + self.api_key = api_key + self.headers = {"X-APIKey": self.api_key} + ``` + """ \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index 3fc3d15..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -cargo clean -maturin build -python3 -m pip uninstall airlock_libs --break-system-packages -python3 -m pip install target/wheels/airlock_libs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl --break-system-packages \ No newline at end of file diff --git a/pythontest.py b/pythontest.py deleted file mode 100644 index d6f5e4c..0000000 --- a/pythontest.py +++ /dev/null @@ -1,3 +0,0 @@ -import airlock_libs - -airlock_libs.pull_policy_exec_histories() \ No newline at end of file diff --git a/src/services.rs b/src/services.rs index 9bc57c5..3de476a 100644 --- a/src/services.rs +++ b/src/services.rs @@ -6,6 +6,7 @@ pub fn pull_policy_exec_histories() { } #[pyfunction] -pub fn api(x: String) { - println!("{}", x); +pub fn api(py: Python<'_>, x: Py) { + let base_url: String = x.getattr(py, "base_url").unwrap().to_string(); + println!("{}", base_url); } \ No newline at end of file