Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Apr 2, 2024
1 parent f5b92af commit c8ab1ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ candle-flash-attn = { git = "https://github.com/huggingface/candle", package = "
candle-nn = { git = "https://github.com/huggingface/candle", package = "candle-nn", version = "0.4.2" }
candle-transformers = { git = "https://github.com/huggingface/candle", package = "candle-transformers", version = "0.4.2" }
config = "0.14.0"
dotenv = "0.15.0"
ed25519-consensus = "2.1.0"
futures = "0.3.30"
hf-hub = "0.3.2"
Expand Down
1 change: 1 addition & 0 deletions atoma-inference/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ candle-flash-attn = { workspace = true, optional = true }
candle-nn.workspace = true
candle-transformers.workspace = true
config.workspace = true
dotenv.workspace = true
ed25519-consensus.workspace = true
futures.workspace = true
hf-hub.workspace = true
Expand Down
31 changes: 31 additions & 0 deletions atoma-inference/src/models/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use config::Config;
use dotenv::dotenv;
use serde::{Deserialize, Serialize};

use crate::{models::types::PrecisionBits, models::ModelId};
Expand Down Expand Up @@ -64,6 +65,36 @@ impl ModelConfig {
.try_deserialize::<Self>()
.expect("Failed to generated config file")
}

pub fn from_env_file() -> Self {
dotenv().ok();

let api_key = std::env::var("API_KEY").expect("Failed to retrieve api key, from .env file");
let flush_storage = std::env::var("FLUSH_STORAGE")
.expect("Failed to retrieve flush storage variable, from .env file")
.parse()
.unwrap();
let models = serde_json::from_str(
&std::env::var("MODELS").expect("Failed to retrieve models metadata, from .env file"),
)
.unwrap();
let storage_path = std::env::var("STORAGE_PATH")
.expect("Failed to retrieve storage path, from .env file")
.parse()
.unwrap();
let tracing = std::env::var("TRACING")
.expect("Failed to retrieve tracing variable, from .env file")
.parse()
.unwrap();

Self {
api_key,
flush_storage,
models,
storage_path,
tracing,
}
}
}

#[cfg(test)]
Expand Down

0 comments on commit c8ab1ad

Please sign in to comment.