Skip to content

Commit

Permalink
chore(controller): application configuration use snake case (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui authored Jan 9, 2023
1 parent 4449bc4 commit 0c824a6
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 52 deletions.
5 changes: 5 additions & 0 deletions server/controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
@Slf4j
public class DataStoreController implements DataStoreApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
@Slf4j
public class DatasetController implements DatasetApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class EnvController implements EnvApi {

private final EnvService envService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Slf4j
@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class EvaluationController implements EvaluationApi {

private final EvaluationService evaluationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

@Slf4j
@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class JobController implements JobApi {

private final JobService jobService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class LogController implements LogApi {

final TaskService taskService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

@Slf4j
@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class ModelController implements ModelApi {

private final ModelService modelService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class PanelController implements PanelApi {

private final PluginService pluginService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class ProjectController implements ProjectApi {

private final ProjectService projectService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

@Slf4j
@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class RuntimeController implements RuntimeApi {

private final RuntimeService runtimeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class SystemController implements SystemApi {

private final SystemService systemService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class TrashController implements TrashApi {

private final TrashService trashService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${sw.controller.apiPrefix}")
@RequestMapping("${sw.controller.api-prefix}")
public class UserController implements UserApi {

private final UserService userService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ContentCachingFilter extends OncePerRequestFilter {

private final String apiPrefix;

public ContentCachingFilter(@Value("${sw.controller.apiPrefix}") String apiPrefix) {
public ContentCachingFilter(@Value("${sw.controller.api-prefix}") String apiPrefix) {
this.apiPrefix = StringUtils.trimTrailingCharacter(apiPrefix, '/') + "/datastore";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ProjectNameExtractorDataStoreMixed implements ProjectNameExtractor
static final String PATH_QUERY_TABLE = "/datastore/queryTable";
static final String PATH_SCAN_TABLE = "/datastore/scanTable";

public ProjectNameExtractorDataStoreMixed(@Value("${sw.controller.apiPrefix}") String apiPrefix,
public ProjectNameExtractorDataStoreMixed(@Value("${sw.controller.api-prefix}") String apiPrefix,
ObjectMapper objectMapper) {
this.apiPrefix = StringUtils.trimTrailingCharacter(apiPrefix, '/');
this.objectMapper = objectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ public class DataStore {
private final DumpThread dumpThread;

public DataStore(StorageAccessService storageAccessService,
@Value("${sw.datastore.walFileSize}") int walFileSize,
@Value("${sw.datastore.walMaxFileSize}") int walMaxFileSize,
@Value("${sw.datastore.ossMaxAttempts}") int ossMaxAttempts,
@Value("${sw.datastore.dataRootPath:}") String dataRootPath,
@Value("${sw.datastore.dumpInterval:1h}") String dumpInterval,
@Value("${sw.datastore.minNoUpdatePeriod:1d}") String minNoUpdatePeriod,
@Value("${sw.datastore.parquet.compressionCodec:SNAPPY}") String compressionCodec,
@Value("${sw.datastore.parquet.rowGroupSize:128MB}") String rowGroupSize,
@Value("${sw.datastore.parquet.pageSize:1MB}") String pageSize,
@Value("${sw.datastore.parquet.pageRowCountLimit:20000}") int pageRowCountLimit) {
@Value("${sw.datastore.wal-file-size}") int walFileSize,
@Value("${sw.datastore.wal-max-file-size}") int walMaxFileSize,
@Value("${sw.datastore.oss-max-attempts}") int ossMaxAttempts,
@Value("${sw.datastore.data-root-path:}") String dataRootPath,
@Value("${sw.datastore.dump-interval:1h}") String dumpInterval,
@Value("${sw.datastore.min-no-update-period:1d}") String minNoUpdatePeriod,
@Value("${sw.datastore.parquet.compression-codec:SNAPPY}") String compressionCodec,
@Value("${sw.datastore.parquet.row-group-size:128MB}") String rowGroupSize,
@Value("${sw.datastore.parquet.page-size:1MB}") String pageSize,
@Value("${sw.datastore.parquet.page-row-count-limit:20000}") int pageRowCountLimit) {
this.storageAccessService = storageAccessService;
if (!dataRootPath.isEmpty() && !dataRootPath.endsWith("/")) {
dataRootPath += "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class TaskWatcherForSchedule implements TaskStatusChangeWatcher {
public TaskWatcherForSchedule(
SwTaskScheduler taskScheduler,
TaskStatusMachine taskStatusMachine,
@Value("${sw.task.deletionDelayMinutes}") Long deletionDelayMinutes
@Value("${sw.task.deletion-delay-minutes}") Long deletionDelayMinutes
) {
this.taskScheduler = taskScheduler;
this.taskStatusMachine = taskStatusMachine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class K8sJobTemplate {
final V1Job v1Job;

public K8sJobTemplate(
@Value("${sw.infra.k8s.job-template-path}") String evalJobTemplatePath,
@Value("${sw.infra.k8s.job.template-path}") String evalJobTemplatePath,
@Value("${sw.infra.k8s.model-serving-template-path}") String msPath,
@Value("${sw.infra.k8s.host-path-for-cache}") String pipCacheHostPath
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public K8sTaskScheduler(K8sClient k8sClient,
ResourceEventHandler<V1Job> eventHandlerJob,
ResourceEventHandler<V1Node> eventHandlerNode,
ResourceEventHandler<V1Pod> eventHandlerPod, @Value("${sw.instance-uri}") String instanceUri,
@Value("${sw.dataset.load.batchSize}") int datasetLoadBatchSize,
@Value("${sw.infra.k8s.job.restartPolicy:OnFailure}") String restartPolicy,
@Value("${sw.infra.k8s.job.backoffLimit:10}") Integer backoffLimit,
@Value("${sw.dataset.load.batch-size}") int datasetLoadBatchSize,
@Value("${sw.infra.k8s.job.restart-policy}") String restartPolicy,
@Value("${sw.infra.k8s.job.backoff-limit}") Integer backoffLimit,
StorageAccessService storageAccessService) {
this.k8sClient = k8sClient;
this.taskTokenValidator = taskTokenValidator;
Expand Down
45 changes: 23 additions & 22 deletions server/controller/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ sw:
jwt:
secret: ${SW_JWT_SECRET:wdxlG3UK66m6uTUgxXFjizli}
issuer: ${SW_JWT_ISSUER:starwhale}
expireMinutes: ${SW_JWT_TOKEN_EXPIRE_MINUTES:43200}
expire-minutes: ${SW_JWT_TOKEN_EXPIRE_MINUTES:43200}
dataset:
load:
batchSize: ${DATASET_CONSUMPTION_BATCH_SIZE:50}
batch-size: ${DATASET_CONSUMPTION_BATCH_SIZE:50}
task:
size: ${SW_TASK_SPLIT_SIZE:1}
deletionDelayMinutes: ${SW_TASK_DELETION_DELAY_MINUTES:30}
deletion-delay-minutes: ${SW_TASK_DELETION_DELAY_MINUTES:30}
instance-uri: ${SW_INSTANCE_URI:http://console.pre.intra.starwhale.ai}
infra:
k8s:
name-space: ${SW_K8S_NAME_SPACE:default}
host-path-for-cache: ${SW_K8S_HOST_PATH_FOR_CACHE:}
job-template-path: ${SW_K8S_JOB_TEMPLATE_PATH:}
model-serving-template-path: ${SW_K8S_MODEL_SERVING_TEMPLATE_PATH:}
job:
template-path: ${SW_K8S_JOB_TEMPLATE_PATH:}
restart-policy: ${SW_K8S_JOB_RESTART_POLICY:OnFailure}
backoff-limit: ${SW_K8S_JOB_BACKOFF_LIMIT:10}
storage:
type: ${SW_STORAGE_TYPE:minio}
path-prefix: ${SW_STORAGE_PREFIX:starwhale}
Expand All @@ -42,29 +45,27 @@ sw:
service-provider: ${SW_INSTANCE_URI}/obj-store
s3-config:
bucket: ${SW_STORAGE_BUCKET:starwhale}
accessKey: ${SW_STORAGE_ACCESSKEY:starwhale}
secretKey: ${SW_STORAGE_SECRETKEY:starwhale}
access-key: ${SW_STORAGE_ACCESSKEY:starwhale}
secret-key: ${SW_STORAGE_SECRETKEY:starwhale}
region: ${SW_STORAGE_REGION:local}
endpoint: ${SW_STORAGE_ENDPOINT:http://localhost:9000}
hugeFileThreshold: 10485760 # 10MB
hugeFilePartSize: 5242880 # 5MB
huge-file-threshold: 10485760 # 10MB
huge-file-part-size: 5242880 # 5MB
controller:
apiPrefix: /api/v1
whiteList: /api/v1/report
api-prefix: /api/v1
white-list: /api/v1/report
datastore:
fsRootDir: ${SW_DATA_STORE_FS_ROOT_DIR:.}
walFileSize: ${SW_DATASTORE_WAL_FILE_SIZE:65536}
walMaxFileSize: ${SW_DATASTORE_WAL_MAX_FILE_SIZE:67108864}
walPrefix: ${SW_DATASTORE_WAL_LOG_PREFIX:wal/}
ossMaxAttempts: ${SW_DATASTORE_WAL_INIT_MAX_ATTEMPTS:3}
dataRootPath: ${SW_DATASTORE_DATA_ROOT_PATH:}
dumpInterval: ${SW_DATASTORE_DUMP_INTERVAL:1h}
minNoUpdatePeriod: ${SW_DATASTORE_MIN_NO_UPDATE_PERIOD:1d}
wal-file-size: ${SW_DATASTORE_WAL_FILE_SIZE:65536}
wal-max-file-size: ${SW_DATASTORE_WAL_MAX_FILE_SIZE:67108864}
oss-max-attempts: ${SW_DATASTORE_WAL_INIT_MAX_ATTEMPTS:3}
data-root-path: ${SW_DATASTORE_DATA_ROOT_PATH:}
dump-interval: ${SW_DATASTORE_DUMP_INTERVAL:1h}
min-no-update-period: ${SW_DATASTORE_MIN_NO_UPDATE_PERIOD:1d}
parquet:
compressionCodec: ${SW_DATASTORE_PARQUET_COMPRESSION_CODEC:SNAPPY}
rowGroupSize: ${SW_DATASTORE_PARQUET_ROW_GROUP_SIZE:128MB}
pageSize: ${SW_DATASTORE_PARQUET_PAGE_SIZE:1MB}
pageRowCountLimit: ${SW_DATASTORE_PARQUET_PAGE_ROW_COUNT_LIMIT:20000}
compression-codec: ${SW_DATASTORE_PARQUET_COMPRESSION_CODEC:SNAPPY}
row-group-size: ${SW_DATASTORE_PARQUET_ROW_GROUP_SIZE:128MB}
page-size: ${SW_DATASTORE_PARQUET_PAGE_SIZE:1MB}
page-row-count-limit: ${SW_DATASTORE_PARQUET_PAGE_ROW_COUNT_LIMIT:20000}
---
#Development
spring:
Expand Down
5 changes: 5 additions & 0 deletions server/storage-access-layer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
package ai.starwhale.mlops.storage.configuration;

import ai.starwhale.mlops.storage.s3.S3Config;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ConfigurationProperties(prefix = "sw.storage")
public class StorageProperties {

Expand Down

0 comments on commit 0c824a6

Please sign in to comment.