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

Implement pipeMode Parameter to EvalCommand #346

Closed
wants to merge 13 commits into from

Conversation

RonConfigu
Copy link
Contributor

@RonConfigu RonConfigu commented Jan 18, 2024

QA Report I

  • Test Units Passes

Closes #336

@RonConfigu RonConfigu added the feat New feature or request label Jan 18, 2024
@RonConfigu RonConfigu self-assigned this Jan 18, 2024
@RonConfigu RonConfigu linked an issue Jan 18, 2024 that may be closed by this pull request
@RonConfigu RonConfigu marked this pull request as ready for review January 22, 2024 07:16
@RonConfigu RonConfigu requested a review from a team as a code owner January 22, 2024 07:16
…ing TBD @rannn505

- [x] Add `pipeMode?: EvalCommandPipeMode` to `EvalCommandParameters`
- [x] Add `pipeMode` to `EvalCommandReturn[KEY]['context']` so that the next `EvalCommand` could identify which to remove
- [x] Modify `EvalCommand.run()` to add the new context.pipeMode to its configs. *currently on the ones from the schema. Q.1 answer may change it to override piped configs context.pipeMode*
- [x] Create Test Units
@@ -224,6 +227,14 @@ export class EvalCommand extends Command<EvalCommandReturn> {
return resultWithTemplates;
}

private removeForwardsFromPipe(result: EvalCommandReturn): EvalCommandReturn {
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming of the method is a bit misleading in my opinion because we perform the removal from the result and not the pipe itself. How about one of these?

  • removeForwardsFromPrevious -> aligns with evalPrevious
  • removeForwards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. if you take a look at the method's logic, pipe[current.context.key] validate we're only removing from the piped configs
  2. removeForwardsFromPrevious -> aligns with evalPrevious i don't understand what you mean here
  3. sure. removeForwards it is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Was true until you showed me the forward chain bug. I'll revise. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Like in the other PR, let's recycle the EvalCommand usages into a function to keep this file leaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what other PR?
please elaborate and be specific here. PR's are not related.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust the schema examples to be more generic, perhaps we should always do tests on start.cfgu.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why?

@@ -277,6 +288,7 @@ export class EvalCommand extends Command<EvalCommandReturn> {
schema: schema.name,
key,
cfgu,
pipeMode,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a mistake that leads to a bug. Consider a scenario where the 2nd eval also forwards the same keys as the previous, this case will lead to all the keys being lost due to the logic inside of the removal method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good one 💯
Thanks. I'l revise and test

const evaluatedConfigs = await new ExportCommand({ pipe: evalQuote }).run();
expect(evaluatedConfigs).toStrictEqual({ MY_NAME: 'What?', QUOTE: 'Hi! My name is What?, my name is Who?' });
});
test("run EvalCommand(pipeMode='forward') and pipe to another, only keys from the second should exists in export", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test or adjust an existing test to check for the scenario where a 2nd eval overrides the same key from a forwarded eval and ensure that the key is still there.

Copy link
Contributor

@RichardAkman RichardAkman left a comment

Choose a reason for hiding this comment

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

Great work 💯 please review my comments 🙏🏻

ShriekinNinja and others added 9 commits January 23, 2024 18:30
Co-authored-by: Richard Akman <richard.akman1@gmail.com>
Co-authored-by: Richard Akman <richard.akman1@gmail.com>
…alCommand' into 336-Add-pipeMode-Parameter-to-EvalCommand
Co-authored-by: Richard Akman <richard.akman1@gmail.com>
…alCommand' into 336-Add-pipeMode-Parameter-to-EvalCommand
if (!pipe) {
return result;
}
console.log(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

?

@@ -308,6 +321,8 @@ export class EvalCommand extends Command<EvalCommandReturn> {
...this.evalTemplates(result),
};

result = this.removeForwards(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

thats should be after validation as all Configs must be validated

@rannn505
Copy link
Contributor

@configu/dev we decided to reproductize this feature, closed until next time.

@rannn505 rannn505 closed this Jan 31, 2024
@RichardAkman RichardAkman deleted the 336-Add-pipeMode-Parameter-to-EvalCommand branch April 15, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@configu/ts feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pipeMode Parameter to EvalCommand
4 participants