Skip to content

Commit

Permalink
Merge branch 'main' into add-analyses-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ItIsJordan committed Dec 9, 2024
2 parents 46d38ec + d1ba472 commit 145013b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 12 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" or "SModelS"). Omit for all.')
@click.option('--endpoint', '-e', type=str, help='Specific endpoint to update (e.g. "rivet" or "MadAnalysis" or "SModelS" or "Combine"). Omit for all.')
def find_and_add_record_analyses(endpoint):
"""Finds analyses such as Rivet, MadAnalysis 5 and SModelS and adds them to records."""
"""Finds analyses such as Rivet, MadAnalysis 5, SModelS and Combine and adds them to records."""
update_analyses(endpoint)


Expand Down
11 changes: 10 additions & 1 deletion hepdata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,16 @@ def _(x):
'endpoint_url': 'https://zenodo.org/records/13952092/files/smodels-analyses.hepdata.json?download=1',
'url_template': '{0}',
'subscribe_user_id': 7766
}
},
'Combine': {
'endpoint_url': 'https://cms-public-likelihoods-list.web.cern.ch/artifacts/output.json',
'url_template': 'https://doi.org/{0}',
'description': 'Statistical models',
'license': {
'name': 'cc-by-4.0',
'url': 'https://creativecommons.org/licenses/by/4.0'
},
},
#'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, HistFactory and NUISANCE to the index.
Add analyses links such as Rivet, MadAnalysis 5, SModelS, Combine, 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 @@ -46,6 +46,7 @@ HEPDATA.file_type_to_details = {
"rivet": {"icon": "area-chart", "description": "Rivet Analysis"},
"madanalysis": {"icon": "area-chart", "description": "MadAnalysis 5 Analysis"},
"smodels": {"icon": "area-chart", "description": "SModelS Analysis"},
"combine": {"icon": "area-chart", "description": "Combine 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 @@ -41,6 +41,7 @@ <h4>Add Resource for <span id="selected_resource_item">Submission</span></h4>
<option value="applgrid">APPLgrid</option>
<option value="MadAnalysis">MadAnalysis 5</option>
<option value="SModelS">SModelS</option>
<option value="Combine">Combine</option>
<option value="rivet">Rivet</option>
<option value="fastnlo">fastNLO</option>
<option value="ufo">Universal Feynrules Output (UFO)</option>
Expand Down
13 changes: 11 additions & 2 deletions hepdata/modules/records/utils/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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
from hepdata.modules.records.utils.common import get_license

logging.basicConfig()
log = logging.getLogger(__name__)
Expand All @@ -43,10 +44,11 @@
@shared_task
def update_analyses(endpoint=None):
"""
Update (Rivet, MadAnalysis 5 and SModelS) analyses and remove outdated resources.
Update (Rivet, MadAnalysis 5, SModelS and Combine) 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 None (default) for both
:param endpoint: either "rivet" or "MadAnalysis" or "SModelS" or "Combine" or None (default) for both
"""
endpoints = current_app.config["ANALYSES_ENDPOINTS"]
for analysis_endpoint in endpoints:
Expand Down Expand Up @@ -86,6 +88,13 @@ def update_analyses(endpoint=None):
file_location=_resource_url,
file_type=analysis_endpoint)

if "description" in endpoints[analysis_endpoint]:
new_resource.file_description = str(endpoints[analysis_endpoint]["description"])

if "license" in endpoints[analysis_endpoint]:
resource_license = get_license(endpoints[analysis_endpoint]["license"])
new_resource.file_license = resource_license.id

submission.resources.append(new_resource)
num_new_resources += 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ <h4>Other useful searches</h4>
(SModelS analysis)
</span>
</li>
<li>
<a href='/search?q=analysis:Combine&sort_by=latest'
target="_new">analysis:Combine</a>
<span class="text-muted">
(CMS statistical models in Combine format)
</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.4dev20241112"
__version__ = "0.9.4dev20241204"
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
beautifulsoup4==4.12.3
bleach==6.2.0
datacite==1.1.4
datacite==1.2.0
gunicorn==23.0.0
hepdata-converter-ws-client==0.2.2
hepdata-validator==0.3.5
invenio-access==2.0.0 # Indirect (needed by invenio-admin)
invenio-accounts==5.1.3
invenio-access==3.0.1 # Indirect (needed by invenio-admin)
invenio-accounts==5.1.7
invenio-admin==1.5.1
invenio-assets==3.0.3
invenio-config==1.0.4
invenio-db[postgresql]==1.1.5
invenio-logging[sentry_sdk]==2.1.1
invenio-oauthclient==4.0.2
invenio-pidstore==1.3.1
invenio-records==2.3.0
invenio-records==2.4.1
invenio-search[opensearch2]==2.4.1
invenio-theme==3.4.3
invenio-userprofiles==3.0.0
Expand Down
19 changes: 18 additions & 1 deletion tests/records_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def test_create_breadcrumb_text():


def test_update_analyses(app):
""" Test update of Rivet, MadAnalyses 5 and SModelS analyses """
""" Test update of Rivet, MadAnalyses 5, SModelS and Combine 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 @@ -1074,6 +1074,23 @@ def test_update_analyses(app):
submission = get_latest_hepsubmission(inspire_id='1847779', overall_status='finished')
assert is_current_user_subscribed_to_record(submission.publication_recid, user)

# Import a record that has an associated Combine analysis
import_records(['ins2796231'], synchronous=True)
analysis_resources = DataResource.query.filter_by(file_type='Combine').all()
assert len(analysis_resources) == 0
analysis_resources = DataResource.query.filter_by(file_location='https://doi.org/10.17181/bp9fx-6qs64').all()
assert len(analysis_resources) == 1
db.session.delete(analysis_resources[0]) # delete resource so it can be re-added in next step
db.session.commit()
update_analyses('Combine')
analysis_resources = DataResource.query.filter_by(file_type='Combine').all()
assert len(analysis_resources) == 1
assert analysis_resources[0].file_location == 'https://doi.org/10.17181/bp9fx-6qs64'
assert analysis_resources[0].file_description == 'Statistical models'
license_data = License.query.filter_by(id=analysis_resources[0].file_license).first()
assert license_data.name == 'cc-by-4.0'
assert license_data.url == 'https://creativecommons.org/licenses/by/4.0'


def test_generate_license_data_by_id(app):
"""
Expand Down

0 comments on commit 145013b

Please sign in to comment.