Skip to content

Commit

Permalink
Add dataset name shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Dec 7, 2023
1 parent 2972451 commit 86e06c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages_rs/nextclade-cli/src/dataset/dataset_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ pub fn dataset_individual_files_load(
VirusProperties {
schema_version: "".to_owned(),
attributes: BTreeMap::default(),
shortcuts: vec![],
meta: DatasetMeta::default(),
files: DatasetFiles {
reference: "".to_owned(),
Expand Down
4 changes: 2 additions & 2 deletions packages_rs/nextclade-web/src/io/fetchDatasetsIndex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from 'axios'
import { get, head, mapValues, sortBy, sortedUniq } from 'lodash'
import { get, head, isNil, mapValues, sortBy, sortedUniq } from 'lodash'
import semver from 'semver'
import { takeFirstMaybe } from 'src/helpers/takeFirstMaybe'
import urljoin from 'url-join'
Expand Down Expand Up @@ -47,7 +47,7 @@ export function findDataset(datasets: Dataset[], name?: string, tag?: string) {
/** Find the datasets given name, ref and tag */
export function filterDatasets(datasets: Dataset[], name?: string, tag?: string) {
return datasets.filter((dataset) => {
let isMatch = dataset.path === name
let isMatch = !isNil(name) && (dataset.path === name || !!dataset.shortcuts?.includes(name))

if (tag) {
isMatch = isMatch && dataset.version?.tag === tag
Expand Down
3 changes: 3 additions & 0 deletions packages_rs/nextclade/src/analyze/virus_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub struct VirusProperties {
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub attributes: BTreeMap<String, AnyType>,

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub shortcuts: Vec<String>,

#[serde(default, skip_serializing_if = "DatasetMeta::is_default")]
pub meta: DatasetMeta,

Expand Down
3 changes: 3 additions & 0 deletions packages_rs/nextclade/src/io/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub struct DatasetCollection {
pub struct Dataset {
pub path: String,

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub shortcuts: Vec<String>,

#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub attributes: BTreeMap<String, AnyType>,

Expand Down

0 comments on commit 86e06c3

Please sign in to comment.