Skip to content

Commit

Permalink
Merging
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Sep 16, 2024
2 parents 2d97a71 + d159a81 commit 6b4bf92
Show file tree
Hide file tree
Showing 44 changed files with 2,588 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
target/
debug/

Cargo.lock

openapitools.json
*.log
funnel-work-dir/
funnel/
lib/src/*/models
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ members = [

[workspace.package]
version = "0.1.0"
authors = ["Aarav Mehta <[email protected]> (Google Summer of Code Participant)", "Pavel Nikonorov <[email protected]> (Google Summer of Code Mentor; GENXT)", "ELIXIR Cloud & AAI <[email protected]> (ELIXIR Europe)"]
authors = ["Aarav Mehta <[email protected]>", "Pavel Nikonorov <[email protected]>", "ELIXIR Cloud & AAI <[email protected]> (ELIXIR Europe)"]
edition = "2021"
readme = "./README.md"
license-file = "LICENSE.txt"
license-file = "LICENSE"
repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk.git"
80 changes: 74 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# A Generic SDK and CLI for GA4GH API services
# GA4GH SDK
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)

## Synopsis

A Generic SDK and CLI for GA4GH API services.

## Basic usage
TBA

## Installation
TBA

## Building

Expand All @@ -12,25 +23,82 @@ To build the project:
cargo build
```

## Running the tests
## Testing
There are 2 types of Tests: Unit tests and integration tests.

To run the unit tests, which are being tested with mock servers, you can simply run
```
cargo test
```

Before running the tests, you need to install Funnel, a task execution system that is compatible with the GA4GH TES API. Follow the instructions in the [Funnel Developer's Guide](https://ohsu-comp-bio.github.io/funnel/docs/development/developers/) to install Funnel.
To test the integration tests:
Before running the integration tests, you need to install Funnel, a task execution system that is compatible with the GA4GH TES API. Follow the instructions in the Funnel Developer's Guide to install Funnel: https://ohsu-comp-bio.github.io/funnel/docs/development/developers/. Note that the link may change over time, so refer to the official Funnel repository or website for the most up-to-date information.

Once you have installed Funnel, you can run the tests. This will automatically run Funnel as well:

```
bash ./run-tests.sh
```
or, you can run using cargo nextest using
or, you can run using:
```
cargo nextest run
```
For checking the unit converage, you can run:
For checking the unit coverage, you can run:
```
cargo llvm-cov nextest
```

To test the CI/CD workflow locally, install `act` and run the following command:
```
act -j build --container-architecture linux/amd64 -P ubuntu-latest=ubuntu:24.04 --reuse
```
# Note: The specified Ubuntu version (24.04) may change in the future.
# Please check for the latest version when running this command.
```

## Versioning
The project adopts the [semver] scheme for versioning.
Currently the software is in a pre-release stage, so changes to the API,
including breaking changes, may occur at any time without further notice.

## Contributing

This project is a community effort and lives off your contributions, be it in
the form of bug reports, feature requests, discussions, ideas, fixes, or other
code changes. Please read [these guidelines][docs-contributing] if you want to
contribute. And please mind the [code of conduct][docs-coc] for all
interactions with the community.

## License

This project is covered by the [Apache License 2.0](badge-url-license) also
[shipped with this repository][license].

## Contact
The project is maintained by [ELIXIR Cloud & AAI][elixir-cloud-aai], a Driver
Project of the [Global Alliance for Genomics and Health (GA4GH)][ga4gh], under
the umbrella of the [ELIXIR] [Compute Platform][elixir-compute].

To get in touch with us, please use one of the following routes:

- For filing bug reports, feature requests or other code-related issues, please
make use of the project's [issue tracker][issue-tracker].
- For private/personal issues, more involved communication, or if you would like
to join our team as a regular contributor, you can either join our
[chat board][badge-chat-url] or [email] the community leaders.


[![logo-elixir]][elixir] [![logo-elixir-cloud-aai]][elixir-cloud-aai]

[badge-chat-url]: https://join.slack.com/t/elixir-cloud/shared_invite/enQtNzA3NTQ5Mzg2NjQ3LTZjZGI1OGQ5ZTRiOTRkY2ExMGUxNmQyODAxMDdjM2EyZDQ1YWM0ZGFjOTJhNzg5NjE0YmJiZTZhZDVhOWE4MWM
[badge-license-url]: http://www.apache.org/licenses/LICENSE-2.0
[code-of-conduct]: https://elixir-cloud-aai.github.io/about/code-of-conduct/
[contributing]: https://elixir-cloud-aai.github.io/guides/guide-contributor/
[elixir]: https://elixir-europe.org/
[elixir-cloud-aai]: https://elixir-cloud.dcc.sib.swiss/
[elixir-compute]: https://elixir-europe.org/platforms/compute
[email]: mailto:[email protected]
[ga4gh]: https://ga4gh.org/
[license]: LICENSE
[logo-elixir]: ./images/logo-elixir.svg
[logo-elixir-cloud-aai]: ./images/logo-elixir-cloud-aai.svg
[semver]: https://semver.org/
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ serde_json = "^1.0"
tempfile = "3.2"
dirs = "5.0.1"
anyhow = "1.0.86"
url = "2.5.2"

[[bin]]
name = "cli"
Expand Down
46 changes: 27 additions & 19 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use clap::{arg, Command};
use ga4gh_sdk::configuration::Configuration;
use ga4gh_sdk::tes::model::ListTasksParams;
use ga4gh_sdk::transport::Transport;
use ga4gh_sdk::clients::tes::models::ListTasksParams;
use std::collections::HashMap;
use std::error::Error;
use ga4gh_sdk::tes::{Task, TES};
use ga4gh_sdk::tes::models::TesTask;
use ga4gh_sdk::test_utils::ensure_funnel_running;
use std::fs;
use std::path::Path;
use ga4gh_sdk::configuration::BasicAuth;
use ga4gh_sdk::clients::tes::models::TesTask;
use ga4gh_sdk::clients::tes::{Task, TES};
use ga4gh_sdk::utils::configuration::Configuration;
use ga4gh_sdk::utils::test_utils::ensure_funnel_running;
use ga4gh_sdk::utils::transport::Transport;
use ga4gh_sdk::utils::configuration::BasicAuth;
use std::fs::File;
use serde_json::Value;
use std::io::Read;
Expand Down Expand Up @@ -126,9 +126,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
let testask: TesTask = serde_json::from_str(&task_json)
.map_err(|e| format!("Failed to parse JSON: {}", e))?;
let mut config = load_configuration();
if config.base_path == "localhost" {
if config.base_path.as_str() == "localhost" {
let funnel_url = ensure_funnel_running().await;
config.set_base_path(&funnel_url);
let funnel_url = url::Url::parse(&funnel_url).expect("Invalid URL");
config.set_base_path(funnel_url);
}
match TES::new(&config).await {
Ok(tes) => {
Expand Down Expand Up @@ -166,9 +167,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
};
println!("parameters are: {:?}",parameters);
let mut config = load_configuration();
if config.base_path == "localhost" {
if config.base_path.as_str() == "localhost" {
let funnel_url = ensure_funnel_running().await;
config.set_base_path(&funnel_url);
let funnel_url = url::Url::parse(&funnel_url).expect("Invalid URL");
config.set_base_path(funnel_url);
}
match TES::new(&config).await {
Ok(tes) => {
Expand All @@ -186,9 +188,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
let view = sub.value_of("view").unwrap();

let mut config = load_configuration();
if config.base_path == "localhost" {
if config.base_path.as_str() == "localhost" {
let funnel_url = ensure_funnel_running().await;
config.set_base_path(&funnel_url);
let funnel_url = url::Url::parse(&funnel_url).expect("Invalid URL");
config.set_base_path(funnel_url);
}

match TES::new(&config).await {
Expand All @@ -206,9 +209,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
let id = sub.value_of("id").unwrap().to_string();

let mut config = load_configuration();
if config.base_path == "localhost" {
if config.base_path.as_str() == "localhost" {
let funnel_url = ensure_funnel_running().await;
config.set_base_path(&funnel_url);
let funnel_url = url::Url::parse(&funnel_url).expect("Invalid URL");
config.set_base_path(funnel_url);
}
let transport = Transport::new(&config);
let task = Task::new(id, transport);
Expand All @@ -226,9 +230,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
let id = sub.value_of("id").unwrap().to_string();

let mut config = load_configuration();
if config.base_path == "localhost" {
if config.base_path.as_str() == "localhost" {
let funnel_url = ensure_funnel_running().await;
config.set_base_path(&funnel_url);
let funnel_url = url::Url::parse(&funnel_url).expect("Invalid URL");
config.set_base_path(funnel_url);
}
let transport = Transport::new(&config);
let task = Task::new(id, transport);
Expand Down Expand Up @@ -275,8 +280,11 @@ fn read_configuration_from_file(file_path: &str) -> Result<Configuration, Box<dy
password: Some(auth["password"].as_str().unwrap_or_default().to_string()),
});
let oauth_access_token = json_value["oauth_access_token"].as_str().map(|s| s.to_string());

let config = Configuration::new(base_path, user_agent, basic_auth, oauth_access_token);
let base_path = url::Url::parse(&base_path).expect("Invalid URL");
let config = Configuration::new(base_path)
.with_user_agent(user_agent.expect("Invalid user agent"))
.with_basic_auth(basic_auth.expect("Invalid basic_auth"))
.with_oauth_access_token(oauth_access_token.expect("Invalid oauth access token"));
Ok(config)
}

Expand Down
112 changes: 112 additions & 0 deletions images/logo-elixir-cloud-aai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6b4bf92

Please sign in to comment.