GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adding interface class and local interface implementation by mtinning · Pull Request #90 · BitBloomTech/spawn

Conversation

@mtinning

@mtinning mtinning commented Jan 22, 2019

Copy link
Copy Markdown
Member

Closes #76

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Mike Tinning
Adding interface class and local interface implementation
7eabd99
@mtinning
mtinning requested a review from phil-brad January 22, 2019 16:33
Mike Tinning added 2 commits January 22, 2019 16:34
Mike Tinning
Fixing build issues
f4b6c82
Mike Tinning
Adding licenses
1a2aaa0
phil-brad
phil-brad requested changes Jan 22, 2019
View reviewed changes

@phil-brad phil-brad left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to add top-level run and inspect functions so that a user can simply do spawn.run(...), which mirrors the the CLI functionality. As a user I would expect to be able to do this. I think with your design of the interface classes, these top-level function can just build and call the appropriate interface class

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Mike Tinning
Adding run and inspect to top-level interface (and fixing circular re…
28cb9f3
…ferences introduced
@phil-brad

phil-brad commented Jan 24, 2019

Copy link
Copy Markdown
Member

Following code errors for me inside spawn_config() (there should be a test on this I think):

import json
import spawn
with open('example_data/example_spec.json') as fp:
    spec_dict = json.load(fp)
spawn.inspect(spec_dict)

Also as a user, I would expect to be able to do spawn.inspect(spec_dict, outfile='spawn.json', format='json') as this parallels the CLI implementation. Also would be nice to pass in config parameters as arguments as this is more natural. I don't think it's necessary to be be able to take an argument config of type ConfigurationBase as this would be more in the realms of advanced users who could use the LocalInterface class. We could go for a **kwargs approach so that signature would be:

def inspect(spec_dict, outfile=None, format='txt', **kwargs)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mtinning

mtinning commented Jan 29, 2019

Copy link
Copy Markdown
Member Author

Also as a user, I would expect to be able to do spawn.inspect(spec_dict, outfile='spawn.json', format='json') as this parallels the CLI implementation

I don't think this is the right way to go as it muddies the interface significantly. However I'd be happy with an additional method, write_inspection which took the inspection as an argument. So the interface would be something like:

spawn.write_inspection(spawn.inspect(spec_dict), outfile='spawn.json', format='json'))
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mtinning

mtinning commented Jan 29, 2019

Copy link
Copy Markdown
Member Author

Also, the definition is flexible, allowing config to be a dict

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mike Tinning added 2 commits January 29, 2019 15:02
Mike Tinning
Adding write_insepction to interface
fefd1fb
Mike Tinning
Updating license
f8b9283
phil-brad
phil-brad approved these changes Feb 4, 2019
View reviewed changes
@phil-brad
phil-brad merged commit 986e760 into master Feb 4, 2019
@phil-brad
phil-brad deleted the spawn-interface branch February 4, 2019 22:58
@phil-brad

phil-brad commented Feb 4, 2019

Copy link
Copy Markdown
Member

OK - I've merged this!

On the inspect function yes I agree actually, it should always return a dict (obviously a CLI cannot return a dict so this is not valid there) and should be abstracted from the write_inspection

However, I do still feel that there should be a top-level function where config parameters are default arguments. I saw that it could be a dict, but having it as a dict obfuscates the options a little because the user's IDE won't hint and the docstrings for that function can't tell them the options. It means they have to look into the config part of the docs which may not be immediately obvious to them. It's not about code design - which is clearly good, it's about offering a top-level wrapper function that delivers maximum usability. If you look at any major python package then it generally has top-level functions with a long list of default arguments (e.g. json.load, pandas.read_csv). These don't really reflect the underlying design but offer an incredibly easy-to-use interface for the user.

Alternatively, I could implement such top-level functions in spawn-wind but leave them out of the core spawn.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@phil-brad phil-brad phil-brad approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mtinning @phil-brad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.