Skip to content

Commit

Permalink
fix: bump version to 3.0.0-alpha.0 and fix compatibility checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Sep 1, 2023
1 parent f59e336 commit 2bd1fa6
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 31 deletions.
9 changes: 6 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages_rs/nextclade-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nextclade-cli"
version = "2.14.0"
version = "3.0.0-alpha.0"
description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. CLI module."
repository = "https://github.com/nextstrain/nextclade"
documentation = "https://docs.nextstrain.org/projects/nextclade/en/stable/"
Expand Down Expand Up @@ -34,7 +34,7 @@ rayon = "=1.7.0"
regex = "=1.8.4"
reqwest = { version = "=0.11.18", default-features = false, features = ["blocking", "deflate", "gzip", "brotli", "socks", "rustls-tls"] }
schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap1"] }
semver = "=1.0.17"
semver = { version = "=1.0.17", features = ["serde"] }
serde = { version = "=1.0.164", features = ["derive"] }
serde_json = { version = "=1.0.99", features = ["preserve_order", "indexmap", "unbounded_depth"] }
strum = "=0.25.0"
Expand Down
9 changes: 4 additions & 5 deletions packages_rs/nextclade-cli/src/cli/nextclade_dataset_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use eyre::{Report, WrapErr};
use itertools::Itertools;
use log::{warn, LevelFilter};
use nextclade::io::dataset::{Dataset, DatasetsIndexJson};
use nextclade::utils::info::{this_package_version, this_package_version_str};
use nextclade::utils::string::find_similar_strings;
use nextclade::{getenv, make_error, make_internal_error};

const THIS_VERSION: &str = getenv!("CARGO_PKG_VERSION");
use nextclade::{make_error, make_internal_error};

pub struct DatasetHttpGetParams<'s> {
pub name: &'s str,
Expand Down Expand Up @@ -93,12 +92,12 @@ pub fn dataset_http_get(http: &mut HttpClient, name: impl AsRef<str>, tag: &Opti
}
}?;

if !dataset.is_cli_compatible(THIS_VERSION) {
if !dataset.is_cli_compatible(&this_package_version()) {
warn!(
"The requested dataset '{}' with version tag '{}' is not compatible with this version of Nextclade ({}). This may cause errors and unexpected results. Please try to upgrade your Nextclade version and/or report this to dataset authors.",
dataset.path,
dataset.tag(),
THIS_VERSION
this_package_version_str()
);
}

Expand Down
7 changes: 3 additions & 4 deletions packages_rs/nextclade-cli/src/cli/nextclade_dataset_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use itertools::Itertools;
use log::LevelFilter;
use nextclade::io::dataset::{Dataset, DatasetsIndexJson};
use nextclade::io::json::{json_stringify, JsonPretty};
use nextclade::{getenv, make_error};

const THIS_VERSION: &str = getenv!("CARGO_PKG_VERSION");
use nextclade::make_error;
use nextclade::utils::info::this_package_version;

pub fn nextclade_dataset_list(
NextcladeDatasetListArgs {
Expand Down Expand Up @@ -50,7 +49,7 @@ pub fn nextclade_dataset_list(
if let Some(tag) = tag.as_ref() {
dataset.is_tag(tag)
} else {
let is_compatible = include_incompatible || dataset.is_cli_compatible(THIS_VERSION);
let is_compatible = include_incompatible || dataset.is_cli_compatible(&this_package_version());
let is_not_deprecated = include_deprecated || !dataset.is_deprecated();
let is_not_experimental = include_experimental || !dataset.is_experimental();
let is_not_community = include_community || !dataset.is_community();
Expand Down
5 changes: 3 additions & 2 deletions packages_rs/nextclade-cli/src/io/http_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use clap::{Parser, ValueHint};
use eyre::Report;
use log::info;
use nextclade::{getenv, make_internal_error};
use nextclade::make_internal_error;
use nextclade::utils::info::{this_package_name, this_package_version_str};
use reqwest::blocking::Client;
use reqwest::{Method, Proxy};
use std::str::FromStr;
Expand Down Expand Up @@ -57,7 +58,7 @@ impl HttpClient {
client_builder
};

let user_agent = format!("{} {}", getenv!("CARGO_PKG_NAME"), getenv!("CARGO_PKG_VERSION"));
let user_agent = format!("{} {}", this_package_name(), this_package_version_str());

let client = client_builder
.connection_verbose(verbose)
Expand Down
2 changes: 1 addition & 1 deletion packages_rs/nextclade-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nextclade-web"
version = "2.14.0"
version = "3.0.0-alpha.0"
description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. WebAssembly module."
edition = "2021"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages_rs/nextclade-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nextstrain/nextclade-web",
"version": "2.14.1",
"version": "3.0.0-alpha.0",
"description": "Clade assignment, mutation calling, and sequence quality checks",
"homepage": "https://clades.nextstrain.org",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages_rs/nextclade-web/src/io/fetchDatasetsIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function isEnabled(dataset: Dataset) {

export function isCompatible(dataset: Dataset): boolean {
const minVersion = dataset.version?.compatibility?.web ?? thisVersion
return semver.gte(thisVersion, minVersion) && semver.lte(thisVersion, minVersion)
return semver.gte(thisVersion, minVersion)
}

export function isLatest(dataset: Dataset): boolean {
Expand Down
4 changes: 2 additions & 2 deletions packages_rs/nextclade/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nextclade"
version = "2.14.0"
version = "3.0.0-alpha.0"
description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. Library module."
repository = "https://github.com/nextstrain/nextclade"
documentation = "https://docs.nextstrain.org/projects/nextclade/en/stable/"
Expand Down Expand Up @@ -49,7 +49,7 @@ pretty_assertions = "=1.3.0"
rayon = "=1.7.0"
regex = "=1.8.4"
schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap"] }
semver = "=1.0.17"
semver = { version = "=1.0.17", features = ["serde"] }
serde = { version = "=1.0.164", features = ["derive"] }
serde_json = { version = "=1.0.99", features = ["preserve_order", "indexmap", "unbounded_depth"] }
serde_repr = "=0.1.12"
Expand Down
8 changes: 8 additions & 0 deletions packages_rs/nextclade/src/analyze/virus_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::run::params_general::NextcladeGeneralParamsOptional;
use crate::tree::params::TreeBuilderParamsOptional;
use crate::utils::boolean::{bool_false, bool_true};
use eyre::{Report, WrapErr};
use semver::Version;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::Path;
Expand Down Expand Up @@ -199,4 +200,11 @@ impl VirusProperties {

json_parse::<VirusProperties>(s).wrap_err("When parsing pathogen.json file")
}

pub fn is_cli_compatible(&self, current_cli_version: &Version) -> bool {
self
.compatibility
.as_ref()
.map_or(true, |compat| compat.is_cli_compatible(current_cli_version))
}
}
16 changes: 11 additions & 5 deletions packages_rs/nextclade/src/io/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::o;
use eyre::Report;
use itertools::Itertools;
use schemars::JsonSchema;
use semver::Version;
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -96,7 +97,7 @@ impl Dataset {
[&self.root_path(), filename.as_ref()].iter().join("/")
}

pub fn is_cli_compatible(&self, cli_version: impl AsRef<str>) -> bool {
pub fn is_cli_compatible(&self, cli_version: &Version) -> bool {
self
.version
.compatibility
Expand Down Expand Up @@ -191,15 +192,20 @@ impl Default for DatasetVersion {
#[serde(rename_all = "camelCase")]
pub struct DatasetCompatibility {
#[serde(default, skip_serializing_if = "Option::is_none")]
cli: Option<String>,
#[schemars(with = "String")]
pub cli: Option<Version>,

#[serde(default, skip_serializing_if = "Option::is_none")]
web: Option<String>,
#[schemars(with = "String")]
pub web: Option<Version>,
}

impl DatasetCompatibility {
pub fn is_cli_compatible(&self, cli_version: impl AsRef<str>) -> bool {
self.cli.as_ref().map_or(true, |cli| cli_version.as_ref() >= cli)
pub fn is_cli_compatible(&self, cli_version: &Version) -> bool {
self
.cli
.as_ref()
.map_or(true, |min_cli_version| cli_version >= min_cli_version)
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages_rs/nextclade/src/io/results_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::utils::datetime::date_iso_now;
use eyre::Report;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use crate::utils::info::this_package_version_str;

#[derive(Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "camelCase")]
Expand All @@ -33,11 +34,9 @@ pub struct ResultsJson {

impl ResultsJson {
pub fn new(clade_node_attrs: &[CladeNodeAttrKeyDesc], phenotype_attr_keys: &[PhenotypeAttrDesc]) -> Self {
const VERSION: &str = env!("CARGO_PKG_VERSION");

Self {
schema_version: "1.0.0".to_owned(),
nextclade_algo_version: VERSION.to_owned(),
schema_version: "3.0.0".to_owned(),
nextclade_algo_version: this_package_version_str().to_owned(),
nextclade_web_version: None,
created_at: date_iso_now(),
clade_node_attr_keys: clade_node_attrs.to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion packages_rs/nextclade/src/utils/getenv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! getenv {
($arg:tt) => {{
match core::option_env!($arg) {
Expand Down
26 changes: 26 additions & 0 deletions packages_rs/nextclade/src/utils/info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use lazy_static::lazy_static;
use semver::Version;

pub fn this_package_name() -> &'static str {
lazy_static! {
pub static ref PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
}
&PKG_NAME
}

pub fn this_package_version() -> &'static Version {
lazy_static! {
pub static ref VERSION: Version = Version::parse(env!("CARGO_PKG_VERSION")).expect(
"Unable to parse env var `CARGO_PKG_VERSION` in semantic version format. \
In most cases it comes from `version` field in `Cargo.toml` file."
);
}
&VERSION
}

pub fn this_package_version_str() -> &'static str {
lazy_static! {
pub static ref VERSION_STR: String = this_package_version().to_string();
}
&VERSION_STR
}
1 change: 1 addition & 0 deletions packages_rs/nextclade/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod datetime;
pub mod error;
pub mod getenv;
pub mod global_init;
pub mod info;
pub mod num;
pub mod option;
pub mod string;
Expand Down

1 comment on commit 2bd1fa6

@vercel
Copy link

@vercel vercel bot commented on 2bd1fa6 Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextclade – ./

nextclade-nextstrain.vercel.app
nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app

Please sign in to comment.