Skip to content
Merged
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MinKNOW API Rust Client

*This is currently an early implementation and should not be used in production settings. This is NOT an official ONT project.*

A rust implementation of the minknow_api client for interacting with MinKNOW. More information on MinKNOW and minknow_api client, see [the minknow_api python client repository](https://github.com/nanoporetech/minknow_api).

## Contributing

Prequisites:

* Rust
* Cargo
* [MinKNOW](https://community.nanoporetech.com/docs/prepare/library_prep_protocols/Guppy-protocol/v/gpb_2003_v1_revan_14dec2018/guppy-for-macos) >=22.10.7 installed and running locally

End to end tests associated with the `minknow-api-rust` client currently interact directly with a running minknow instance to create simulated devices. The following setup must be performed prior to running tests:

1. Create a developer API token by opening the MinKNOW desktop application and navigating to 'Host Settings' -> 'API Access Tokens'.
1. An environment variable must reference this token, run `export MINKNOW_API_TEST_TOKEN={created_token}`
1. An environment variable must reference the self-signed certificate provided with the MinKNOW installation (for example, on MacOS run `export MIKNOW_TRUSTED_CA="/Applications/MinKNOW.app/Contents/Resources/conf/rpc-certs/ca.crt"`)

Once above prerequisites tests can be run with `cargo test --tests`.
24 changes: 20 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! A Rust implementation of the minknow_api client that supports communicating
//! with a MinKNOW server.
//!
//! For more information on MinKNOW and minknow_api clients, see [the minknow_api
//! python client repository].

use hyper::{
client::{HttpConnector, ResponseFuture},
header::HeaderValue,
Expand Down Expand Up @@ -58,7 +64,7 @@ pub mod minknow_api {
}
}

// A flow cell position
// A flow cell position.
//
// You should not normally construct this directly, but instead call
// `Manager.flow_cell_positions`. The constructor arguments may change between minor
Expand Down Expand Up @@ -303,6 +309,7 @@ impl Manager {
self.reset_positions(vec![position], force).await
}

// Reset flow cell positions.
async fn reset_positions(
&self,
positions: Vec<String>,
Expand All @@ -329,6 +336,9 @@ impl Manager {
Ok(response)
}

// Create a new developer api token, which expires at [expiry]
//
// Cannot be invoked when using a developer token as authorisation method.
async fn create_developer_api_token(
&self,
name: String
Expand All @@ -354,6 +364,7 @@ impl Manager {
Ok(response)
}

// Revoke an existing developer API token.
async fn revoke_developer_api_token(
&self,
id: String
Expand All @@ -378,6 +389,7 @@ impl Manager {
Ok(response)
}

// List existing developer API tokens.
async fn list_developer_api_tokens(
&self
) -> Result<minknow_api::manager::ListDeveloperApiTokensResponse, Status> {
Expand All @@ -399,6 +411,7 @@ impl Manager {
Ok(response)
}

// List available protocols for the given experiment type.
async fn find_protocols(
&self,
experiment_type: minknow_api::manager::ExperimentType
Expand Down Expand Up @@ -449,7 +462,8 @@ mod tests {
9502
).await;

manager.channel.set_token("5bd16355-3e52-4be0-8462-23eda1fb3c06".to_string());
let test_base_token = env::var("MINKNOW_API_TEST_TOKEN").ok().unwrap();
manager.channel.set_token(test_base_token);

let response = manager.create_developer_api_token(
"test_simulated_end_to_end".to_string()
Expand Down Expand Up @@ -494,7 +508,8 @@ mod tests {
9502
).await;

manager.channel.set_token("5bd16355-3e52-4be0-8462-23eda1fb3c06".to_string());
let test_base_token = env::var("MINKNOW_API_TEST_TOKEN").ok().unwrap();
manager.channel.set_token(test_base_token);

let response = manager.create_developer_api_token(
"test_developer_api_token_management".to_string()
Expand All @@ -519,7 +534,8 @@ mod tests {
9502
).await;

manager.channel.set_token("5bd16355-3e52-4be0-8462-23eda1fb3c06".to_string());
let test_base_token = env::var("MINKNOW_API_TEST_TOKEN").ok().unwrap();
manager.channel.set_token(test_base_token);

let response = manager.find_protocols(
minknow_api::manager::ExperimentType::Sequencing
Expand Down