diff --git a/hepdata/cli.py b/hepdata/cli.py index 36b4d54f..43849f50 100644 --- a/hepdata/cli.py +++ b/hepdata/cli.py @@ -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) diff --git a/hepdata/config.py b/hepdata/config.py index 713693dd..c36c9eff 100644 --- a/hepdata/config.py +++ b/hepdata/config.py @@ -331,7 +331,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': {}, diff --git a/hepdata/ext/opensearch/document_enhancers.py b/hepdata/ext/opensearch/document_enhancers.py index 6ca9173a..f5554b8b 100644 --- a/hepdata/ext/opensearch/document_enhancers.py +++ b/hepdata/ext/opensearch/document_enhancers.py @@ -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: diff --git a/hepdata/modules/records/assets/js/hepdata_common.js b/hepdata/modules/records/assets/js/hepdata_common.js index a55d6963..0aec95fb 100644 --- a/hepdata/modules/records/assets/js/hepdata_common.js +++ b/hepdata/modules/records/assets/js/hepdata_common.js @@ -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)"}, diff --git a/hepdata/modules/records/templates/hepdata_records/components/resources-widget.html b/hepdata/modules/records/templates/hepdata_records/components/resources-widget.html index 17c295b5..328a5be1 100644 --- a/hepdata/modules/records/templates/hepdata_records/components/resources-widget.html +++ b/hepdata/modules/records/templates/hepdata_records/components/resources-widget.html @@ -41,6 +41,7 @@

Add Resource for Submission

+ diff --git a/hepdata/modules/records/utils/analyses.py b/hepdata/modules/records/utils/analyses.py index 35b4b730..5219e01a 100644 --- a/hepdata/modules/records/utils/analyses.py +++ b/hepdata/modules/records/utils/analyses.py @@ -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__) @@ -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: @@ -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 diff --git a/hepdata/modules/search/templates/hepdata_search/modals/search_help.html b/hepdata/modules/search/templates/hepdata_search/modals/search_help.html index 357661b1..88d5063b 100644 --- a/hepdata/modules/search/templates/hepdata_search/modals/search_help.html +++ b/hepdata/modules/search/templates/hepdata_search/modals/search_help.html @@ -243,6 +243,13 @@

Other useful searches

(SModelS analysis) +
  • + analysis:Combine + + (CMS statistical models in Combine format) + +
  • analysis:HistFactory diff --git a/hepdata/version.py b/hepdata/version.py index eeef8cfc..6be16374 100644 --- a/hepdata/version.py +++ b/hepdata/version.py @@ -28,4 +28,4 @@ and parsed by ``setup.py``. """ -__version__ = "0.9.4dev20241112" +__version__ = "0.9.4dev20241204" diff --git a/tests/records_test.py b/tests/records_test.py index 988f7692..2f6b4a14 100644 --- a/tests/records_test.py +++ b/tests/records_test.py @@ -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) @@ -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): """