Skip to content

Commit

Permalink
global: add SModelS analyses and bulk subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeWatt committed Oct 31, 2024
1 parent 8dcf0c0 commit 98e46a0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hepdata/cli.py
Original file line number Diff line number Diff line change
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"). Omit for all.')
@click.option('--endpoint', '-e', type=str, help='Specific endpoint to update (e.g. "rivet" or "MadAnalysis" or "SModelS"). Omit for all.')
def find_and_add_record_analyses(endpoint):
"""Finds analyses such as Rivet and MadAnalysis 5 and adds them to records."""
"""Finds analyses such as Rivet, MadAnalysis 5 and SModelS and adds them to records."""
update_analyses(endpoint)


Expand Down
5 changes: 5 additions & 0 deletions hepdata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ def _(x):
'endpoint_url': 'https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/analyses.json',
'url_template': 'https://doi.org/{0}'
},
'SModelS': {
'endpoint_url': 'https://zenodo.org/records/13952092/files/smodels-analyses.hepdata.json?download=1',
'url_template': '{0}',
'subscribe_user_id': 7766
}
#'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, HistFactory and NUISANCE to the index.
Add analyses links such as Rivet, MadAnalysis 5, SModelS, HistFactory and NUISANCE 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 @@ -45,6 +45,7 @@ HEPDATA.file_type_to_details = {
"fastnlo": {"icon": "area-chart", "description": "fastNLO Analysis"},
"rivet": {"icon": "area-chart", "description": "Rivet Analysis"},
"madanalysis": {"icon": "area-chart", "description": "MadAnalysis 5 Analysis"},
"smodels": {"icon": "area-chart", "description": "SModelS 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 @@ -40,6 +40,7 @@ <h4>Add Resource for <span id="selected_resource_item">Submission</span></h4>
<option disabled>Analyses</option>
<option value="applgrid">APPLgrid</option>
<option value="MadAnalysis">MadAnalysis 5</option>
<option value="SModelS">SModelS</option>
<option value="rivet">Rivet</option>
<option value="fastnlo">fastNLO</option>
<option value="ufo">Universal Feynrules Output (UFO)</option>
Expand Down
17 changes: 15 additions & 2 deletions hepdata/modules/records/utils/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
from hepdata.ext.opensearch.api import index_record_ids
from hepdata.modules.submission.api import get_latest_hepsubmission, is_resource_added_to_submission
from hepdata.modules.submission.models import DataResource, HEPSubmission, data_reference_link
from hepdata.utils.users import get_user_from_id
from hepdata.modules.records.subscribers.rest import subscribe
from hepdata.modules.records.subscribers.api import is_current_user_subscribed_to_record

logging.basicConfig()
log = logging.getLogger(__name__)
Expand All @@ -40,9 +43,10 @@
@shared_task
def update_analyses(endpoint=None):
"""
Update (Rivet and MadAnalysis 5) analyses and remove outdated resources.
Update (Rivet, MadAnalysis 5 and SModelS) analyses and remove outdated resources.
Allow bulk subscription to record update notifications if "subscribe_user_id" in endpoint.
:param endpoint: either "Rivet" or "MadAnalysis" or None (default) for both
:param endpoint: either "rivet" or "MadAnalysis" or "SModelS" or None (default) for both
"""
endpoints = current_app.config["ANALYSES_ENDPOINTS"]
for analysis_endpoint in endpoints:
Expand Down Expand Up @@ -137,5 +141,14 @@ def update_analyses(endpoint=None):
db.session.rollback()
log.error(e)

# Allow bulk subscription to record update notifications.
if "subscribe_user_id" in endpoints[analysis_endpoint]:
user = get_user_from_id(endpoints[analysis_endpoint]["subscribe_user_id"])
if user:
for record in analyses:
submission = get_latest_hepsubmission(inspire_id=record, overall_status='finished')
if submission and not is_current_user_subscribed_to_record(submission.publication_recid, user):
subscribe(submission.publication_recid, user)

else:
log.debug("No endpoint url configured for {0}".format(analysis_endpoint))
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ <h4>Other useful searches</h4>
(MadAnalysis 5 analysis)
</span>
</li>
<li>
<a href='/search?q=analysis:SModelS&sort_by=latest'
target="_new">analysis:SModelS</a>
<span class="text-muted">
(SModelS 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.4dev20241003"
__version__ = "0.9.4dev20241031"

0 comments on commit 98e46a0

Please sign in to comment.