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

[feature] Only output the files that user requests #60

Closed
formatc1702 opened this issue Jul 4, 2020 · 7 comments
Closed

[feature] Only output the files that user requests #60

formatc1702 opened this issue Jul 4, 2020 · 7 comments
Assignees
Milestone

Comments

@formatc1702
Copy link
Collaborator

formatc1702 commented Jul 4, 2020

Currently, running WireViz generates multiple output files from the YAML input by default:

  • .png raster image
  • .svg vector image
  • .gv GraphViz code
  • .tsv BOM
  • .html page with embedded diagram and BOM (feature to be expanded, see # 32)

Especially the GraphViz code is probably not of much interest to the end user. The output() function in Harness.py should be updated to only actually generate the files the user needs.

A good default behavior should be set, ideally just with one file type to avoid cluttering the file system.

@aakatz3
Copy link
Contributor

aakatz3 commented Jul 21, 2020

I had looked into this before, and there are a couple of different ways this can be done, from refactoring the outputs to simple if-else statements. The Graphviz DOT file can be useful as it can be converted into something like a Visio document, but (and I have to check the code,) I think its generated due to how Graphviz processes the DOT file to generate conversions. Since it externally calls the dot executable, and the dot executable needs to read from disk (at least by default), I think we would have to just delete the file if the user does not request it, unless Graphviz and the python library for it support sending the info via named pipes.

@formatc1702
Copy link
Collaborator Author

formatc1702 commented Jul 22, 2020

Right now the .gv file is explicitly saved so that's easy to fix.

I'd say a couple of if statements, the possibility to specify what to output when running from command line:
$ python wireviz.py inputfile.yml -png -csv -html or similar
and setting good default behavior (my vote: generate PNG only so as not to generate clutter).

@slightlynybbled
Copy link
Contributor

If you are looking for a great library, check out click. Pure python and easy to maintain. No chained if statements. Have successfully used this on several internal CLI packages.

@formatc1702
Copy link
Collaborator Author

formatc1702 commented Jul 24, 2020

That looks quite interesting.

@slightlynybbled would you be interested in taking over this issue and rewriting the current CLI handling?

Currently, the --generate-bom an --output-file flags are unused and could be simplified as proposed below.

The usecases I envision:
wireviz inputfile.yml <- default behavior: output only PNG
wireviz inputfile.yml --prepend library.yml <- to include e.g. a library of templates/parts to reference in the inputfile *
wireviz inputfile.yml --output png svg gv csv tsv html pdf <- accept one or more options for output and generate the respective files. Some options (csv, pdf) are not yet implemented and could be filled with placeholders
wireviz --help <- is this augo-generated by click?

*[Note] prepending a file is already implemented, though poorly tested (by me, at least). It is a really useful option since YAML does not support including files by default. The idea is that one could curate a library of commonly used connectors and cables:

# this is library.yml
molex_kk254_female_4pin_from_library:
  type: KK 254
  subtype: female
  pincount: 4
  pn: xxx
  mpn: yyy
  manufacturer: Molex

and then include them in inputfile.yml like so:

# this is inputfile.yml
connectors:
  X1:
    <<: *molex_kk254_female_4pin_from_library # this will work since the --prepend'ed file will be appended before it goes through WireViz's YAML parser
    pinlabels: [GND, VCC, SCL, SDA]
    notes: Just edit any attributes that are not specified in the library, or need overriding

@kvid
Copy link
Collaborator

kvid commented Jul 24, 2020

Currently, running WireViz generates multiple output files from the YAML input by default:

.csv becomes a new BOM output format when #116 is merged in - probably quite soon, as it seems from the last comment #116 (comment).

A good default behavior should be set, ideally just with one file type to avoid cluttering the file system.

I suggest an --all option to output every possible format when the default becomes less than all formats.

@aakatz3
Copy link
Contributor

aakatz3 commented Jul 24, 2020

It would also be great if the YAML had the ability to specify the requested outputs.

@kvid
Copy link
Collaborator

kvid commented Jul 25, 2020

It would also be great if the YAML had the ability to specify the requested outputs.

I agree, but I would like to be able to override such YAML specifiers with the CLI, and in that case we would need to define how to handle conflicts: Should any CLI specifier presence make all YAML specifiers to be ignored, or should it happen specifier by specifier instead? In the latter case, negative specifiers (e.g. removing 'csv' if that was specified by the YAML specifiers) might be needed.

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

No branches or pull requests

4 participants