Skip to content

Commit

Permalink
[ML] Move aiops-utils package to x-pack/packages/ml. (#134985)
Browse files Browse the repository at this point in the history
When we created the `aiops-utils` package originally, we were not aware that packages could also live within `x-pack`. Since `aiops` is a platinum feature and maintained by the ML team, this moves the package from `/packages` to `/x-pack/packages/ml`. The license header of the package files now match the `aiops` plugin again.
  • Loading branch information
walterra authored Jun 24, 2022
1 parent cf4040a commit 8c94def
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 1,042 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
/x-pack/test/functional/services/transform/ @elastic/ml-ui
/x-pack/test/functional_basic/apps/transform/ @elastic/ml-ui
/x-pack/packages/ml/ @elastic/ml-ui
/packages/kbn-aiops-utils @elastic/ml-ui
/examples/response_stream/ @elastic/ml-ui

# Maps
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"@hapi/inert": "^6.0.4",
"@hapi/wreck": "^17.1.0",
"@kbn/ace": "link:bazel-bin/packages/kbn-ace",
"@kbn/aiops-utils": "link:bazel-bin/packages/kbn-aiops-utils",
"@kbn/aiops-utils": "link:bazel-bin/x-pack/packages/ml/aiops_utils",
"@kbn/alerts": "link:bazel-bin/packages/kbn-alerts",
"@kbn/analytics": "link:bazel-bin/packages/kbn-analytics",
"@kbn/analytics-client": "link:bazel-bin/packages/analytics/client",
Expand Down Expand Up @@ -650,7 +650,7 @@
"@types/json5": "^0.0.30",
"@types/jsonwebtoken": "^8.5.6",
"@types/kbn__ace": "link:bazel-bin/packages/kbn-ace/npm_module_types",
"@types/kbn__aiops-utils": "link:bazel-bin/packages/kbn-aiops-utils/npm_module_types",
"@types/kbn__aiops-utils": "link:bazel-bin/x-pack/packages/ml/aiops_utils/npm_module_types",
"@types/kbn__alerts": "link:bazel-bin/packages/kbn-alerts/npm_module_types",
"@types/kbn__analytics": "link:bazel-bin/packages/kbn-analytics/npm_module_types",
"@types/kbn__analytics-client": "link:bazel-bin/packages/analytics/client/npm_module_types",
Expand Down
4 changes: 2 additions & 2 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ filegroup(
"//packages/elastic-apm-synthtrace:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/kbn-ace:build",
"//packages/kbn-aiops-utils:build",
"//packages/kbn-alerts:build",
"//packages/kbn-ambient-storybook-types:build",
"//packages/kbn-ambient-ui-types:build",
Expand Down Expand Up @@ -163,6 +162,7 @@ filegroup(
"//packages/shared-ux/page/kibana_no_data:build",
"//packages/shared-ux/prompt/no_data_views:build",
"//x-pack/packages/ml/agg_utils:build",
"//x-pack/packages/ml/aiops_utils:build",
"//x-pack/packages/ml/is_populated_object:build",
"//x-pack/packages/ml/string_hash:build",
],
Expand Down Expand Up @@ -215,7 +215,6 @@ filegroup(
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-safer-lodash-set:build_types",
"//packages/kbn-ace:build_types",
"//packages/kbn-aiops-utils:build_types",
"//packages/kbn-alerts:build_types",
"//packages/kbn-analytics:build_types",
"//packages/kbn-apm-config-loader:build_types",
Expand Down Expand Up @@ -311,6 +310,7 @@ filegroup(
"//packages/shared-ux/page/kibana_no_data:build_types",
"//packages/shared-ux/prompt/no_data_views:build_types",
"//x-pack/packages/ml/agg_utils:build_types",
"//x-pack/packages/ml/aiops_utils:build_types",
"//x-pack/packages/ml/is_populated_object:build_types",
"//x-pack/packages/ml/string_hash:build_types",
],
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-aiops-utils/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions packages/kbn-aiops-utils/jest.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ function getTsProject(repoPath: string) {
skipAddingFilesFromTsConfig: true,
});
project.addSourceFilesAtPaths([`${repoPath}/x-pack/plugins/**/*.ts`, '!**/*.d.ts']);
project.addSourceFilesAtPaths([`${repoPath}/x-pack/packages/**/*.ts`, '!**/*.d.ts']);
project.addSourceFilesAtPaths([`${repoPath}/src/plugins/**/*.ts`, '!**/*.d.ts']);
project.addSourceFilesAtPaths([`${repoPath}/packages/**/*.ts`, '!**/*.d.ts']);
project.resolveSourceFileDependencies();
Expand Down
13 changes: 10 additions & 3 deletions packages/kbn-docs-utils/src/api_docs/find_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function findPlugins(): PluginOrPackage[] {
*/
export function findPackages(): PluginOrPackage[] {
const packagePaths = globby
.sync(Path.resolve(REPO_ROOT, 'packages/**/package.json'), { absolute: true })
.sync(Path.resolve(REPO_ROOT, '{x-pack/,}packages/**/package.json'), { absolute: true })
.map((path) =>
// absolute paths returned from globby are using normalize or
// something so the path separators are `/` even on windows,
Expand All @@ -59,15 +59,22 @@ export function findPackages(): PluginOrPackage[] {
scope = ApiScope.CLIENT;
}

let ownerName = '[Owner missing]';
// Some of these author fields have "<[email protected]>" in the name which mdx chokes on. Removing the < and > seems to work.
if (Array.isArray(manifest.author)) {
ownerName = manifest.author.map((d) => d.replace(/[<>]/gi, '')).join(', ');
} else if (typeof manifest.author === 'string') {
ownerName = manifest.author.replace(/[<>]/gi, '');
}

acc.push({
directory: Path.dirname(path),
manifestPath: path,
manifest: {
...manifest,
id: manifest.name,
serviceFolders: [],
// Some of these author fields have "<[email protected]>" in the name which mdx chokes on. Removing the < and > seems to work.
owner: { name: manifest.author?.replace(/[<>]/gi, '') || '[Owner missing]' },
owner: { name: ownerName },
},
isPlugin: false,
scope,
Expand Down
31 changes: 2 additions & 29 deletions x-pack/packages/ml/agg_utils/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
# @kbn/ml-agg-utils

This package includes utility functions provided by the ML team to be used in Kibana plugins related to data manipulation and verification.
This package includes utility functions related to creating elasticsearch aggregation queries, data manipulation and verification.

<!-- INSERT GENERATED DOCS START -->

### `buildSamplerAggregation` (function)

Wraps the supplied aggregations in a sampler aggregation.
A supplied samplerShardSize (the shard_size parameter of the sampler aggregation)
of less than 1 indicates no sampling, and the aggs are returned as-is.

**Parameters:**

- aggs (`any`)
- samplerShardSize (`number`)

**returns:** Record<string, AggregationsAggregationContainer>

### `getSamplerAggregationsResponsePath` (function)

**Parameters:**

- samplerShardSize (`number`)

**returns:** string[]

### `getAggIntervals` (function)

Returns aggregation intervals for the supplied document fields.

<!-- INSERT GENERATED DOCS END -->
https://docs.elastic.dev/kibana-dev-docs/api/kbn-ml-agg-utils
11 changes: 4 additions & 7 deletions x-pack/packages/ml/agg_utils/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"name": "@kbn/ml-agg-utils",
"description": "This package includes utility functions related to creating elasticsearch aggregation queries, data manipulation and verification.",
"author": "Machine Learning UI",
"homepage": "https://docs.elastic.dev/kibana-dev-docs/api/kbn-ml-agg-utils",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0",
"devDependencies": {
"ts-readme": "^1.1.3"
},
"scripts": {
"generate-docs": "ts-readme src/index.ts"
}
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Loading

0 comments on commit 8c94def

Please sign in to comment.