Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(excel2resources, excel2properties): cover all cases (DEV-1040) #201

Merged
merged 28 commits into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
78f2a3f
fix bugs
jnussbaum Jun 15, 2022
fee1074
PR-title: allow commas and numbers in scope
jnussbaum Jun 15, 2022
ae8cd88
fix DeprecationWarning: The metaschema specified by $schema was not f…
jnussbaum Jun 16, 2022
f9eac36
allow multiple superclasses for properties
jnussbaum Jun 16, 2022
397cdd7
remove old entry from MANIFEST.in (forgotten in an older PR)
jnussbaum Jun 16, 2022
93eb58f
- cover more cases in the test data
jnussbaum Jun 16, 2022
5d8b6da
replace the too generic "Exception" by "ValueError"
jnussbaum Jun 16, 2022
a1fe43a
improve checks if row is non-empty
jnussbaum Jun 20, 2022
e0249db
unittests: check contents of outfile, not only if it exists
jnussbaum Jun 20, 2022
606a921
add Romansh to docs, testdata, and templates
jnussbaum Jun 20, 2022
44b951a
move pandas from dev-packages to packages
jnussbaum Jun 20, 2022
6bfeb1b
include äöü
jnussbaum Jun 20, 2022
66fb7fc
Merge branch 'main' into wip/dev-1040-improve-excel2resources-excel2p…
jnussbaum Jun 20, 2022
12985de
improve docs
jnussbaum Jun 21, 2022
6bb6917
refactor tests
jnussbaum Jun 21, 2022
a2553cb
remove superfluous e2e tests
jnussbaum Jun 21, 2022
2579d1c
improve test data
jnussbaum Jun 21, 2022
82c1708
use pandas instead of openpyxl
jnussbaum Jun 21, 2022
b8a71c7
move pandas from dev-packages to packages (also in requirements.txt a…
jnussbaum Jun 21, 2022
4fc05ab
reduce number of code smells
jnussbaum Jun 21, 2022
9364036
apply reviewer's feedback
jnussbaum Jun 21, 2022
2512729
harmonize single quotes/double quotes
jnussbaum Jun 21, 2022
998909f
break too long lines
jnussbaum Jun 21, 2022
5443d61
prevent empty labels or comments
jnussbaum Jun 22, 2022
8e4ca89
shorten testdata files
jnussbaum Jun 22, 2022
cb3933c
add a unit test
jnussbaum Jun 23, 2022
aa25c88
reduce number of code smells
jnussbaum Jun 23, 2022
8b77cce
- restore test_excel_to_json_resources() and test_excel_to_json_prop…
jnussbaum Jun 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -12,7 +12,7 @@ jobs:
# check PR title
- uses: deepakputhraya/action-pr-title@master
with:
regex: '([a-z])+(\(([a-z\-_ ])+\))?!?: [a-z]([a-zA-Z-\.\d \(\)\[\]#_,])+$' # Regex the title should match.
regex: '([a-z])+(\(([0-9a-z\-_, ])+\))?!?: [a-z]([a-zA-Z-\.\d \(\)\[\]#_,])+$' # Regex the title should match.
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
allowed_prefixes: "fix,refactor,feat,docs,chore,style,test" # title should start with the given prefix
disallowed_prefixes: "feature,hotfix" # title should not start with the given prefix
prefix_case_sensitive: true # title prefix are case insensitive
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Expand Up @@ -4,4 +4,3 @@ include knora/dsplib/schemas/lists-only.json
include knora/dsplib/schemas/resources-only.json
include knora/dsplib/schemas/properties-only.json
include knora/dsplib/schemas/data.xsd
include knora/dsplib/utils/language-codes-3b2_csv.csv
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -17,6 +17,7 @@ pystrict = "*"
openpyxl = "*"
pyparsing = "==2.4.7"
networkx = "*"
pandas = "*"

[dev-packages]
mkdocs = "*"
Expand All @@ -28,7 +29,6 @@ setuptools = "*"
wheel = "*"
pipenv-setup = "*"
pytest = "*"
pandas = "*"

[requires]
python_version = "3.9"
150 changes: 79 additions & 71 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions dev-requirements.txt
Expand Up @@ -23,10 +23,8 @@ mkdocs-material~=8.3.6
mkdocs-material-extensions~=1.0.3
mypy~=0.961
mypy-extensions~=0.4.3
numpy~=1.22.4
orderedmultidict~=1.0.1
packaging~=20.9
pandas~=1.4.2
pep517~=0.12.0
pip~=22.1.2
pip-shims~=0.7.0
Expand All @@ -42,12 +40,11 @@ pymdown-extensions~=9.5
pyparsing~=2.4.7
pytest~=7.1.2
python-dateutil~=2.8.2
pytz~=2022.1
pyyaml~=6.0
pyyaml-env-tag~=0.1
requests~=2.28.0
requirementslib~=1.6.4
setuptools~=62.4.0
setuptools~=62.6.0
six~=1.16.0
toml~=0.10.2
tomli~=2.0.1
Expand Down
Binary file modified docs/assets/images/img-properties-example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/img-resources-example-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/templates/properties_template.xlsx
Binary file not shown.
Binary file modified docs/assets/templates/resources_template.xlsx
Binary file not shown.
35 changes: 19 additions & 16 deletions docs/dsp-tools-excel.md
Expand Up @@ -20,25 +20,25 @@ The expected worksheets of the Excel file are:
- `classes`: a table with all resource classes intended to be used in the resulting JSON
- `class1`, `class2`,...: a table for each resource class named after its name

The Excel sheet must have the following structure.

The worksheet called `classes` has the following structure:
The worksheet called `classes` must have the following structure:
![img-resources-example-1.png](assets/images/img-resources-example-1.png)

The expected columns are:

- `name` : The name of the resource
- `en`, `de`, `fr`, `it` : The labels of the resource in different languages, at least one language has to be provided
- `comment_en`, `comment_de`, `comment_fr`, `comment_it`: optional comments in the respective language
- `super` : The base class of the resource
- `name` (mandatory): The name of the resource
- `en`, `de`, `fr`, `it`, `rm`: The labels of the resource in different languages, at least one language has to be provided
- `comment_en`, `comment_de`, `comment_fr`, `comment_it`, `comment_rm` (optional): comments in the respective language
- `super` (mandatory): The base class(es) of the resource, separated by commas

The optional columns may be omitted in the Excel.

All other worksheets, one for each resource class, have the following structure:
![img-resources-example-2.png](assets/images/img-resources-example-2.png){ width=50% }

The expected columns are:

- `Property` : The name of the property
- `Cardinality` : The cardinality, one of: `1`, `0-1`, `1-n`, `0-n`
- `Property` (mandatory): The name of the property
- `Cardinality` (mandatory): The cardinality, one of: `1`, `0-1`, `1-n`, `0-n`

The GUI order is given by the order in which the properties are listed in the Excel sheet.

Expand All @@ -58,15 +58,18 @@ The Excel sheet must have the following structure:

The expected columns are:

- `name` : The name of the property
- `super` : The base property of the property
- `object` : If the property is derived from `hasValue`, the type of the property must be further specified by the
- `name` (mandatory): The name of the property
- `super` (mandatory): The base property/ies of the property, separated by commas
- `object` (mandatory): If the property is derived from `hasValue`, the type of the property must be further specified by the
object it takes, e.g. `TextValue`, `ListValue`, or `IntValue`. If the property is derived from `hasLinkTo`,
the `object` specifies the resource class that this property refers to.
- `en`, `de`, `fr`, `it` : The labels of the property in different languages, at least one language has to be provided
- `comment_en`, `comment_de`, `comment_fr`, `comment_it`: optional comments in the respective language
- `gui_element` : The GUI element for the property
- `hlist` : In case of list values: the name of the list
- `en`, `de`, `fr`, `it`, `rm`: The labels of the property in different languages, at least one language has to be provided
- `comment_en`, `comment_de`, `comment_fr`, `comment_it`, `comment_rm` (optional): comments in the respective language
- `gui_element` (mandatory): The GUI element for the property
- `gui_attributes` (optional): The gui_attributes in the form "attr: value, attr: value".

The optional columns may be omitted in the Excel.
For backwards compatibility, files containing a column `hlist` are valid, but deprecated.

For further information about properties, see [here](./dsp-tools-create-ontologies.md#properties).

Expand Down
2 changes: 1 addition & 1 deletion knora/dsplib/schemas/lists-only.json
@@ -1,5 +1,5 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
"$id": "https://dasch.swiss/schema/lists.json",
"title": "JSON schema for DSP lists",
"description": "JSON schema for the lists section used in DSP ontologies",
Expand Down
2 changes: 1 addition & 1 deletion knora/dsplib/schemas/ontology.json
@@ -1,5 +1,5 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://dasch.swiss/schema/ontology.json",
"title": "JSON schema for DSP ontologies",
"description": "JSON schema for DSP ontologies",
Expand Down
3 changes: 2 additions & 1 deletion knora/dsplib/schemas/properties-only.json
@@ -1,5 +1,5 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://dasch.swiss/schema/properties-only.json",
"title": "JSON schema for properties used in DSP ontologies",
"description": "JSON schema for the properties section used in DSP ontologies",
Expand Down Expand Up @@ -82,6 +82,7 @@
"ListValue",
"Region",
"Resource",
"Representation",
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
"Annotation"
]
},
Expand Down
2 changes: 1 addition & 1 deletion knora/dsplib/schemas/resources-only.json
@@ -1,5 +1,5 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://dasch.swiss/schema/resources-only.json",
"title": "JSON schema for resources used in DSP ontologies",
"description": "JSON schema for the resources section used in DSP ontologies",
Expand Down