Skip to content
Merged
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
8 changes: 4 additions & 4 deletions hepdata/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from hepdata.modules.submission.models import HEPSubmission
from hepdata.modules.submission.api import get_latest_hepsubmission
from .factory import create_app
from hepdata.config import CFG_PUB_TYPE
from hepdata.config import CFG_PUB_TYPE, ANALYSES_ENDPOINTS
from hepdata.ext.opensearch.api import reindex_all, get_records_matching_field
from hepdata.modules.records.importer import api as importer_api
from hepdata.modules.records.utils import data_files
Expand All @@ -55,7 +55,7 @@
cli = create_cli(create_app=create_app)

default_recids = 'ins1283842,ins1245023,ins1311487'

endpoints_as_string = '"' + '" or "'.join(ANALYSES_ENDPOINTS.keys()) + '"'

@cli.group()
def importer():
Expand Down Expand Up @@ -223,9 +223,9 @@ def do_unload(records_to_unload):

@utils.command()
@with_appcontext
@click.option('--endpoint', '-e', type=str, help='Specific endpoint to update (e.g. "rivet" or "MadAnalysis" or "SModelS" or "CheckMATE" or "HackAnalysis" or "Combine"). Omit for all.')
@click.option('--endpoint', '-e', type=str, help=f'Specific endpoint to update (e.g. {endpoints_as_string}). Omit for all.')
def find_and_add_record_analyses(endpoint):
"""Finds analyses such as Rivet, MadAnalysis 5, SModelS, CheckMATE, HackAnalysis and Combine and adds them to records."""
"""Finds analyses from tools such as Rivet, MadAnalysis 5, etc. and adds them to records."""
update_analyses(endpoint)


Expand Down
3 changes: 3 additions & 0 deletions hepdata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ def _(x):
'url': 'https://creativecommons.org/licenses/by/4.0'
},
},
'GAMBIT': {
'endpoint_url': 'https://gambitbsm.org/analyses.json',
},
Comment thread
mhabedan marked this conversation as resolved.
#'ufo': {},
#'xfitter': {},
#'applgrid': {},
Expand Down
2 changes: 1 addition & 1 deletion hepdata/ext/opensearch/document_enhancers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def add_shortened_authors(doc):

def add_analyses(doc):
"""
Add analyses links such as Rivet, MadAnalysis 5, SModelS, CheckMATE, HackAnalysis, Combine, HistFactory and NUISANCE to the index.
Add analyses links to tools such as Rivet, MadAnalysis 5, etc. to the index.

:param doc:
:return:
Expand Down
1 change: 1 addition & 0 deletions hepdata/modules/records/assets/js/hepdata_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ HEPDATA.file_type_to_details = {
"checkmate": {"icon": "area-chart", "description": "CheckMATE Analysis"},
"hackanalysis": {"icon": "area-chart", "description": "HackAnalysis Analysis"},
"combine": {"icon": "area-chart", "description": "Combine Analysis"},
"gambit": {"icon": "area-chart", "description": "GAMBIT analysis"},
"xfitter": {"icon": "area-chart", "description": "xFitter Analysis"},
"applgrid": {"icon": "area-chart", "description": "APPLgrid Analysis"},
"ufo": {"icon": "rocket", "description": "Universal Feynrules Output (UFO)"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ <h4>Add Resource for <span id="selected_resource_item">Submission</span></h4>
<select name="analysisType" id="analysisType" class="form-control">
<option disabled>Analyses</option>
<option value="applgrid">APPLgrid</option>
<option value="MadAnalysis">MadAnalysis 5</option>
<option value="SModelS">SModelS</option>
<option value="CheckMATE">CheckMATE</option>
<option value="HackAnalysis">HackAnalysis</option>
<option value="Combine">Combine</option>
<option value="rivet">Rivet</option>
<option value="fastnlo">fastNLO</option>
<option value="ufo">Universal Feynrules Output (UFO)</option>
<option value="xfitter">xFitter</option>
Expand Down
14 changes: 8 additions & 6 deletions hepdata/modules/records/utils/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from celery import shared_task
from flask import current_app
from invenio_db import db
import requests
from hepdata.resilient_requests import resilient_requests
import json
import jsonschema

Expand All @@ -52,11 +52,11 @@ def test_analyses_schema(json_file, schema_version="1.0.0"):
@shared_task
def update_analyses(endpoint=None):
"""
Update (Rivet, MadAnalysis 5, SModelS, CheckMATE, HackAnalysis and Combine) analyses and remove outdated resources.
Update tools (Rivet, MadAnalysis 5, etc.) analyses and remove outdated resources.
Allow bulk subscription to record update notifications if "subscribe_user_id" in endpoint.
Add optional "description" and "license" fields if present in endpoint.

:param endpoint: either "rivet" or "MadAnalysis" or "SModelS" or "CheckMATE" or "HackAnalysis" or "Combine" or None (default) for all
:param endpoint: any one from config.ANALYSES_ENDPOINTS ("rivet", "MadAnalysis", etc.) or None (default) for all
"""

endpoints = current_app.config["ANALYSES_ENDPOINTS"]
Expand All @@ -69,9 +69,9 @@ def update_analyses(endpoint=None):

log.info("Updating analyses from {0}...".format(analysis_endpoint))

response = requests.get(endpoints[analysis_endpoint]["endpoint_url"])
response = resilient_requests('get', endpoints[analysis_endpoint]["endpoint_url"])

if response and response.status_code == 200:
if response.ok:

analysis_resources = DataResource.query.filter_by(file_type=analysis_endpoint).all()

Expand Down Expand Up @@ -244,6 +244,8 @@ def update_analyses(endpoint=None):
if submission and not is_current_user_subscribed_to_record(submission.publication_recid, user):
subscribe(submission.publication_recid, user)

else: # if not response.ok
log.error(f"Error accessing {endpoints[analysis_endpoint]['endpoint_url']}")

else:
else: # if "endpoint_url" not in endpoints[analysis_endpoint]
log.debug("No endpoint_url configured for {0}".format(analysis_endpoint))
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ <h4>Other useful searches</h4>
(CMS statistical models in Combine format)
</span>
</li>
<li>
<a href='/search?q=analysis:GAMBIT&sort_by=latest'
target="_new">analysis:GAMBIT</a>
<span class="text-muted">
(GAMBIT analysis)
</span>
</li>
<li>
<a href='/search?q=analysis:HistFactory&sort_by=latest'
target="_new">analysis:HistFactory</a>
Expand Down
2 changes: 1 addition & 1 deletion hepdata/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
and parsed by ``setup.py``.
"""

__version__ = "0.9.4dev20250905"
__version__ = "0.9.4dev20250912"
16 changes: 14 additions & 2 deletions tests/records_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def test_create_breadcrumb_text():


def test_update_analyses(app):
""" Test update of Rivet, MadAnalyses 5, SModelS, CheckMATE, HackAnalysis and Combine analyses """
""" Test update of Rivet, MadAnalyses 5, etc. analyses """

# Import a record that already has a Rivet analysis attached (but with '#' in the URL)
import_records(['ins1203852'], synchronous=True)
Expand Down Expand Up @@ -1131,14 +1131,26 @@ def test_update_analyses(app):
assert license_data.name == 'cc-by-4.0'
assert license_data.url == 'https://creativecommons.org/licenses/by/4.0'

# ins1847779 also has a GAMBIT analysis, so don't need to import another record
analysis_resources = DataResource.query.filter_by(file_type='GAMBIT').all()
assert len(analysis_resources) == 0
update_analyses('GAMBIT')
analysis_resources = DataResource.query.filter_by(file_type='GAMBIT').all()
assert len(analysis_resources) == 1
assert analysis_resources[0].file_location == 'https://github.com/GambitBSM/gambit_2.6/blob/release_2.6/ColliderBit/src/analyses/Analysis_ATLAS_13TeV_MONOJET_139infb.cpp'
Comment thread
mhabedan marked this conversation as resolved.

# Call update_analysis using an endpoint with no endpoint_url
current_app.config["ANALYSES_ENDPOINTS"]["TestAnalysis"] = {}
update_analyses('TestAnalysis')

# Call update_analyses using an endpoint_url that will fail validation.
# Call update_analyses using an endpoint_url that will fail validation
current_app.config["ANALYSES_ENDPOINTS"]["TestAnalysis"]['endpoint_url'] = 'https://www.hepdata.net/search/?format=json&size=1'
update_analyses('TestAnalysis')
Comment thread
GraemeWatt marked this conversation as resolved.

# Call update_analyses using an invalid endpoint_URL
current_app.config["ANALYSES_ENDPOINTS"]["TestAnalysis"]['endpoint_url'] = 'https://www.hepdata.net/analyses.json'
update_analyses('TestAnalysis')


def test_generate_license_data_by_id(app):
"""
Expand Down