Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend, deployment): fix seqsets so they can be configured to work in production #2476

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
theosanderson marked this conversation as resolved.
Show resolved Hide resolved
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,17 +20,27 @@ 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")

init {
println("heeelo2 $crossRefServiceProperties")
}

theosanderson marked this conversation as resolved.
Show resolved Hide resolved
private fun checkIsActive() {
if (!isActive) {
throw RuntimeException("The CrossRefService is not active as it has not been configured.")
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}}
- name: CROSSREF_ENDPOINT
value: {{$.Values.crossref.endpoint }}
{{- 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 @@ -1481,8 +1480,7 @@ secrets:
type: raw
data:
username: "dummy"
testPassword: "dummy"
livePassword: "dummy"
password: "dummy"
service-accounts:
type: autogen
data:
Expand Down
Loading