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

Add Invalid Encoding Channel Warning #3426

Merged
merged 1 commit into from
Mar 4, 2018
Merged

Conversation

invokesus
Copy link
Member

@invokesus invokesus commented Feb 28, 2018

Please:

  • Make your pull request atomic, fixing one issue at a time unless there are many relevant issues that cannot be decoupled.
  • Provide a test case & update the documentation under site/docs/
  • Make lint and test pass. (Run yarn lint and yarn test. If your change affects Vega outputs of some examples, please run yarn build:example EXAMPLE_NAME to re-compile a specific example or yarn build:examples to re-compile all examples.)
  • Make sure you have rebased onto the master branch.
  • Provide a concise title so that we can just copy it to our release note.
    • Use imperative mood and present tense.
    • Mention relevant issues. (e.g., #1)

Fixes #3415.

@domoritz
Copy link
Member

Thank you for the pull request.

Please make this a warning and delete the encoding instead of throwing an error. Also, let's add a test.

@invokesus
Copy link
Member Author

The warning and deletion of encoding is already implemented in encoding.ts.
I was thinking of adding a case for unrecognized Channel here. So that, getSupportedMark returns an empty dictionary, causing supportMark to return false and finally the warning being triggered in normalizeEncoding.
Is this in the right direction?

@domoritz
Copy link
Member

domoritz commented Mar 1, 2018

I'd trace what causes the error in #3415 and make sure that it's handled either by the code you found or something new you write.

@invokesus invokesus force-pushed the master branch 2 times, most recently from ec5d71b to e91c4fe Compare March 1, 2018 22:57
@invokesus invokesus changed the title Add Invalid Encoding Channel Error Message Add Invalid Encoding Channel Warning Mar 1, 2018
@invokesus
Copy link
Member Author

Updated the PR. 🙂

Copy link
Member

@kanitw kanitw left a comment

Choose a reason for hiding this comment

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

Thank you so much for submitting a PR.

Please see my comments. I think you're getting there. :)

src/channel.ts Outdated
@@ -214,6 +214,8 @@ export function getSupportedMark(channel: Channel): SupportedMark {
return {point: true, geoshape: true};
case TEXT:
return {text: true};
default:
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this is the right place to correct this?

If the channel you have isn't a valid Channel at all, then it doesn't satisfy the signature of this method.

A better check would be using isChannel method to check if a key of the encoding object is a channel.

Copy link
Member Author

Choose a reason for hiding this comment

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

Made the changes. Thanks for the help!

_y: {type: 'quantitative'}
}
} as any); // To make parseUnitModel accept the model with invalid encoding channel
assert.equal(model.encoding.shape, undefined);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why this is related to model.encoding.shape.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the assert.

Copy link
Member

@kanitw kanitw left a comment

Choose a reason for hiding this comment

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

Thanks. A few more minor correction and this should be good to go! :)

src/log.ts Outdated
@@ -175,6 +175,10 @@ export namespace message {
return `${channel} dropped as it is incompatible with "${markOrFacet}"${when ? ` when ${when}` : ''}.`;
}

export function invalidEncodingChannel(encoding: string) {
Copy link
Member

Choose a reason for hiding this comment

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

encoding normally refer to encoding mapping, which is an object.

Rename to channel would be less misleading.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

src/log.ts Outdated
@@ -175,6 +175,10 @@ export namespace message {
return `${channel} dropped as it is incompatible with "${markOrFacet}"${when ? ` when ${when}` : ''}.`;
}

export function invalidEncodingChannel(encoding: string) {
return `${encoding} dropped as it is invalid.`;
Copy link
Member

Choose a reason for hiding this comment

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

${channel}-encoding is dropped as ${channel} is not a valid encoding channel.

@@ -19,6 +19,17 @@ describe('UnitModel', function() {
assert.equal(localLogger.warns[0], log.message.incompatibleChannel(SHAPE, BAR));
}));

it('should drop invalid channel and throws warning', log.wrap((localLogger) => {
const INVALID_CHANNEL = '_y';
Copy link
Member

Choose a reason for hiding this comment

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

remove this line and just use "_y" below?

@kanitw kanitw merged commit 3f66a77 into vega:master Mar 4, 2018
@domoritz
Copy link
Member

domoritz commented Mar 4, 2018

Thank you @invokesus!

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.

Invalid encoding channel should fail more gracefully
3 participants