-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openalex: remove ci deployment, add job spec, better logging, add con…
…tact email to requests
- Loading branch information
Showing
9 changed files
with
108 additions
and
146 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#! /bin/env bash | ||
|
||
# build docker image and push to ECR | ||
set -euxo pipefail | ||
|
||
TAGNAME=openalex-importer | ||
|
||
docker build -t $TAGNAME . | ||
|
||
docker tag $TAGNAME:latest 523044037273.dkr.ecr.us-east-2.amazonaws.com/$TAGNAME:latest | ||
docker push 523044037273.dkr.ecr.us-east-2.amazonaws.com/$TAGNAME:latest | ||
|
||
# aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 523044037273.dkr.ecr.us-east-2.amazonaws.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: openalex-importer-service | ||
name: openalex-importer | ||
labels: | ||
App: OpenAlexImporter | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 2 | ||
selector: | ||
matchLabels: | ||
App: OpenAlexImporter | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 25% | ||
type: RollingUpdate | ||
# replicas: 1 | ||
# revisionHistoryLimit: 2 | ||
# selector: | ||
# matchLabels: | ||
# App: OpenAlexImporter | ||
# strategy: | ||
# type: Recreate | ||
template: | ||
metadata: | ||
annotations: | ||
vault.hashicorp.com/agent-inject: 'true' | ||
vault.hashicorp.com/agent-inject-status: 'update' | ||
vault.hashicorp.com/role: app-vault-reader | ||
vault.hashicorp.com/agent-inject-secret-config: secrets/openalex/db | ||
vault.hashicorp.com/agent-inject-secret-config: secrets/openalex-importer | ||
vault.hashicorp.com/agent-inject-template-config: | | ||
{{- with secret "secrets/desci-server/dev/repo" -}} | ||
echo "sourcing"; | ||
export OPENALEX_API_KEY={{ .Data.OPENALEX_API_KEY }} | ||
export NODE_ENV=production | ||
export DATABASE_URL={{ .Data.DATABASE_URL }} | ||
{{- end -}} | ||
{{- with secret "secrets/openalex-importer" -}} | ||
{{- range $k, $v := .Data }} | ||
export {{ $k }}={{ $v }} | ||
{{- end }} | ||
{{- end }} | ||
labels: | ||
App: OpenAlexImporter | ||
spec: | ||
# TODO: change before ultimately deploying | ||
restartPolicy: Never | ||
containers: | ||
- image: 523044037273.dkr.ecr.us-east-2.amazonaws.com/openalex-importer:latest | ||
name: openalex-importer | ||
# command: [ 'tail', '-f', '/dev/null' ] | ||
command: ['/bin/bash', '-c'] | ||
args: | ||
- echo "SOURCING ENV"; source /vault/secrets/config; NODE_PATH=./dist node ./dist/index.js; | ||
- echo "SOURCING ENV"; source /vault/secrets/config; node ./dist/index.js; | ||
env: | ||
- name: QUERY_TYPE | ||
value: "updated" | ||
- name: QUERY_FROM | ||
value: "2024-12-06" | ||
- name: QUERY_TO | ||
value: "2024-12-31" | ||
- name: NODE_OPTIONS | ||
value: "--enable-source-maps --max-semi-space-size=256" | ||
resources: | ||
limits: | ||
cpu: '2' | ||
memory: 16Gi | ||
memory: 4Gi | ||
requests: | ||
cpu: '1' | ||
memory: 8Gi | ||
cpu: '2' | ||
memory: 2Gi | ||
serviceAccountName: 'vault-auth' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ type Query = { | |
filter?: FilterParam; | ||
'per-page'?: number; | ||
cursor: string | undefined; | ||
mailto?: string | undefined; | ||
}; | ||
|
||
export type FilterParam = { | ||
|
@@ -52,6 +53,8 @@ export const getInitialWorksQuery = (filter: FilterParam): Query => ({ | |
filter, | ||
'per-page': 200, | ||
cursor: '*', | ||
// https://docs.openalex.org/how-to-use-the-api/rate-limits-and-authentication#the-polite-pool | ||
mailto: '[email protected]', | ||
}); | ||
|
||
export const fetchWorksPage = (searchQuery: Query) => fetchPage<Work>(WORKS_URL, searchQuery); | ||
|
@@ -61,7 +64,6 @@ export async function fetchPage<T>( | |
searchQuery: Query, | ||
): Promise<{ data: T[]; next_cursor: string | undefined }> { | ||
const query = buildQueryString(searchQuery); | ||
logger.info({ searchQuery }, 'Fetching page...'); | ||
const request = new Request(`${url}?${query}`, { | ||
headers: { 'API-KEY': process.env.OPENALEX_API_KEY as string }, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters