Skip to content

Commit faac3bc

Browse files
committed
Fix CI
1 parent e97a5a0 commit faac3bc

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

datafusion-cli/src/hf_store.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ impl ParsedHFUrl {
175175
/// Parse a http style HuggingFace URL into a ParsedHFUrl struct.
176176
/// The URL should be in the format `https://huggingface.co/<repo_type>/<repository>/resolve/<revision>/<path>`
177177
/// where `repo_type` is either `datasets` or `spaces`.
178-
///
179-
/// url: The HuggingFace URL to parse.
178+
///
179+
/// url: The HuggingFace URL to parse.
180180
fn parse_http_style(url: String) -> Result<Self> {
181181
let mut parsed_url = Self::default();
182182
let mut last_delim = 0;
@@ -212,22 +212,24 @@ impl ParsedHFUrl {
212212
return config_err!("Invalid HuggingFace URL: {}, please format as 'https://huggingface.co/<repo_type>/<repository>/resolve/<revision>/<path>'", url);
213213
}
214214

215-
parsed_url.repository = Some(url[start_delim..last_delim + next_slash.unwrap()].to_string());
215+
parsed_url.repository =
216+
Some(url[start_delim..last_delim + next_slash.unwrap()].to_string());
216217
last_delim += next_slash.unwrap();
217-
218+
218219
let next_resolve = url[last_delim..].find("resolve");
219220
if next_resolve.is_none() {
220221
return config_err!("Invalid HuggingFace URL: {}, please format as 'https://huggingface.co/<repo_type>/<repository>/resolve/<revision>/<path>'", url);
221222
}
222-
223+
223224
last_delim += next_resolve.unwrap() + "resolve".len();
224225

225226
let next_slash = url[last_delim + 1..].find('/');
226227
if next_slash.is_none() {
227228
return config_err!("Invalid HuggingFace URL: {}, please format as 'https://huggingface.co/<repo_type>/<repository>/resolve/<revision>/<path>'", url);
228229
}
229230

230-
parsed_url.revision = Some(url[last_delim + 1..last_delim + 1 + next_slash.unwrap()].to_string());
231+
parsed_url.revision =
232+
Some(url[last_delim + 1..last_delim + 1 + next_slash.unwrap()].to_string());
231233
last_delim += 1 + next_slash.unwrap();
232234

233235
// parse path.
@@ -572,15 +574,13 @@ impl ObjectStore for HFStore {
572574
&self,
573575
_prefix: Option<&Path>,
574576
) -> ObjectStoreResult<ListResult> {
575-
576577
Err(ObjectStoreError::NotImplemented)
577578
}
578579

579580
fn list(
580581
&self,
581582
prefix: Option<&Path>,
582583
) -> BoxStream<'_, ObjectStoreResult<ObjectMeta>> {
583-
584584
let Some(prefix) = prefix else {
585585
return futures::stream::once(async {
586586
Err(ObjectStoreError::Generic {
@@ -615,7 +615,6 @@ impl ObjectStore for HFStore {
615615
});
616616
};
617617

618-
619618
let Ok(tree_result) =
620619
serde_json::from_slice::<Vec<HFTreeEntry>>(bytes.to_byte_slice())
621620
else {
@@ -638,7 +637,9 @@ impl ObjectStore for HFStore {
638637
.into_iter()
639638
.map(|result| {
640639
result.and_then(|mut meta| {
641-
let Ok(location) = ParsedHFUrl::parse_http_style(meta.location.to_string()) else {
640+
let Ok(location) =
641+
ParsedHFUrl::parse_http_style(meta.location.to_string())
642+
else {
642643
return Err(ObjectStoreError::Generic {
643644
store: STORE,
644645
source: format!("Unable to parse location {}", meta.location)
@@ -714,28 +715,29 @@ mod tests {
714715
fn test_parse_hf_url_errors() {
715716
test_error(
716717
"datasets/datasets-examples/doc-formats-csv-1",
717-
"Invalid HuggingFace URL: hf://datasets/datasets-examples/doc-formats-csv-1, please format as 'hf://<repo_type>/<repository>[@revision]/<path>'",
718+
"Invalid HuggingFace URL: datasets/datasets-examples/doc-formats-csv-1, please format as 'hf://<repo_type>/<repository>[@revision]/<path>'",
718719
);
719720

720721
test_error(
721722
"datadicts/datasets-examples/doc-formats-csv-1/data.csv",
722-
"Invalid HuggingFace URL: hf://datadicts/datasets-examples/doc-formats-csv-1/data.csv, currently only 'datasets' or 'spaces' are supported",
723+
"Invalid HuggingFace URL: datadicts/datasets-examples/doc-formats-csv-1/data.csv, currently only 'datasets' or 'spaces' are supported",
723724
);
724725

725726
test_error(
726727
"datasets/datasets-examples/doc-formats-csv-1@~csv",
727-
"Invalid HuggingFace URL: hf://datasets/datasets-examples/doc-formats-csv-1@~csv, please format as 'hf://<repo_type>/<repository>[@revision]/<path>'",
728+
"Invalid HuggingFace URL: datasets/datasets-examples/doc-formats-csv-1@~csv, please format as 'hf://<repo_type>/<repository>[@revision]/<path>'",
728729
);
729730

730731
test_error(
731732
"datasets/datasets-examples/doc-formats-csv-1@~csv/",
732-
"Invalid HuggingFace URL: hf://datasets/datasets-examples/doc-formats-csv-1@~csv/, please specify a path",
733+
"Invalid HuggingFace URL: datasets/datasets-examples/doc-formats-csv-1@~csv/, please specify a path",
733734
);
734735
}
735736

736737
#[test]
737738
fn test_parse_http_url() {
738-
let url = "datasets/datasets-examples/doc-formats-csv-1/resolve/main/data.csv".to_string();
739+
let url = "datasets/datasets-examples/doc-formats-csv-1/resolve/main/data.csv"
740+
.to_string();
739741

740742
let parsed_url = ParsedHFUrl::parse_http_style(url).unwrap();
741743

@@ -748,7 +750,6 @@ mod tests {
748750
assert_eq!(parsed_url.path, Some("data.csv".to_string()));
749751
}
750752

751-
752753
#[test]
753754
fn test_file_path() {
754755
let url = "datasets/datasets-examples/doc-formats-csv-1/data.csv".to_string();

0 commit comments

Comments
 (0)