Skip to content

Commit 232d080

Browse files
committed
Fix linter errors
1 parent 77379dc commit 232d080

7 files changed

Lines changed: 35 additions & 34 deletions

File tree

docs/CONFIGURATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Infera supports configuration via environment variables to customize its behavio
2525
```bash
2626
## Set to 5GB
2727
export INFERA_CACHE_SIZE_LIMIT=5368709120
28-
28+
2929
## Set to 500MB
3030
export INFERA_CACHE_SIZE_LIMIT=524288000
3131
```
@@ -96,10 +96,10 @@ Infera supports configuration via environment variables to customize its behavio
9696
```bash
9797
## Show all messages including debug
9898
export INFERA_LOG_LEVEL=DEBUG
99-
99+
100100
## Show only errors
101101
export INFERA_LOG_LEVEL=ERROR
102-
102+
103103
## Show informational messages and above
104104
export INFERA_LOG_LEVEL=INFO
105105
```

infera/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl LogLevel {
4646

4747
/// Cache eviction strategy
4848
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
49+
#[allow(clippy::upper_case_acronyms)]
4950
pub enum CacheEvictionStrategy {
5051
/// Least Recently Used - evict oldest accessed files first
5152
LRU,
@@ -76,6 +77,7 @@ pub struct InferaConfig {
7677
pub cache_size_limit: u64,
7778

7879
/// Whether to enable verbose logging
80+
#[allow(dead_code)]
7981
pub verbose_logging: bool,
8082

8183
/// HTTP request timeout in seconds
@@ -88,6 +90,7 @@ pub struct InferaConfig {
8890
pub http_retry_delay_ms: u64,
8991

9092
/// Cache eviction strategy
93+
#[allow(dead_code)]
9194
pub cache_eviction_strategy: CacheEvictionStrategy,
9295

9396
/// Logging level

infera/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub(crate) fn run_inference_impl(
124124
// If model inner dimensions (after the first/batch dim) are all known (>0),
125125
// validate that the provided `cols` matches their product. This yields clearer errors
126126
// than deferring to the backend.
127-
if model.input_shape.len() >= 1 {
127+
if !model.input_shape.is_empty() {
128128
let inner_dims = &model.input_shape[1..];
129129
if inner_dims.iter().all(|&d| d > 0) {
130130
let expected_inner: usize = inner_dims.iter().map(|&d| d as usize).product();

infera/src/http.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::config::{LogLevel, CONFIG};
55
use crate::error::InferaError;
66
use crate::log;
77
use sha2::{Digest, Sha256};
8-
use std::env;
98
use std::fs::{self, File};
109
use std::io;
1110
use std::path::{Path, PathBuf};
@@ -71,15 +70,16 @@ fn get_cached_files_by_access_time() -> Result<Vec<(PathBuf, SystemTime, u64)>,
7170
}
7271

7372
let mut files = Vec::new();
74-
for entry in fs::read_dir(&dir).map_err(|e| InferaError::IoError(e.to_string()))? {
75-
if let Ok(entry) = entry {
76-
let path = entry.path();
77-
if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("onnx") {
78-
if let Ok(metadata) = fs::metadata(&path) {
79-
let accessed = metadata.accessed().unwrap_or_else(|_| SystemTime::now());
80-
let size = metadata.len();
81-
files.push((path, accessed, size));
82-
}
73+
for entry in fs::read_dir(&dir)
74+
.map_err(|e| InferaError::IoError(e.to_string()))?
75+
.flatten()
76+
{
77+
let path = entry.path();
78+
if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("onnx") {
79+
if let Ok(metadata) = fs::metadata(&path) {
80+
let accessed = metadata.accessed().unwrap_or_else(|_| SystemTime::now());
81+
let size = metadata.len();
82+
files.push((path, accessed, size));
8383
}
8484
}
8585
}
@@ -127,14 +127,15 @@ pub(crate) fn clear_cache() -> Result<(), InferaError> {
127127
if !dir.exists() {
128128
return Ok(());
129129
}
130-
for entry in fs::read_dir(&dir).map_err(|e| InferaError::IoError(e.to_string()))? {
131-
if let Ok(entry) = entry {
132-
let path = entry.path();
133-
if path.is_file() {
134-
fs::remove_file(&path).map_err(|e| InferaError::IoError(e.to_string()))?;
135-
} else if path.is_dir() {
136-
fs::remove_dir_all(&path).map_err(|e| InferaError::IoError(e.to_string()))?;
137-
}
130+
for entry in fs::read_dir(&dir)
131+
.map_err(|e| InferaError::IoError(e.to_string()))?
132+
.flatten()
133+
{
134+
let path = entry.path();
135+
if path.is_file() {
136+
fs::remove_file(&path).map_err(|e| InferaError::IoError(e.to_string()))?;
137+
} else if path.is_dir() {
138+
fs::remove_dir_all(&path).map_err(|e| InferaError::IoError(e.to_string()))?;
138139
}
139140
}
140141
Ok(())
@@ -276,6 +277,7 @@ fn download_file(url: &str, dest: &Path, timeout_secs: u64) -> Result<(), Infera
276277
mod tests {
277278
use super::*;
278279
use mockito::Server;
280+
use std::env; // moved here: used in tests only
279281
use std::thread;
280282
use tiny_http::{Header, Response, Server as TinyServer};
281283

infera/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The public C API layer and module declarations.
33

44
use serde_json::json;
5-
use std::env;
65
use std::ffi::{c_char, CStr, CString};
76
use std::fs;
87

@@ -326,16 +325,15 @@ pub extern "C" fn infera_get_cache_info() -> *mut c_char {
326325
let mut file_count = 0usize;
327326

328327
if cache_dir.exists() {
329-
for entry in
330-
fs::read_dir(&cache_dir).map_err(|e| error::InferaError::IoError(e.to_string()))?
328+
for entry in fs::read_dir(&cache_dir)
329+
.map_err(|e| error::InferaError::IoError(e.to_string()))?
330+
.flatten()
331331
{
332-
if let Ok(entry) = entry {
333-
let path = entry.path();
334-
if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("onnx") {
335-
if let Ok(metadata) = fs::metadata(&path) {
336-
total_size += metadata.len();
337-
file_count += 1;
338-
}
332+
let path = entry.path();
333+
if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("onnx") {
334+
if let Ok(metadata) = fs::metadata(&path) {
335+
total_size += metadata.len();
336+
file_count += 1;
339337
}
340338
}
341339
}

test/sql/test_decimal_features.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ true
2020

2121
statement ok
2222
select infera_unload_model('linear_dec')
23-

test/sql/test_is_model_loaded.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ query I
3333
select infera_is_model_loaded('linear')
3434
----
3535
false
36-

0 commit comments

Comments
 (0)