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

[Obs AI Assistant] Use Mocha & Synthtrace for evaluation framework #173993

Merged
merged 8 commits into from
Dec 28, 2023

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Dec 27, 2023

Two changes here:

  1. Use Mocha instead of custom test runner. This allows us to use Mocha's much more extensive API to run the tests: skipping tests, before and after hooks, grep etc.
  2. Make Synthtrace available for running tests.

One note:

  • I've added a rule to automatically inject a type reference for Mocha, via @kbn/ambient-ftr-types. The reason is Mocha is not typed by default (ie, the types are not available in the global space), because it conflicts with Jest. The rule enforces that @kbn/ambient-ftr-types is imported so things like before() can be used.

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v8.12.0 v8.12.1 v8.13.0 labels Dec 27, 2023
@dgieselaar dgieselaar marked this pull request as ready for review December 27, 2023 16:40
@dgieselaar dgieselaar requested review from a team as code owners December 27, 2023 16:40
@@ -39,6 +39,8 @@ interface ChatClient {
{}: { conversationId?: string; messages: InnerMessage[] },
criteria: string[]
) => Promise<EvaluationResult>;
getResults: () => EvaluationResult[];
onResult: (cb: (result: EvaluationResult) => void) => () => void;
Copy link
Contributor

@CoenWarmer CoenWarmer Dec 28, 2023

Choose a reason for hiding this comment

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

Could you add these methods to x-pack/plugins/observability_ai_assistant/public/types.ts and the mock of ChatClient in x-pack/plugins/observability_ai_assistant/public/mock.tsx?

I'm surprised the TS check did not catch this. We should probably fix this

Copy link
Member Author

Choose a reason for hiding this comment

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

Different chat client, this is only for the tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wait, this is a different ChatClient in /scripts. Should they have the same methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a simplified client so it's easy to use for Almu & Marco as well, so I don't think we should have parity with the other client as a goal necessarily

@CoenWarmer
Copy link
Contributor

Code looks good. Just one question: why use mocha instead of jest?

@dgieselaar
Copy link
Member Author

@CoenWarmer Jest comes with a lot more things than Mocha. E.g. I don't need mocking, or watch mode, or fancy terminal output. Mocha is the simple option.

@CoenWarmer CoenWarmer self-requested a review December 28, 2023 14:27
Copy link
Contributor

@CoenWarmer CoenWarmer left a comment

Choose a reason for hiding this comment

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

LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar dgieselaar merged commit 5359ebe into elastic:main Dec 28, 2023
21 checks passed
@dgieselaar dgieselaar deleted the obs-ai-assistant-evaluation-mocha branch December 28, 2023 15:13
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 28, 2023
Two changes here:

1. Use Mocha instead of custom test runner. This allows us to use
Mocha's much more extensive API to run the tests: skipping tests, before
and after hooks, grep etc.
2. Make Synthtrace available for running tests.

One note:
- I've added a rule to automatically inject a type reference for Mocha,
via `@kbn/ambient-ftr-types`. The reason is Mocha is not typed by
default (ie, the types are not available in the global space), because
it conflicts with Jest. The rule enforces that `@kbn/ambient-ftr-types`
is imported so things like `before()` can be used.

(cherry picked from commit 5359ebe)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.12

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 28, 2023
# Backport

This will backport the following commits from `main` to `8.12`:
- [[Obs AI Assistant] Use Mocha &amp; Synthtrace
(#173993)](#173993)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dario
Gieselaar","email":"dario.gieselaar@elastic.co"},"sourceCommit":{"committedDate":"2023-12-28T15:13:24Z","message":"[Obs
AI Assistant] Use Mocha & Synthtrace (#173993)\n\nTwo changes
here:\r\n\r\n1. Use Mocha instead of custom test runner. This allows us
to use\r\nMocha's much more extensive API to run the tests: skipping
tests, before\r\nand after hooks, grep etc.\r\n2. Make Synthtrace
available for running tests.\r\n\r\nOne note:\r\n- I've added a rule to
automatically inject a type reference for Mocha,\r\nvia
`@kbn/ambient-ftr-types`. The reason is Mocha is not typed by\r\ndefault
(ie, the types are not available in the global space), because\r\nit
conflicts with Jest. The rule enforces that
`@kbn/ambient-ftr-types`\r\nis imported so things like `before()` can be
used.","sha":"5359ebe9c8838bd5b3fb347d1dbd556fcd88d566","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.12.0","v8.12.1","v8.13.0"],"title":"[Obs
AI Assistant] Use Mocha & Synthtrace for evaluation
framework","number":173993,"url":"https://github.com/elastic/kibana/pull/173993","mergeCommit":{"message":"[Obs
AI Assistant] Use Mocha & Synthtrace (#173993)\n\nTwo changes
here:\r\n\r\n1. Use Mocha instead of custom test runner. This allows us
to use\r\nMocha's much more extensive API to run the tests: skipping
tests, before\r\nand after hooks, grep etc.\r\n2. Make Synthtrace
available for running tests.\r\n\r\nOne note:\r\n- I've added a rule to
automatically inject a type reference for Mocha,\r\nvia
`@kbn/ambient-ftr-types`. The reason is Mocha is not typed by\r\ndefault
(ie, the types are not available in the global space), because\r\nit
conflicts with Jest. The rule enforces that
`@kbn/ambient-ftr-types`\r\nis imported so things like `before()` can be
used.","sha":"5359ebe9c8838bd5b3fb347d1dbd556fcd88d566"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173993","number":173993,"mergeCommit":{"message":"[Obs
AI Assistant] Use Mocha & Synthtrace (#173993)\n\nTwo changes
here:\r\n\r\n1. Use Mocha instead of custom test runner. This allows us
to use\r\nMocha's much more extensive API to run the tests: skipping
tests, before\r\nand after hooks, grep etc.\r\n2. Make Synthtrace
available for running tests.\r\n\r\nOne note:\r\n- I've added a rule to
automatically inject a type reference for Mocha,\r\nvia
`@kbn/ambient-ftr-types`. The reason is Mocha is not typed by\r\ndefault
(ie, the types are not available in the global space), because\r\nit
conflicts with Jest. The rule enforces that
`@kbn/ambient-ftr-types`\r\nis imported so things like `before()` can be
used.","sha":"5359ebe9c8838bd5b3fb347d1dbd556fcd88d566"}}]}] BACKPORT-->

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v8.12.0 v8.12.1 v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants