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

Issue 2037: extend shaclgen.py to add the suffix "Shape" to the generated SHACL shape #2038

Merged
merged 10 commits into from
Apr 2, 2024

Conversation

robertschubert
Copy link
Contributor

@robertschubert robertschubert commented Mar 28, 2024

This PR implements the feature requested in #2037.

Fixes #2037

…ated SHACL shape.

Signed-off-by: schuberr <robert.schubert@msg.group>
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.68%. Comparing base (f5076a6) to head (46de5f1).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2038      +/-   ##
==========================================
+ Coverage   80.67%   80.68%   +0.01%     
==========================================
  Files         107      107              
  Lines       11921    11949      +28     
  Branches     3409     3417       +8     
==========================================
+ Hits         9617     9641      +24     
- Misses       1741     1743       +2     
- Partials      563      565       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…erage.

Signed-off-by: schuberr <robert.schubert@msg.group>
@cmungall
Copy link
Member

Can you make it such that appending Shape or any other suffix is opt-in and the default behavior remains the same?

@robertschubert
Copy link
Contributor Author

Can you make it such that appending Shape or any other suffix is opt-in and the default behavior remains the same?

I will try to find the mechanism to pass CLI parameters to the generator.

schuberr added 2 commits March 28, 2024 17:24
…rameter. Defaut: no suffix,

Signed-off-by: schuberr <robert.schubert@msg.group>
@robertschubert
Copy link
Contributor Author

robertschubert commented Mar 28, 2024

Hi @cmungall
thanks for your valuable feedback. I changed the implementation as you requested. The suffix is now a cli parameter and defaults to "".

But I am struggling with the checks:

  • The "build and test documentation" states: "/home/runner/work/linkml/linkml/docs/generators/shacl.rst:18: CRITICAL: Unexpected section title or transition."

    • There was no change in shacl.rst. The part where my changes come into the game is starting from the section "Command line" starting at line 87. You have a hint?
  • The "build and test linkml / test (ubuntu-latest," "3.9" and "3.10") seem to have an infrastructural problem.

    • They fail with "ModuleNotFoundError: No module named 'pyshacl'"
    • Other recent PRs seem to have the same problem with those three checks.
    • Do we need another issue to create?

Signed-off-by: schuberr <robert.schubert@msg.group>
@sneakers-the-rat
Copy link
Collaborator

super weird. checking on this because i was the one who proposed making pyshacl an extra dependency here: #1992

so the cached environment for 3.9 is from here: https://github.com/linkml/linkml/actions/runs/8445452327/job/23132690282
key: venv-3.9-Linux-2130111127bb0cfd765b175f385377faa156d7790932052a2ac8d8368c099e5b

pyshacl is installed: https://github.com/linkml/linkml/actions/runs/8445452327/job/23132690282#step:6:169

it does not seem to be removed in the subsequent call to install pydantic.

these runs restore the same cache key: https://github.com/linkml/linkml/actions/runs/8473903961/job/23219220620?pr=2038#step:5:17

but it seems to say "the venv is broken" - https://github.com/linkml/linkml/actions/runs/8473903961/job/23219220620?pr=2038#step:7:9

no idea what that means.

pretty sure the fix is to do poetry run pip install 'pydantic<2' (not sure if you need --force rather than poetry add because that attempts to re-solve the environment rather than modifying a single package, which is what we want.

@sneakers-the-rat
Copy link
Collaborator

invalidated the caches and it looks like tests are passing now. ya we probs want to change that pydantic install command (or move ahead with deprecating pydantic 1!!!)

schuberr added 2 commits March 29, 2024 10:41
Signed-off-by: schuberr <robert.schubert@msg.group>
Signed-off-by: schuberr <robert.schubert@msg.group>
@robertschubert
Copy link
Contributor Author

@sneakers-the-rat: Thanks for making the failing checks running! :)

@cmungall
Copy link
Member

cmungall commented Mar 29, 2024 via email

@robertschubert
Copy link
Contributor Author

robertschubert commented Mar 29, 2024

Thanks @cmungall and @sneakers-the-rat
no problem. I'm glad you're helping.
Must say I like this community here :)
Hope my PR helps. There is no breaking change now.

@robertschubert
Copy link
Contributor Author

I'm in easter holiday now for a week but I will of course have a look at the progress here. Could be that I am not able to respond early ;) have a good time!

@sneakers-the-rat
Copy link
Collaborator

figured it out - it was from having the empty string as the default and having "show default" set to True

can be resolved by removing show_default in the suffix click option or by making the default None

imo optional params should default to None so it's possible to tell when they aren't passed vs. when they should be filled with a default. so that would be something like

@click.option(
    "-s",
    "--suffix",
    help="Use --suffix to append given string to SHACL class name (e. g. --suffix Shape: Person becomes PersonShape).",
)

and then

if self.suffix is not None:
    class_url += suffix

but that's just a style thing i don't use shaclgen so up to you!!!!

schuberr added 3 commits April 2, 2024 20:41
Signed-off-by: schuberr <robert.schubert@msg.group>
Signed-off-by: schuberr <robert.schubert@msg.group>
Signed-off-by: schuberr <robert.schubert@msg.group>
@robertschubert
Copy link
Contributor Author

@sneakers-the-rat Thanks for the hint. Changed it and that step is fine now :)
After all checks are completed, I will set this PR to "ready".

@robertschubert robertschubert marked this pull request as ready for review April 2, 2024 19:14
@robertschubert
Copy link
Contributor Author

ready for final review

@cmungall cmungall merged commit 6ea755c into linkml:main Apr 2, 2024
17 checks passed
@paul121
Copy link

paul121 commented Apr 2, 2024

Thank you for adding this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Append "Shape" suffix to SHACL shape in shaclgen.py
4 participants