linkml / linkml

Linked Open Data Modeling Language
https://linkml.io/linkml
Other
312 stars 98 forks source link

gen-yuml `--format` does not work #522

Closed cmungall closed 1 year ago

cmungall commented 2 years ago

The output from gen-yuml is always a yuml string, regardless of --format option

sujaypatil96 commented 2 years ago

Running:

pipenv run gen-yuml --help

I can see -f, --format [yuml|png|pdf|jpg|json|svg] are the options we want to support. Do we want to support all of them?

cmungall commented 2 years ago

I don't know what json is intended to do!

It looks like this might be quite complicated to do with the yuml API. If it turns out too hard then simply remove all formats except yuml. The main point is to avoid false advertising.

@wdduncan you have used gen-yuml to make whole schema pngs in the past - do you recall how you did it?

wdduncan commented 2 years ago

@cmungall Not sure which script you are referring to, but here is a script that @deepakunni3 wrote to generate the uml diagram from the yaml:

import sys
import yaml
import requests
from linkml.generators.yumlgen import YumlGenerator

YAML_SPEC = sys.argv[1]
OUTPUT = sys.argv[2]

model = yaml.load(open(YAML_SPEC), Loader=yaml.FullLoader)
yuml = YumlGenerator(model).serialize()
yuml = yuml.replace('|', '|')
if not yuml.endswith('.svg'):
    # append the desired format
    yuml += '.svg'
myfile = requests.get(yuml)
open(OUTPUT, 'wb').write(myfile.content)

called like so:

python generate_uml_svg.py test_schema.yaml test_schema.svg
gaurav commented 2 years ago

This is the code that uses the format in yumlgen.py:

https://github.com/linkml/linkml/blob/36ba4b1df3377344603500affdc5ce2d2af92f8f/linkml/generators/yumlgen.py#L77-L78

It looks like yUML supports adding a file extension to a query to return the content in the specified format, i.e. https://yuml.me/c9ce39b0.json returns some metadata about the description used to create this yUML and https://yuml.me/c9ce39b0.png, https://yuml.me/c9ce39b0.pdf, https://yuml.me/c9ce39b0.jpg and https://yuml.me/c9ce39b0.svg return the yUML in the specified format.

Assuming this works for the cases where the URL includes the yUML class definition, I think it should be relatively easy to support all of the formats listed by Sujay.

cmungall commented 2 years ago

do you have the info you need @sujaypatil96 ?

deepakunni3 commented 2 years ago

And just a bit more context regarding the script referenced by @wdduncan - that script was written to generate an svg when the yuml query generated by yumlgen was not being encoded properly for the yuml.me endpoint. While this was an issue back in 2020, I think things ought to be pretty stable now with the yumlgen packaged with linkml.

sujaypatil96 commented 1 year ago

Current direction is gen-yuml is going to be deprecated in favour of mermaid diagrams that will be generated as part of gen-doc.

This issue will be closed as there will not be any active development on the issue, but please feel free to reopen if it's a priority.