Skip to content

Commit

Permalink
Merge pull request #15 from samply/feature/coder
Browse files Browse the repository at this point in the history
Added: RStudio in Coder
  • Loading branch information
djuarezgf authored Jun 26, 2024
2 parents 9787f18 + f8528ae commit 5c439b7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.0.1 - 2024-06-13]
## [0.0.1 - 2024-06-26]
### Added
- First version of the project
- Spring Application
Expand Down Expand Up @@ -135,3 +135,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Max time to wait focus task in minutes
- Check export execution status
- Coder Service
- RStudio in Coder
5 changes: 4 additions & 1 deletion src/main/java/de/samply/app/ProjectManagerConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public class ProjectManagerConst {
public final static String CODER_SESSION_TOKEN_HEADER = "Coder-Session-Token";

public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_KEY = "Enable Jupyter Lab?";
public final static String CODER_ENABLE_RSTUDIO_PARAM_KEY = "Enable RStudio?";
public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_KEY = "Enable VS Code Server?";
public final static String CODER_DOTFILES_URL_PARAM_KEY = "Your Dotfiles URL";
public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_KEY = "Samply.Beam: Enable file receiver";
Expand Down Expand Up @@ -340,6 +341,7 @@ public class ProjectManagerConst {
public final static String CODER_SESSION_TOKEN = "CODER_SESSION_TOKEN";

public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE = "CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE";
public final static String CODER_ENABLE_RSTUDIO_PARAM_VALUE = "CODER_ENABLE_RSTUDIO_PARAM_VALUE";
public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE = "CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE";
public final static String CODER_DOTFILES_URL_PARAM_VALUE = "CODER_DOTFILES_URL_PARAM_VALUE";
public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE = "CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE";
Expand Down Expand Up @@ -388,7 +390,7 @@ public class ProjectManagerConst {
public final static String DATASHIELD_TEMPLATES_SV = HEAD_SV + DATASHIELD_TEMPLATES + BOTTOM_SV;
public final static String TOKEN_MANAGER_URL_SV = HEAD_SV + TOKEN_MANAGER_URL + BOTTOM_SV;
public final static String FOCUS_PROJECT_MANAGER_ID_SV = HEAD_SV + FOCUS_PROJECT_MANAGER_ID + BOTTOM_SV;
public final static String FOCUS_TTL_SV = HEAD_SV + FOCUS_TTL + ":10s" + BOTTOM_SV;
public final static String FOCUS_TTL_SV = HEAD_SV + FOCUS_TTL + ":60s" + BOTTOM_SV;
public final static String FOCUS_FAILURE_STRATEGY_BACKOFF_IN_MILLISECONDS_SV =
HEAD_SV + FOCUS_FAILURE_STRATEGY_BACKOFF_IN_MILLISECONDS + ":1000" + BOTTOM_SV;
public final static String FOCUS_FAILURE_STRATEGY_MAX_TRIES_SV = HEAD_SV + FOCUS_FAILURE_STRATEGY_MAX_TRIES + ":5" + BOTTOM_SV;
Expand Down Expand Up @@ -422,6 +424,7 @@ public class ProjectManagerConst {
public final static String CODER_SESSION_TOKEN_SV = HEAD_SV + CODER_SESSION_TOKEN + BOTTOM_SV;

public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE + ":1" + BOTTOM_SV;
public final static String CODER_ENABLE_RSTUDIO_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_RSTUDIO_PARAM_VALUE + ":1" + BOTTOM_SV;
public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE + ":0" + BOTTOM_SV;
public final static String CODER_DOTFILES_URL_PARAM_VALUE_SV = HEAD_SV + CODER_DOTFILES_URL_PARAM_VALUE + ":" + BOTTOM_SV;
public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE + ":1" + BOTTOM_SV;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/samply/app/ProjectManagerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ public ResponseEntity<String> uploadVotum(

@RoleConstraints(projectRoles = {ProjectRole.CREATOR, ProjectRole.BRIDGEHEAD_ADMIN, ProjectRole.PROJECT_MANAGER_ADMIN})
@StateConstraints(projectStates = {ProjectState.FINISHED})
@EmailSender(templateType = EmailTemplateType.NEW_PUBLICATION, recipients = {EmailRecipientType.PROJECT_ALL})
@FrontendSiteModule(site = ProjectManagerConst.PROJECT_VIEW_SITE, module = ProjectManagerConst.PROJECT_DOCUMENTS_MODULE)
@FrontendAction(action = ProjectManagerConst.ADD_PUBLICATION_URL_ACTION)
@PostMapping(value = ProjectManagerConst.ADD_PUBLICATION_URL)
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/de/samply/coder/CoderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CoderService {
private final String coderCreatePath;
private final String coderDeletePath;
private final String enableJupyterLab;
private final String enableRstudio;
private final String enableVsCodeServer;
private final String dotFilesUrl;
private final String enableFileReceiver;
Expand All @@ -54,11 +55,11 @@ public CoderService(
@Value(ProjectManagerConst.ENABLE_CODER_SV) boolean coderEnabled,
@Value(ProjectManagerConst.CODER_BASE_URL_SV) String coderBaseUrl,
@Value(ProjectManagerConst.CODER_ORGANISATION_ID_SV) String coderOrganizationId,
@Value(ProjectManagerConst.CODER_MEMBER_ID_SV) String coderMemberId,
@Value(ProjectManagerConst.CODER_TEMPLATE_VERSION_ID_SV) String coderTemplateVersionId,
@Value(ProjectManagerConst.CODER_CREATE_PATH_SV) String coderCreatePath,
@Value(ProjectManagerConst.CODER_DELETE_PATH_SV) String coderDeletePath,
@Value(ProjectManagerConst.CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE_SV) String enableJupyterLab,
@Value(ProjectManagerConst.CODER_ENABLE_RSTUDIO_PARAM_VALUE_SV) String enableRstudio,
@Value(ProjectManagerConst.CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE_SV) String enableVsCodeServer,
@Value(ProjectManagerConst.CODER_DOTFILES_URL_PARAM_VALUE_SV) String dotFilesUrl,
@Value(ProjectManagerConst.CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE_SV) String enableFileReceiver,
Expand All @@ -69,12 +70,12 @@ public CoderService(
this.notificationService = notificationService;
this.projectRepository = projectRepository;
this.enableJupyterLab = enableJupyterLab;
this.enableRstudio = enableRstudio;
this.enableVsCodeServer = enableVsCodeServer;
this.dotFilesUrl = dotFilesUrl;
this.enableFileReceiver = enableFileReceiver;
this.coderSessionToken = coderSessionToken;
Map<String, String> pathVariables = Map.of(ProjectManagerConst.CODER_ORGANISATION_ID, coderOrganizationId,
ProjectManagerConst.CODER_MEMBER_ID, coderMemberId);
Map<String, String> pathVariables = Map.of(ProjectManagerConst.CODER_ORGANISATION_ID, coderOrganizationId);
this.coderCreatePath = replaceVariablesInPath(coderCreatePath, pathVariables);
this.coderDeletePath = replaceVariablesInPath(coderDeletePath, pathVariables);

Expand Down Expand Up @@ -119,7 +120,8 @@ public void createWorkspace(@NotNull String email, @NotNull Project project) {

private Mono<Response> createWorkspace(ProjectCoder projectCoder, CreateRequestBody createRequestBody) {
return this.webClient.post()
.uri(uriBuilder -> uriBuilder.path(ProjectManagerConst.CODER_API_PATH).path(coderCreatePath).build())
.uri(uriBuilder -> uriBuilder.path(ProjectManagerConst.CODER_API_PATH).path(
replaceVariablesInPath(coderCreatePath, Map.of(ProjectManagerConst.CODER_MEMBER_ID, fetchCoderMemberId(projectCoder.getEmail())))).build())
.header(ProjectManagerConst.CODER_SESSION_TOKEN_HEADER, coderSessionToken)
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(createRequestBody)
Expand Down Expand Up @@ -198,6 +200,7 @@ private CreateRequestBody generateCreateRequestBody(ProjectCoder projectCoder) {

private void addRichParameterValues(CreateRequestBody createRequestBody, ProjectCoder projectCoder) {
List<CreateRequestParameter> createRequestParameters = List.of(
new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_RSTUDIO_PARAM_KEY, enableRstudio),
new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_JUPYTER_LAB_PARAM_KEY, enableJupyterLab),
new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_VS_CODE_SERVER_PARAM_KEY, enableVsCodeServer),
new CreateRequestParameter(ProjectManagerConst.CODER_DOTFILES_URL_PARAM_KEY, dotFilesUrl),
Expand All @@ -216,4 +219,7 @@ private String generateAppSecret() {
return UUID.randomUUID().toString();
}

private String fetchCoderMemberId(@NotNull String email) {
return email.substring(0, email.indexOf("@")).replace(".", "");
}
}
3 changes: 2 additions & 1 deletion src/main/java/de/samply/project/ProjectType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum ProjectType {
EXPORT,
DATASHIELD
//DATA_SCIENCE_ORCHESTRATOR //TODO: Data Science Orchestrator
//,
//RESEARCH_ENVIRONMENT
}
4 changes: 2 additions & 2 deletions src/main/resources/email-templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
"RESULTS_ACCEPTED": {
"subject": "Results accepted",
"files": {
"DEFAULT": "default-admin-results-accepted.html"
"DEFAULT": "default-results-accepted.html"
}
},
"RESULTS_REJECTED": {
"subject": "Results rejected",
"files": {
"DEFAULT": "default-admin-results-rejected.html"
"DEFAULT": "default-results-rejected.html"
}
},
"REQUEST_CHANGES_IN_PROJECT": {
Expand Down

0 comments on commit 5c439b7

Please sign in to comment.