Skip to content

Commit

Permalink
fix(backend, deployment): fix seqsets so they can be configured to wo…
Browse files Browse the repository at this point in the history
…rk in production (#2476)

* towards production seqsets

* adapt kotlin code

* Update backend/src/main/kotlin/org/loculus/backend/service/crossref/CrossRefService.kt

Co-authored-by: Chaoran Chen <mail@chaoran-chen.de>

* update

* add quote

---------

Co-authored-by: Chaoran Chen <mail@chaoran-chen.de>
  • Loading branch information
theosanderson and chaoran-chen authored Aug 21, 2024
1 parent 0ad25fe commit dadd17b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
timeout-minutes: 15
env:
CROSSREF_USERNAME: ${{ secrets.CROSSREF_USERNAME }}
CROSSREF_TEST_PASSWORD: ${{ secrets.CROSSREF_TEST_PASSWORD }}
CROSSREF_TEST_ENDPOINT: ${{ secrets.CROSSREF_TEST_ENDPOINT }}
CROSSREF_PASSWORD: ${{ secrets.CROSSREF_PASSWORD }}
CROSSREF_ENDPOINT: ${{ secrets.CROSSREF_ENDPOINT }}
CROSSREF_DOI_PREFIX: ${{ secrets.CROSSREF_DOI_PREFIX }}
steps:
- name: Login to Docker Hub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,5 @@ data class AuthorProfile(
)

object SeqSetCitationsConstants {
const val DOI_PREFIX = "placeholder"
const val DOI_WEEKLY_RATE_LIMIT = 7
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ import java.util.UUID
private val log = KotlinLogging.logger { }

@ConfigurationProperties(prefix = "crossref")
data class CrossRefServiceProperties(val endpoint: String?, val username: String?, val password: String?)
data class CrossRefServiceProperties(
val endpoint: String?,
val username: String?,
val password: String?,
val doiPrefix: String?,
)

@Service
class CrossRefService(private val crossRefServiceProperties: CrossRefServiceProperties) {
val isActive = crossRefServiceProperties.endpoint != null &&
crossRefServiceProperties.username != null &&
crossRefServiceProperties.password != null
crossRefServiceProperties.password != null &&
crossRefServiceProperties.doiPrefix != null
val dateTimeFormatterMM = DateTimeFormatter.ofPattern("MM")
val dateTimeFormatterdd = DateTimeFormatter.ofPattern("dd")
val dateTimeFormatteryyyy = DateTimeFormatter.ofPattern("yyyy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.loculus.backend.auth.AuthenticatedUser
import org.loculus.backend.config.BackendConfig
import org.loculus.backend.controller.NotFoundException
import org.loculus.backend.controller.UnprocessableEntityException
import org.loculus.backend.service.crossref.CrossRefServiceProperties
import org.loculus.backend.service.submission.AccessionPreconditionValidator
import org.loculus.backend.utils.getNextSequenceNumber
import org.springframework.stereotype.Service
Expand All @@ -47,6 +48,7 @@ private val log = KotlinLogging.logger { }
class SeqSetCitationsDatabaseService(
private val accessionPreconditionValidator: AccessionPreconditionValidator,
private val backendConfig: BackendConfig,
private val crossRefServiceProperties: CrossRefServiceProperties,
pool: DataSource,
) {
init {
Expand Down Expand Up @@ -333,7 +335,8 @@ class SeqSetCitationsDatabaseService(

validateCreateSeqSetDOI(username, seqSetId, version)

val seqSetDOI = "${SeqSetCitationsConstants.DOI_PREFIX}/$seqSetId.$version"
val doiPrefix = crossRefServiceProperties.doiPrefix ?: "no-prefix-configured"
val seqSetDOI = "$doiPrefix/$seqSetId.$version"

SeqSetsTable.update(
{
Expand Down
1 change: 1 addition & 0 deletions backend/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ loculus.config.path=src/test/resources/backend_config.json
crossref.endpoint=dummy
crossref.username=dummy
crossref.password=dummy
crossref.doi-prefix=placeholder

keycloak.user=dummy
keycloak.password=dummy
Expand Down
17 changes: 8 additions & 9 deletions kubernetes/loculus/templates/loculus-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ spec:
- containerPort: 8079
args:
- "--crossref.doi-prefix=$(CROSSREF_DOI_PREFIX)"
- "--crossref.endpoint=$(CROSSREF_TEST_ENDPOINT)"
- "--crossref.endpoint=$(CROSSREF_ENDPOINT)"
- "--crossref.username=$(CROSSREF_USERNAME)"
- "--crossref.password=$(CROSSREF_TEST_PASSWORD)"
- "--crossref.password=$(CROSSREF_PASSWORD)"
- "--keycloak.password=$(BACKEND_KEYCLOAK_PASSWORD)"
- "--keycloak.realm=loculus"
- "--keycloak.client=backend-client"
Expand All @@ -71,16 +71,15 @@ spec:
secretKeyRef:
name: crossref
key: username
- name: CROSSREF_TEST_PASSWORD
- name: CROSSREF_PASSWORD
valueFrom:
secretKeyRef:
name: crossref
key: testPassword
- name: CROSSREF_LIVE_PASSWORD
valueFrom:
secretKeyRef:
name: crossref
key: livePassword
key: password
- name: CROSSREF_DOI_PREFIX
value: {{$.Values.crossRef.DOIPrefix | quote }}
- name: CROSSREF_ENDPOINT
value: {{$.Values.crossRef.endpoint | quote }}
{{- end }}
- name: BACKEND_KEYCLOAK_PASSWORD
valueFrom:
Expand Down
6 changes: 2 additions & 4 deletions kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
environment: server
crossRef:
DOIPrefix: "10.62599"
testEndpoint: "https://test.crossref.org"
liveEndpoint: "https://doi.crossref.org"
endpoint: "https://test.crossref.org"
disableWebsite: false
disableBackend: false
disablePreprocessing: false
Expand Down Expand Up @@ -1482,8 +1481,7 @@ secrets:
type: raw
data:
username: "dummy"
testPassword: "dummy"
livePassword: "dummy"
password: "dummy"
service-accounts:
type: autogen
data:
Expand Down

0 comments on commit dadd17b

Please sign in to comment.