-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from scc-digitalhub/models-hf-mlflow-sklearn
Models hf mlflow sklearn
- Loading branch information
Showing
42 changed files
with
1,843 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
.../src/main/java/it/smartcommunitylabdhub/core/models/specs/model/HuggingFaceModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
package it.smartcommunitylabdhub.core.models.specs.model; | ||
|
||
|
||
import it.smartcommunitylabdhub.commons.annotations.common.SpecType; | ||
import it.smartcommunitylabdhub.commons.models.enums.EntityName; | ||
|
||
|
||
@SpecType(kind = "huggingface", entity = EntityName.MODEL) | ||
public class HuggingFaceModelSpec extends it.smartcommunitylabdhub.commons.models.entities.model.HuggingFaceModelSpec { | ||
} |
9 changes: 9 additions & 0 deletions
9
...ation/src/main/java/it/smartcommunitylabdhub/core/models/specs/model/MlflowModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package it.smartcommunitylabdhub.core.models.specs.model; | ||
|
||
|
||
import it.smartcommunitylabdhub.commons.annotations.common.SpecType; | ||
import it.smartcommunitylabdhub.commons.models.enums.EntityName; | ||
@SpecType(kind = "mlflow", entity = EntityName.MODEL) | ||
public class MlflowModelSpec extends it.smartcommunitylabdhub.commons.models.entities.model.MlflowModelSpec { | ||
|
||
} |
32 changes: 1 addition & 31 deletions
32
application/src/main/java/it/smartcommunitylabdhub/core/models/specs/model/ModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
package it.smartcommunitylabdhub.core.models.specs.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import it.smartcommunitylabdhub.commons.annotations.common.SpecType; | ||
import it.smartcommunitylabdhub.commons.models.entities.model.ModelBaseSpec; | ||
import it.smartcommunitylabdhub.commons.models.enums.EntityName; | ||
import java.io.Serializable; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@SpecType(kind = "model", entity = EntityName.MODEL) | ||
public class ModelSpec extends ModelBaseSpec { | ||
|
||
@JsonProperty("base_model") | ||
private String baseModel; | ||
|
||
@JsonProperty("parameters") | ||
private Map<String, Serializable> parameters = new LinkedHashMap<>(); | ||
|
||
@JsonProperty("metrics") | ||
private Map<String, Number> metrics = new LinkedHashMap<>(); | ||
|
||
@Override | ||
public void configure(Map<String, Serializable> data) { | ||
super.configure(data); | ||
|
||
ModelSpec spec = mapper.convertValue(data, ModelSpec.class); | ||
|
||
this.baseModel = spec.getBaseModel(); | ||
this.parameters = spec.getParameters(); | ||
this.metrics = spec.getMetrics(); | ||
} | ||
public class ModelSpec extends it.smartcommunitylabdhub.commons.models.entities.model.ModelBaseSpec { | ||
} |
9 changes: 9 additions & 0 deletions
9
...tion/src/main/java/it/smartcommunitylabdhub/core/models/specs/model/SKLearnModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package it.smartcommunitylabdhub.core.models.specs.model; | ||
|
||
|
||
import it.smartcommunitylabdhub.commons.annotations.common.SpecType; | ||
import it.smartcommunitylabdhub.commons.models.enums.EntityName; | ||
|
||
@SpecType(kind = "sklearn", entity = EntityName.MODEL) | ||
public class SKLearnModelSpec extends it.smartcommunitylabdhub.commons.models.entities.model.SKLearnModelSpec { | ||
} |
18 changes: 18 additions & 0 deletions
18
...cation/src/main/java/it/smartcommunitylabdhub/core/models/specs/model/mlflow/Dataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package it.smartcommunitylabdhub.core.models.specs.model.mlflow; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class Dataset { | ||
|
||
private String name; | ||
private String digest; | ||
private String profile; | ||
private String schema; | ||
private String source; | ||
@JsonProperty("source_type") | ||
private String sourceType; | ||
} |
13 changes: 13 additions & 0 deletions
13
...tion/src/main/java/it/smartcommunitylabdhub/core/models/specs/model/mlflow/Signature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package it.smartcommunitylabdhub.core.models.specs.model.mlflow; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class Signature { | ||
|
||
private String inputs; | ||
private String outputs; | ||
private String params; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ain/java/it/smartcommunitylabdhub/commons/models/entities/model/HuggingFaceModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@Getter | ||
@Setter | ||
public class HuggingFaceModelSpec extends ModelSpec { | ||
|
||
//Huggingface model id | ||
@JsonProperty("model_id") | ||
private String modelId; | ||
|
||
//Huggingface model revision | ||
@JsonProperty("model_revision") | ||
private String modelRevision; | ||
|
||
@Override | ||
public void configure(Map<String, Serializable> data) { | ||
super.configure(data); | ||
|
||
HuggingFaceModelSpec spec = mapper.convertValue(data, HuggingFaceModelSpec.class); | ||
|
||
this.modelId = spec.getModelId(); | ||
this.modelRevision = spec.getModelRevision(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...src/main/java/it/smartcommunitylabdhub/commons/models/entities/model/MlflowModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model; | ||
|
||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import it.smartcommunitylabdhub.commons.models.entities.model.mlflow.Dataset; | ||
import it.smartcommunitylabdhub.commons.models.entities.model.mlflow.Signature; | ||
|
||
@Getter | ||
@Setter | ||
public class MlflowModelSpec extends ModelSpec { | ||
|
||
private String flavor; | ||
|
||
@JsonProperty("model_config") | ||
private Map<String, String> modelConfig; | ||
|
||
@JsonProperty("input_datasets") | ||
private List<Dataset> inputDatasets; | ||
|
||
private Signature signature; | ||
|
||
@Override | ||
public void configure(Map<String, Serializable> data) { | ||
super.configure(data); | ||
|
||
MlflowModelSpec spec = mapper.convertValue(data, MlflowModelSpec.class); | ||
this.flavor = spec.getFlavor(); | ||
this.signature = spec.getSignature(); | ||
this.inputDatasets = spec.getInputDatasets(); | ||
this.modelConfig = spec.getModelConfig(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...mmons/src/main/java/it/smartcommunitylabdhub/commons/models/entities/model/ModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.io.Serializable; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ModelSpec extends ModelBaseSpec { | ||
|
||
@JsonProperty("base_model") | ||
private String baseModel; | ||
|
||
@JsonProperty("parameters") | ||
private Map<String, Serializable> parameters = new LinkedHashMap<>(); | ||
|
||
@JsonProperty("metrics") | ||
private Map<String, Number> metrics = new LinkedHashMap<>(); | ||
|
||
@Override | ||
public void configure(Map<String, Serializable> data) { | ||
super.configure(data); | ||
|
||
ModelSpec spec = mapper.convertValue(data, ModelSpec.class); | ||
|
||
this.baseModel = spec.getBaseModel(); | ||
this.parameters = spec.getParameters(); | ||
this.metrics = spec.getMetrics(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/it/smartcommunitylabdhub/commons/models/entities/model/SKLearnModelSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class SKLearnModelSpec extends ModelSpec { | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
.../src/main/java/it/smartcommunitylabdhub/commons/models/entities/model/mlflow/Dataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model.mlflow; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class Dataset { | ||
|
||
private String name; | ||
private String digest; | ||
private String profile; | ||
private String schema; | ||
private String source; | ||
@JsonProperty("source_type") | ||
private String sourceType; | ||
} |
13 changes: 13 additions & 0 deletions
13
...rc/main/java/it/smartcommunitylabdhub/commons/models/entities/model/mlflow/Signature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package it.smartcommunitylabdhub.commons.models.entities.model.mlflow; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class Signature { | ||
|
||
private String inputs; | ||
private String outputs; | ||
private String params; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-runtime-model-serve</artifactId> | ||
<version>0.7.0-SNAPSHOT</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-commons</artifactId> | ||
<version>0.7.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-framework-k8s</artifactId> | ||
<version>0.7.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-framework-kaniko</artifactId> | ||
<version>0.7.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.34</version> | ||
<scope>compile</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.16.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-cbor</artifactId> | ||
<version>2.16.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
<version>2.16.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.module</groupId> | ||
<artifactId>jackson-module-jsonSchema</artifactId> | ||
<version>2.16.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
<version>2.16.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>2.0.9</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>log4j-over-slf4j</artifactId> | ||
<version>2.0.9</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.