15
15
*/
16
16
package io .hops .hopsworks .api .modelregistry .models ;
17
17
18
- import com .google .common .base .Strings ;
19
18
import io .hops .hopsworks .api .modelregistry .models .dto .ModelDTO ;
20
19
import io .hops .hopsworks .common .dao .project .ProjectFacade ;
21
20
import io .hops .hopsworks .common .dataset .DatasetController ;
22
21
import io .hops .hopsworks .common .hdfs .DistributedFileSystemOps ;
23
22
import io .hops .hopsworks .common .hdfs .DistributedFsService ;
24
23
import io .hops .hopsworks .common .hdfs .HdfsUsersController ;
25
24
import io .hops .hopsworks .common .hdfs .Utils ;
26
- import io .hops .hopsworks .common .provenance .state .dto .ProvStateDTO ;
27
- import io .hops .hopsworks .common .python .environment .EnvironmentController ;
28
25
import io .hops .hopsworks .common .util .AccessController ;
29
26
import io .hops .hopsworks .common .util .Settings ;
30
27
import io .hops .hopsworks .exceptions .DatasetException ;
31
28
import io .hops .hopsworks .exceptions .GenericException ;
32
- import io .hops .hopsworks .exceptions .JobException ;
33
- import io .hops .hopsworks .exceptions .MetadataException ;
34
- import io .hops .hopsworks .exceptions .ModelRegistryException ;
29
+
35
30
import io .hops .hopsworks .exceptions .ProjectException ;
36
- import io .hops .hopsworks .exceptions .PythonException ;
37
- import io .hops .hopsworks .exceptions .ServiceException ;
38
31
import io .hops .hopsworks .persistence .entity .dataset .Dataset ;
39
32
import io .hops .hopsworks .persistence .entity .project .Project ;
40
33
import io .hops .hopsworks .persistence .entity .user .Users ;
41
34
import io .hops .hopsworks .restutils .RESTCodes ;
42
- import org .json .JSONObject ;
43
35
44
36
import javax .ejb .EJB ;
45
37
import javax .ejb .Stateless ;
46
38
import javax .ejb .TransactionAttribute ;
47
39
import javax .ejb .TransactionAttributeType ;
48
- import javax .ws .rs .core .Response ;
49
- import javax .ws .rs .core .UriBuilder ;
50
- import javax .ws .rs .core .UriInfo ;
51
40
import java .util .logging .Level ;
52
41
53
42
@ Stateless
@@ -64,12 +53,6 @@ public class ModelUtils {
64
53
private HdfsUsersController hdfsUsersController ;
65
54
@ EJB
66
55
private DistributedFsService dfs ;
67
- @ EJB
68
- private ModelsController modelsController ;
69
- @ EJB
70
- private EnvironmentController environmentController ;
71
- @ EJB
72
- private ModelConverter modelConverter ;
73
56
74
57
public String getModelsDatasetPath (Project userProject , Project modelRegistryProject ) {
75
58
String modelsPath = Utils .getProjectPath (userProject .getName ()) + Settings .HOPS_MODELS_DATASET + "/" ;
@@ -139,39 +122,10 @@ public ModelsController.Accessor getModelsAccessor(Users user, Project userProje
139
122
}
140
123
}
141
124
142
- public Response createModel (UriInfo uriInfo , ModelsController .Accessor accessor , String mlId , ModelDTO modelDTO ,
143
- String jobName , String kernelId )
144
- throws DatasetException , MetadataException , JobException , ServiceException , PythonException ,
145
- ModelRegistryException {
146
- String realName = accessor .user .getFname () + " " + accessor .user .getLname ();
147
- //Only attach program and environment if exporting inside Hopsworks
148
- if (!Strings .isNullOrEmpty (jobName ) || !Strings .isNullOrEmpty (kernelId )) {
149
-
150
- modelDTO .setProgram (modelsController .versionProgram (accessor , jobName , kernelId ,
151
- modelDTO .getName (), modelDTO .getVersion ()));
152
- //Export environment to correct path here
153
- modelDTO .setEnvironment (environmentController .exportEnv (accessor .experimentProject , accessor .user ,
154
- getModelFullPath (accessor .modelProject , modelDTO .getName (), modelDTO .getVersion ()) +
155
- "/" + Settings .ENVIRONMENT_FILE
156
- ));
157
- }
158
-
159
- modelDTO .setModelRegistryId (accessor .modelProject .getId ());
160
-
161
- modelsController .attachModel (accessor .udfso , accessor .modelProject , realName , modelDTO );
162
- UriBuilder builder = uriInfo .getAbsolutePathBuilder ().path (mlId );
163
- return Response .created (builder .build ()).entity (modelDTO ).build ();
164
- }
165
-
166
125
public String getModelFullPath (Project modelRegistryProject , String modelName , Integer modelVersion ) {
167
126
return Utils .getProjectPath (modelRegistryProject .getName ()) +
168
127
Settings .HOPS_MODELS_DATASET + "/" + modelName + "/" + modelVersion ;
169
128
}
170
-
171
- public ModelDTO convertProvenanceHitToModel (ProvStateDTO model ) throws ModelRegistryException {
172
- JSONObject summary = new JSONObject (model .getXattrs ().get (ModelsBuilder .MODEL_SUMMARY_XATTR_NAME ));
173
- return modelConverter .unmarshalDescription (summary .toString ());
174
- }
175
129
176
130
public String [] getModelNameAndVersion (String mlId ) {
177
131
int splitIndex = mlId .lastIndexOf ("_" );
0 commit comments