Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lmp_server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmp
lmp_server
Commits
bc070476
Commit
bc070476
authored
Dec 06, 2023
by
linpeiqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加运行状态信息
parent
3c155aac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
TuningRunController.java
...com/yice/webadmin/app/controller/TuningRunController.java
+26
-10
No files found.
application-webadmin/src/main/java/com/yice/webadmin/app/controller/TuningRunController.java
View file @
bc070476
...
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.github.pagehelper.page.PageMethod
;
import
com.github.pagehelper.page.PageMethod
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.yice.common.core.annotation.MyRequestBody
;
import
com.yice.common.core.annotation.MyRequestBody
;
...
@@ -33,12 +32,9 @@ import org.springframework.web.bind.annotation.*;
...
@@ -33,12 +32,9 @@ import org.springframework.web.bind.annotation.*;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -170,7 +166,7 @@ public class TuningRunController {
...
@@ -170,7 +166,7 @@ public class TuningRunController {
array
.
add
(
true
);
array
.
add
(
true
);
array
.
add
(
jsonObject
.
get
(
"dpoBetaData"
));
array
.
add
(
jsonObject
.
get
(
"dpoBetaData"
));
array
.
add
(
new
JSONArray
());
array
.
add
(
new
JSONArray
());
array
.
add
(
"train_"
+
runId
);
array
.
add
(
"train_"
+
runId
);
System
.
out
.
println
(
array
.
toJSONString
());
System
.
out
.
println
(
array
.
toJSONString
());
return
ResponseResult
.
success
(
array
.
toJSONString
());
return
ResponseResult
.
success
(
array
.
toJSONString
());
}
}
...
@@ -244,6 +240,26 @@ public class TuningRunController {
...
@@ -244,6 +240,26 @@ public class TuningRunController {
return
ResponseResult
.
success
(
TuningRun
.
INSTANCE
.
fromModelList
(
tuningRunList
));
return
ResponseResult
.
success
(
TuningRun
.
INSTANCE
.
fromModelList
(
tuningRunList
));
}
}
/**
* 提交运行状态信息。
*
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping
(
"/postRunStatus"
)
public
ResponseResult
<
Void
>
postRunStatus
(
@MyRequestBody
Long
runId
,
@MyRequestBody
Long
runTime
,
@MyRequestBody
Integer
runStatus
)
{
TuningRun
tuningRun
=
this
.
tuningRunService
.
getById
(
runId
);
tuningRun
.
setRunStatus
(
runStatus
);
tuningRun
.
setRunTime
(
runTime
);
String
errorMessage
;
if
(!
tuningRunService
.
updateById
(
tuningRun
))
{
errorMessage
=
"运行状态信息提交错误!"
;
return
ResponseResult
.
error
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
errorMessage
);
}
return
ResponseResult
.
success
();
}
/**
/**
* 查看指定精调任务运行对象详情。
* 查看指定精调任务运行对象详情。
*
*
...
@@ -270,9 +286,10 @@ public class TuningRunController {
...
@@ -270,9 +286,10 @@ public class TuningRunController {
public
ResponseEntity
<
Resource
>
getLog
(
@RequestParam
Long
runId
)
throws
IOException
{
public
ResponseEntity
<
Resource
>
getLog
(
@RequestParam
Long
runId
)
throws
IOException
{
TuningRun
tuningRun
=
this
.
tuningRunService
.
getById
(
runId
);
TuningRun
tuningRun
=
this
.
tuningRunService
.
getById
(
runId
);
ModelVersion
modelVersion
=
this
.
modelVersionService
.
getById
(
tuningRun
.
getModelVersionId
());
ModelVersion
modelVersion
=
this
.
modelVersionService
.
getById
(
tuningRun
.
getModelVersionId
());
String
url
=
this
.
pythonConfig
.
getModelTuningFileBaseDir
()
+
modelVersion
.
getVersionName
()
+
File
.
separator
+
tuningRun
.
getTrainMethod
()
+
File
.
separator
+
"train_"
+
tuningRun
.
getRunId
()
+
File
.
separator
+
"run_train.log"
;
String
url
=
this
.
pythonConfig
.
getModelTuningFileBaseDir
()
+
modelVersion
.
getVersionName
()
+
File
.
separator
+
tuningRun
.
getTrainMethod
()
+
File
.
separator
+
"train_"
+
tuningRun
.
getRunId
()
+
File
.
separator
+
"run_train.log"
;
return
this
.
getFileByUrl
(
url
);
return
this
.
getFileByUrl
(
url
);
}
}
/**
/**
* 获取运行状态。
* 获取运行状态。
*
*
...
@@ -283,13 +300,12 @@ public class TuningRunController {
...
@@ -283,13 +300,12 @@ public class TuningRunController {
public
ResponseResult
<
String
>
getStatus
(
@RequestParam
Long
runId
)
throws
IOException
{
public
ResponseResult
<
String
>
getStatus
(
@RequestParam
Long
runId
)
throws
IOException
{
TuningRun
tuningRun
=
this
.
tuningRunService
.
getById
(
runId
);
TuningRun
tuningRun
=
this
.
tuningRunService
.
getById
(
runId
);
ModelVersion
modelVersion
=
this
.
modelVersionService
.
getById
(
tuningRun
.
getModelVersionId
());
ModelVersion
modelVersion
=
this
.
modelVersionService
.
getById
(
tuningRun
.
getModelVersionId
());
String
url
=
this
.
pythonConfig
.
getModelTuningFileBaseDir
()
+
modelVersion
.
getVersionName
()
+
File
.
separator
+
tuningRun
.
getTrainMethod
()
+
File
.
separator
+
"train_"
+
tuningRun
.
getRunId
()
+
File
.
separator
+
"trainer_state.json"
;
String
url
=
this
.
pythonConfig
.
getModelTuningFileBaseDir
()
+
modelVersion
.
getVersionName
()
+
File
.
separator
+
tuningRun
.
getTrainMethod
()
+
File
.
separator
+
"train_"
+
tuningRun
.
getRunId
()
+
File
.
separator
+
"trainer_state.json"
;
File
file
=
new
File
(
url
);
// 指定文件路径
File
file
=
new
File
(
url
);
// 指定文件路径
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ArrayNode
arrayNode
=
(
ArrayNode
)
objectMapper
.
readTree
(
file
);
return
ResponseResult
.
success
(
objectMapper
.
readTree
(
file
).
toString
());
String
jsonString
=
objectMapper
.
writeValueAsString
(
arrayNode
);
return
ResponseResult
.
success
(
jsonString
);
}
}
private
ResponseEntity
<
Resource
>
getFileByUrl
(
String
url
)
throws
IOException
{
private
ResponseEntity
<
Resource
>
getFileByUrl
(
String
url
)
throws
IOException
{
Path
file
=
Paths
.
get
(
url
);
Path
file
=
Paths
.
get
(
url
);
Resource
resource
=
new
UrlResource
(
file
.
toUri
());
// 使用UrlResource从文件路径构建一个Resource对象
Resource
resource
=
new
UrlResource
(
file
.
toUri
());
// 使用UrlResource从文件路径构建一个Resource对象
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment