entrenar/hf_pipeline/publish/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Clone, Debug, Default, Serialize, Deserialize)]
7#[serde(default)]
8pub struct PublishConfig {
9 pub repo_id: String,
11 pub repo_type: RepoType,
13 pub private: bool,
15 #[serde(skip)]
17 pub token: Option<String>,
18 pub license: Option<String>,
20 pub tags: Vec<String>,
22}
23
24#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(rename_all = "lowercase")]
27pub enum RepoType {
28 #[default]
30 Model,
31 Dataset,
33 Space,
35}
36
37impl RepoType {
38 #[must_use]
40 pub fn api_path(&self) -> &'static str {
41 match self {
42 Self::Model => "models",
43 Self::Dataset => "datasets",
44 Self::Space => "spaces",
45 }
46 }
47}
48
49impl std::fmt::Display for RepoType {
50 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 match self {
52 Self::Model => write!(f, "model"),
53 Self::Dataset => write!(f, "dataset"),
54 Self::Space => write!(f, "space"),
55 }
56 }
57}