From 443aad0575c5607cc7c29eaf66937033f544907d Mon Sep 17 00:00:00 2001 From: lambdamusic Date: Mon, 30 Dec 2024 16:47:48 +0000 Subject: [PATCH 1/4] typo --- dimcli/repl/repl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dimcli/repl/repl.py b/dimcli/repl/repl.py index e390c7e..78ad99e 100644 --- a/dimcli/repl/repl.py +++ b/dimcli/repl/repl.py @@ -56,7 +56,7 @@ >>> .export_as_html: save results from last query as HTML file. >>> .export_as_bar_chart: save results from last query as Plotly bar chart. >>> .export_as_jupyter: save results from last query as Jupyter notebook. ->>> .export_as_gsheets: save results from last query as Google Sheets (requires gpread credentials). +>>> .export_as_gsheets: save results from last query as Google Sheets (requires gspread credentials). >>> .show [optional: N]: print N results from last query, trying to build URLs for objects. Default N=10. >>> .json_compact: print results of last query as single-line JSON. >>> .json_full: print results of last query as formatted JSON. @@ -303,7 +303,8 @@ def run(instance="live"): click.secho(f"Using endpoint: {CLIENT._url} - DSL version: {_info}", dim=True) # history - session = PromptSession(history=SelectiveFileHistory(USER_HISTORY_FILE)) + session = PromptSession(history=SelectiveFileHistory(USER_HISTORY_FILE)) ### December 30, 2024 + # session = PromptSession() databuffer = DslResultsBuffer() From d2c3e7367473a66c5fae531815c33325cd2881a1 Mon Sep 17 00:00:00 2001 From: lambdamusic Date: Mon, 30 Dec 2024 16:48:15 +0000 Subject: [PATCH 2/4] fix missing history --- dimcli/repl/history.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dimcli/repl/history.py b/dimcli/repl/history.py index d043fea..75311dc 100644 --- a/dimcli/repl/history.py +++ b/dimcli/repl/history.py @@ -24,11 +24,10 @@ def __init__(self, filename): # print("HISTORY: ", filename) super(SelectiveFileHistory, self).__init__(filename) - def append_string(self, string): - " Add string to the history only if it is a valid DSL query" + def append_string(self, string: str) -> None: + "DIMCLI override: add string to the history only if it is a valid DSL query" l = G.allowed_starts_dsl_query() - for x in l: - if string.startswith(x): - self._loaded_strings.append(string) - self.store_string(string) - return \ No newline at end of file + if string.startswith(tuple(l)): + self._loaded_strings.insert(0, string) + self.store_string(string) + From ca5454fef4e198fcb62c5ae5bb63a91eb703405c Mon Sep 17 00:00:00 2001 From: lambdamusic Date: Mon, 30 Dec 2024 17:43:02 +0000 Subject: [PATCH 3/4] new DSL grammar --- dimcli/core/dsl_grammar_core.py | 60 ++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/dimcli/core/dsl_grammar_core.py b/dimcli/core/dsl_grammar_core.py index 3ae4eb8..8929af7 100644 --- a/dimcli/core/dsl_grammar_core.py +++ b/dimcli/core/dsl_grammar_core.py @@ -577,11 +577,11 @@ "fieldsets": ["basics", "extras", "categories", "studies"], "metrics": {"count": {"description": "Total count", "name": "count"}}, "search_fields": [ - "title_only", - "raw_affiliations", "full_data", + "title_only", "investigators", "title_abstract_only", + "raw_affiliations", ], }, "datasets": { @@ -875,7 +875,7 @@ "type": "string", }, "repository": { - "description": "Repository associtated with the dataset.", + "description": "Repository associated with the dataset.", "is_entity": True, "is_facet": True, "is_filter": True, @@ -958,7 +958,7 @@ }, "fieldsets": ["basics", "categories"], "metrics": {"count": {"description": "Total count", "name": "count"}}, - "search_fields": ["full_data", "title_only", "title_abstract_only"], + "search_fields": ["title_abstract_only", "title_only", "full_data"], }, "funder_groups": { "fields": { @@ -1005,6 +1005,15 @@ "long_description": None, "type": "string", }, + "active_status": { + "description": None, + "is_entity": False, + "is_facet": True, + "is_filter": True, + "is_multivalue": False, + "long_description": None, + "type": "string", + }, "active_year": { "description": "List of active years for a grant.", "is_entity": False, @@ -1428,6 +1437,15 @@ "long_description": None, "type": "states", }, + "research_org_types": { + "description": "Type of organisation to which investigators are affiliated. This field only contains information for organisations with GRID IDs.", + "is_entity": False, + "is_facet": True, + "is_filter": True, + "is_multivalue": False, + "long_description": None, + "type": "string", + }, "research_orgs": { "description": "GRID organisations receiving the grant (note: identifiers are automatically extracted from the source text and can be missing in some cases).", "is_entity": True, @@ -1493,11 +1511,11 @@ }, "search_fields": [ "concepts", - "title_only", - "raw_affiliations", "full_data", + "title_only", "investigators", "title_abstract_only", + "raw_affiliations", ], }, "organizations": { @@ -2207,7 +2225,7 @@ "is_entity": False, "is_facet": False, "is_filter": True, - "is_multivalue": False, + "is_multivalue": True, "long_description": None, "type": "json", }, @@ -2344,8 +2362,8 @@ "inventors", "title_only", "assignees", - "full_data", "title_abstract_only", + "full_data", ], }, "policy_documents": { @@ -2551,7 +2569,7 @@ }, "fieldsets": ["basics", "categories"], "metrics": {"count": {"description": "Total count", "name": "count"}}, - "search_fields": ["full_data", "title_only"], + "search_fields": ["title_only", "full_data"], }, "publications": { "fields": { @@ -2816,6 +2834,15 @@ "long_description": None, "type": "string", }, + "document_type": { + "description": "Document type prediction based on the content and metadata of a publication.", + "is_entity": False, + "is_facet": True, + "is_filter": True, + "is_multivalue": False, + "long_description": None, + "type": "string", + }, "doi": { "description": "Digital object identifier.", "is_entity": False, @@ -3095,6 +3122,15 @@ "long_description": None, "type": "string", }, + "research_org_types": { + "description": "Types of organisation associated with the publication. This field only contains information for organisations with GRID IDs.", + "is_entity": False, + "is_facet": True, + "is_filter": True, + "is_multivalue": True, + "long_description": None, + "type": "string", + }, "research_orgs": { "description": "GRID organisations associated to a publication. Identifiers are automatically extracted from author affiliations text, so they can be missing in some cases (note: this field supports :ref:`filter-functions`: ``count``).", "is_entity": True, @@ -3242,14 +3278,14 @@ }, "search_fields": [ "acknowledgements", - "authors", "concepts", "full_data_exact", - "full_data", "terms", "title_abstract_only", "raw_affiliations", + "authors", "title_only", + "full_data", ], }, "reports": { @@ -3617,7 +3653,7 @@ }, "fieldsets": ["basics", "categories"], "metrics": {"count": {"description": "Total count", "name": "count"}}, - "search_fields": ["full_data", "concepts", "title_abstract_only"], + "search_fields": ["concepts", "title_abstract_only", "full_data"], }, "research_org_groups": { "fields": { From 728b16323e9e26c30fe60d6c1cb86aeeaebe9181 Mon Sep 17 00:00:00 2001 From: lambdamusic Date: Mon, 30 Dec 2024 17:43:10 +0000 Subject: [PATCH 4/4] v 1.4 --- CHANGELOG.md | 9 +++++++-- dimcli/VERSION.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd1016..7e81017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,17 @@ # Changelog +## v 1.4 + +* Fix CLI [history bug](https://github.com/digital-science/dimcli/issues/80) +* Added DSL grammar for DSL [V2.10](https://docs.dimensions.ai/dsl/releasenotes.html#version-2-10-0-2024-april-week-of-29th) + ## v 1.3 * Function `extract_affiliations` return an extra column for unstructured data, with the input string. ## v 1.2 -* Added DSL grammar for DSL V2.8 +* Added DSL grammar for DSL [V2.8](https://docs.dimensions.ai/dsl/releasenotes.html#version-2-8-0-2023-september-week-of-25th) * New utility function: [utils.explode_nested_repeated_field](https://digital-science.github.io/dimcli/modules.html#dimcli.utils.misc_utils.explode_nested_repeated_field) ## v 1.1 @@ -29,7 +34,7 @@ ## v 0.9.9 * New parameters for [DslDataset.as_dataframe()](https://digital-science.github.io/dimcli/modules.html#dimcli.core.api.DslDataset.as_dataframe) -* Improvements to the `--nice` and `--links` rendering of dataframes with Dimesions data +* Improvements to the `--nice` and `--links` rendering of dataframes with Dimensions data - with hyperlinks, drop IDs if title is present - affiliations as a list with GRID links - generic 'default_transform' method for extra column not in transformations diff --git a/dimcli/VERSION.py b/dimcli/VERSION.py index a07d124..c3e5772 100644 --- a/dimcli/VERSION.py +++ b/dimcli/VERSION.py @@ -1,7 +1,7 @@ # !/usr/bin/env python # -*- coding: UTF-8 -*- -__version__ = "1.3" # LATEST? => https://pypi.org/project/dimcli/ +__version__ = "1.4" # LATEST? => https://pypi.org/project/dimcli/ __copyright__ = "CopyRight (C) 2018-2024 by Digital Science" __license__ = "MIT" __author__ = "Michele Pasin"