Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .kargo-render/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sourceCommit: 05299924ac8e38f2deef61026000c57af77088c8
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/component: job
name: hep-script-add-to-fermilab-collection
spec:
jobTemplate:
metadata:
labels:
app.kubernetes.io/component: job
spec:
completionMode: Indexed
completions: 10
parallelism: 10
template:
metadata:
labels:
app.kubernetes.io/component: job
spec:
containers:
- args:
- shell
- /usr/local/src/script.py
command:
- inspirehep
env:
- name: SENTRY_ENVIRONMENT
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POSTGRESQL_HOST
value: inspire-qa-db-cluster-pooler-rw.inspire-qa.svc
- name: POSTGRESQL_PORT
value: "5432"
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: user
name: postgres-inspire-pguser-hep
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgres-inspire-pguser-hep
- name: JOB_COMPLETIONS
value: "10"
envFrom:
- configMapRef:
name: hep-defaults
- configMapRef:
name: hep-globals
- configMapRef:
name: hep-feature-flags
- secretRef:
name: hep-creds
image: registry.cern.ch/docker.io/inspirehep/hep
name: hep
volumeMounts:
- mountPath: /usr/local/var/instance/inspirehep_api.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /usr/local/var/instance/inspirehep.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /home/invenio
name: invenio-home
- mountPath: /usr/local/src/script.py
name: hep-script
subPath: script.py
restartPolicy: Never
volumes:
- configMap:
name: hep-cfg
name: hep-cfg
- emptyDir: {}
name: invenio-home
- configMap:
name: hep-script-add-to-fermilab-collection-ff8f9mmk6t
name: hep-script
schedule: '@yearly'
suspend: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
data:
script.py: |
from inspirehep.curation.search_check_do import SearchCheckDo


class AddToFermilabCollection(SearchCheckDo):
"""Add records with Fermilab report numbers to the Fermilab collection."""

query = "r FERMILAB* -_collections:Fermilab"

@staticmethod
def check(record, logger, state):
reports = record.get_value("report_numbers.value", [])
logger.info("Report numbers in record", reports=reports)
if "Fermilab" in record["_collections"]:
return False
return any(report.lower().startswith("fermilab") for report in reports)

@staticmethod
def do(record, logger, state):
record["_collections"].append("Fermilab")


AddToFermilabCollection()
kind: ConfigMap
metadata:
name: hep-script-add-to-fermilab-collection-ff8f9mmk6t
82 changes: 82 additions & 0 deletions curation-scripts/hep-script-amend-pbn-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/component: job
name: hep-script-amend-pbn
spec:
jobTemplate:
metadata:
labels:
app.kubernetes.io/component: job
spec:
completionMode: Indexed
completions: 10
parallelism: 10
template:
metadata:
labels:
app.kubernetes.io/component: job
spec:
containers:
- args:
- shell
- /usr/local/src/script.py
command:
- inspirehep
env:
- name: SENTRY_ENVIRONMENT
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POSTGRESQL_HOST
value: inspire-qa-db-cluster-pooler-rw.inspire-qa.svc
- name: POSTGRESQL_PORT
value: "5432"
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: user
name: postgres-inspire-pguser-hep
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgres-inspire-pguser-hep
- name: JOB_COMPLETIONS
value: "10"
envFrom:
- configMapRef:
name: hep-defaults
- configMapRef:
name: hep-globals
- configMapRef:
name: hep-feature-flags
- secretRef:
name: hep-creds
image: registry.cern.ch/docker.io/inspirehep/hep
name: hep
volumeMounts:
- mountPath: /usr/local/var/instance/inspirehep_api.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /usr/local/var/instance/inspirehep.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /home/invenio
name: invenio-home
- mountPath: /usr/local/src/script.py
name: hep-script
subPath: script.py
restartPolicy: Never
volumes:
- configMap:
name: hep-cfg
name: hep-cfg
- emptyDir: {}
name: invenio-home
- configMap:
name: hep-script-amend-pbn-f84mgc2959
name: hep-script
schedule: '@yearly'
suspend: true
44 changes: 44 additions & 0 deletions curation-scripts/hep-script-amend-pbn-f84mgc2959-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: v1
data:
script.py: |
from inspirehep.curation.search_check_do import SearchCheckDo

tag_info = ("parent_isbn", "9789811947506")

missing_info = {
"journal_title": "Springer Proc.Math.Stat.",
"journal_volume": "396",
"parent_record": {"$ref": "https://inspirehep.net/api/literature/2628642"},
}


class AmendPBN(SearchCheckDo):
"""Add missing info to PBNs with tag"""

query = "publication_info.%s:%s" % tag_info

@staticmethod
def check(record, logger, state):
# flag PBN containing tag info

state["pos_tag"] = []
for npbn, pbn in enumerate(record.get("publication_info", [])):
tag = pbn.get(tag_info[0], "")
if tag == tag_info[1]:
state["pos_tag"].append(npbn)
if state["pos_tag"]:
return True
return False

@staticmethod
def do(record, logger, state):
# append missing info

for npbn in state["pos_tag"]:
record["publication_info"][npbn].update(missing_info)


AmendPBN()
kind: ConfigMap
metadata:
name: hep-script-amend-pbn-f84mgc2959
82 changes: 82 additions & 0 deletions curation-scripts/hep-script-change-cnum-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/component: job
name: hep-script-change-cnum
spec:
jobTemplate:
metadata:
labels:
app.kubernetes.io/component: job
spec:
completionMode: Indexed
completions: 10
parallelism: 10
template:
metadata:
labels:
app.kubernetes.io/component: job
spec:
containers:
- args:
- shell
- /usr/local/src/script.py
command:
- inspirehep
env:
- name: SENTRY_ENVIRONMENT
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POSTGRESQL_HOST
value: inspire-qa-db-cluster-pooler-rw.inspire-qa.svc
- name: POSTGRESQL_PORT
value: "5432"
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: user
name: postgres-inspire-pguser-hep
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgres-inspire-pguser-hep
- name: JOB_COMPLETIONS
value: "10"
envFrom:
- configMapRef:
name: hep-defaults
- configMapRef:
name: hep-globals
- configMapRef:
name: hep-feature-flags
- secretRef:
name: hep-creds
image: registry.cern.ch/docker.io/inspirehep/hep
name: hep
volumeMounts:
- mountPath: /usr/local/var/instance/inspirehep_api.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /usr/local/var/instance/inspirehep.cfg
name: hep-cfg
subPath: inspirehep.cfg
- mountPath: /home/invenio
name: invenio-home
- mountPath: /usr/local/src/script.py
name: hep-script
subPath: script.py
restartPolicy: Never
volumes:
- configMap:
name: hep-cfg
name: hep-cfg
- emptyDir: {}
name: invenio-home
- configMap:
name: hep-script-change-cnum-th6km57527
name: hep-script
schedule: '@yearly'
suspend: true
43 changes: 43 additions & 0 deletions curation-scripts/hep-script-change-cnum-th6km57527-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: v1
data:
script.py: |
from inspirehep.curation.search_check_do import SearchCheckDo

wrong_cnum = "C20-05-18.1"
new_cnum = "C21-05-31"
new_conf_record = "https://inspirehep.net/api/conferences/1812458"


class ChangeCNUM(SearchCheckDo):
"""Wrong CNUM assigned - replace by correct information"""

query = "publication_info.cnum:%s" % wrong_cnum

@staticmethod
def check(record, logger, state):
# flag PBN with wrong CNUM

state["pos_cnum"] = []
for npbn, pbn in enumerate(record.get("publication_info", [])):
cnum = pbn.get("cnum", "")
if cnum == wrong_cnum:
state["pos_cnum"].append(npbn)
if state["pos_cnum"]:
return True
return False

@staticmethod
def do(record, logger, state):
# replace CNUM and conference record

for npbn in state["pos_cnum"]:
record["publication_info"][npbn]["cnum"] = new_cnum
record["publication_info"][npbn]["conference_record"] = (
"{'$ref': '%s'}" % new_conf_record
)


ChangeCNUM()
kind: ConfigMap
metadata:
name: hep-script-change-cnum-th6km57527
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
data:
script.py: |
from inspirehep.curation.search_check_do import SearchCheckDo


class ChangeInternalCDFCollection(SearchCheckDo):
"""Ensure all CDF Internal Notes are really private."""

query = '_collections:"CDF Internal Notes"'

@staticmethod
def check(record, logger, state):
return (
len(record["_collections"]) > 1
and "CDF Internal Notes" in record["_collections"]
)

@staticmethod
def do(record, logger, state):
record["_collections"] = ["CDF Internal Notes"]


ChangeInternalCDFCollection()
kind: ConfigMap
metadata:
name: hep-script-change-internal-cdf-collection-527b6845t2
Loading