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

[ML] Remove static api service #153477

Closed
Tracked by #187772
jgowdyelastic opened this issue Mar 22, 2023 · 1 comment · Fixed by #189729
Closed
Tracked by #187772

[ML] Remove static api service #153477

jgowdyelastic opened this issue Mar 22, 2023 · 1 comment · Fixed by #189729
Labels
Meta :ml refactoring technical debt Improvement of the software architecture and operational architecture v8.16.0

Comments

@jgowdyelastic
Copy link
Member

jgowdyelastic commented Mar 22, 2023

The statically imported api service, normally imported as ml from ml/public/application/services/ml_api_service/index.ts uses http from the dependency cache.
This statically imported server should be removed.

In some cases ml isn't used, and a more specific provider is used instead, e.g. jobsApiProvider

TypeScript react functional components
Replace with context versions supplied by useMlApiContext or specific hooks like useTrainedModelsApiService (do we need specific hooks like this? only ever using useMlApiContext would be simpler and easier to document.

  • alerting/job_selector.tsx
  • alerting/preview_alert_condition.tsx
  • alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx
  • alerting/ml_anomaly_alert_trigger.tsx
  • application/settings/anomaly_detection_settings.tsx
  • application/app.tsx
  • application/management/jobs_list/components/jobs_list_page/space_management/space_management.tsx
  • application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx
  • application/components/model_snapshots/edit_model_snapshot_flyout/edit_model_snapshot_flyout.tsx
  • application/components/model_snapshots/model_snapshots_table.tsx
  • application/components/model_snapshots/revert_model_snapshot_flyout/revert_model_snapshot_flyout.tsx
  • application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared/new_job_awaiting_node_shared.tsx
  • application/components/annotations/annotation_flyout/index.tsx
  • application/components/anomalies_table/anomaly_details.tsx
  • application/components/anomalies_table/links_menu.tsx
  • application/data_frame_analytics/pages/analytics_creation/components/details_step/details_step_form.tsx
  • application/data_frame_analytics/pages/analytics_creation/components/create_analytics_advanced_editor/create_analytics_advanced_editor.tsx
  • application/data_frame_analytics/pages/analytics_creation/components/create_step_footer/create_step_footer.tsx
  • application/data_frame_analytics/pages/analytics_creation/page.tsx
  • application/data_frame_analytics/pages/analytics_exploration/components/expandable_section/expandable_section_analytics.tsx
  • application/data_frame_analytics/pages/analytics_management/components/action_edit/edit_action_flyout.tsx
  • application/data_frame_analytics/pages/analytics_management/components/analytics_list/expanded_row_messages_pane.tsx
  • application/data_frame_analytics/pages/components/analytics_selector/analytics_id_selector.tsx
  • application/routing/routes/explorer.tsx
  • application/routing/routes/timeseriesexplorer.tsx
  • application/jobs/new_job/pages/components/validation_step/validation.tsx
  • application/jobs/new_job/pages/components/job_details_step/components/additional_section/components/calendars/calendars_selection.tsx
  • application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/top_categories.tsx
  • application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/category_stopped_partitions.tsx
  • application/jobs/jobs_list/components/job_details/job_messages_pane.tsx
  • application/overview/components/analytics_panel/analytics_panel.tsx
  • application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx
  • application/memory_usage/nodes_overview/nodes_list.tsx
  • application/memory_usage/memory_tree_map/tree_map.tsx
  • application/model_management/delete_models_modal.tsx
  • application/model_management/models_list.tsx
  • application/model_management/test_models/test_flyout.tsx
  • application/model_management/model_actions.tsx
  • maps/anomaly_layer_wizard_factory.tsx
  • maps/anomaly_source.tsx
  • maps/anomaly_job_selector.tsx
  • maps/create_anomaly_source_editor.tsx

Util like files, hooks, services
These will need to be wrapped in provider function or converted to a service class to allow the dependencies to be passed in.

  • application/capabilities/check_capabilities.ts
  • application/capabilities/get_capabilities.ts
  • application/components/import_export_jobs/export_jobs_flyout/jobs_export_service.ts
  • application/components/node_available_warning/hooks.ts
  • application/components/rule_editor/utils.js
  • application/data_frame_analytics/common/analytics.ts
  • application/data_frame_analytics/common/get_index_data.ts
  • application/data_frame_analytics/common/use_results_view_config.ts
  • application/data_frame_analytics/pages/analytics_creation/components/shared/fetch_explain_data.ts
  • application/data_frame_analytics/pages/analytics_creation/hooks/use_index_data.ts
  • application/data_frame_analytics/pages/analytics_exploration/components/exploration_results_table/use_exploration_results.ts
  • application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.ts
  • application/data_frame_analytics/pages/analytics_management/services/analytics_service/delete_analytics.ts
  • application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.ts
  • application/data_frame_analytics/pages/analytics_management/services/analytics_service/start_analytics.ts
  • application/data_frame_analytics/pages/analytics_management/services/analytics_service/stop_analytics.ts
  • application/data_frame_analytics/pages/job_map/use_fetch_analytics_map_data.ts
  • application/explorer/explorer_utils.ts
  • application/jobs/components/custom_url_editor/utils.js
  • application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js
  • application/jobs/jobs_list/components/utils.js
  • application/jobs/new_job/common/chart_loader/chart_loader.ts
  • application/jobs/new_job/common/chart_loader/searches.ts
  • application/jobs/new_job/common/job_creator/job_creator.ts
  • application/jobs/new_job/common/job_creator/util/model_memory_estimator.ts
  • application/jobs/new_job/common/job_runner/job_runner.ts
  • application/jobs/new_job/common/job_validator/validators.ts
  • application/jobs/new_job/common/results_loader/categorization_examples_loader.ts
  • application/jobs/new_job/common/results_loader/searches.ts
  • application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts
  • application/jobs/new_job/job_from_lens/quick_create_job.ts
  • application/jobs/new_job/job_from_lens/route_resolver.ts
  • application/jobs/new_job/job_from_map/quick_create_job.ts
  • application/jobs/new_job/job_from_map/route_resolver.ts
  • application/jobs/new_job/pages/components/pick_fields_step/components/bucket_span_estimator/estimate_bucket_span.ts
  • application/jobs/new_job/recognize/resolvers.ts
  • application/ml_nodes_check/check_ml_nodes.ts
  • application/model_management/test_models/models/inference_base.ts
  • application/model_management/test_models/models/ner/ner_inference.ts
  • application/model_management/test_models/models/question_answering/question_answering_inference.ts
  • application/model_management/test_models/models/text_classification/fill_mask_inference.ts
  • application/model_management/test_models/models/text_classification/lang_ident_inference.ts
  • application/model_management/test_models/models/text_classification/text_classification_inference.ts
  • application/model_management/test_models/models/text_classification/zero_shot_classification_inference.ts
  • application/model_management/test_models/models/text_embedding/text_embedding_inference.ts
  • application/services/anomaly_detector_service.ts
  • application/services/anomaly_explorer_charts_service.ts
  • application/services/calendar_service.ts
  • application/services/forecast_service.js
  • application/services/job_service.js
  • application/services/mapping_service.js
  • application/services/ml_server_info.ts
  • application/services/new_job_capabilities/new_job_capabilities_service_analytics.ts
  • application/services/new_job_capabilities/new_job_capabilities_service.ts
  • application/services/results_service/index.ts
  • application/services/results_service/result_service_rx.ts
  • application/services/results_service/results_service.d.ts
  • application/settings/calendars/edit/utils.js
  • application/settings/filter_lists/edit/utils.js
  • application/timeseriesexplorer/timeseries_search_service.ts
  • application/timeseriesexplorer/timeseriesexplorer_utils/get_focus_data.ts
  • embeddables/anomaly_charts/anomaly_charts_embeddable_factory.ts
  • embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.ts
  • maps/anomaly_source_factory.ts
  • maps/util.ts

React classes
Convert to functional component to allow use of useMlApiContext or pass in specific api dependencies as props.
An alternative is to use contextType to access kibana context from the class based component (see https://legacy.reactjs.org/docs/context.html#classcontexttype).
For javascript files, converting to a functional component would also involve rewriting in TypeScript.

  • application/components/annotations/annotations_table/annotations_table.js
  • application/components/anomalies_table/anomalies_table.js
  • application/components/data_recognizer/data_recognizer.js
  • application/components/rule_editor/rule_editor_flyout.js
  • application/components/rule_editor/select_rule_action/rule_action_panel.js
  • application/datavisualizer/index_based/data_loader/data_loader.ts
  • application/jobs/jobs_list/components/edit_job_flyout/edit_job_flyout.js
  • application/jobs/jobs_list/components/edit_job_flyout/tabs/job_details.js
  • application/jobs/jobs_list/components/job_details/datafeed_preview_tab.js
  • application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js
  • application/jobs/jobs_list/components/multi_job_actions/group_selector/group_selector.js
  • application/settings/calendars/edit/new_calendar.js
  • application/settings/calendars/list/calendars_list.js
  • application/settings/calendars/list/delete_calendars.js
  • application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_lists.js
  • application/settings/filter_lists/edit/edit_filter_list.js
  • application/settings/filter_lists/list/filter_lists.js
  • application/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js
  • application/timeseriesexplorer/timeseriesexplorer.js

Test files

  • application/components/annotations/annotations_table/annotations_table.test.js
  • application/components/ml_entity_selector/ml_entity_selector.test.tsx
  • application/components/rule_editor/rule_editor_flyout.test.js
  • application/components/rule_editor/select_rule_action/rule_action_panel.test.js
  • application/contexts/kibana/__mocks__/kibana_context.ts
  • application/contexts/kibana/__mocks__/use_ml_api_context.ts
  • application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.test.ts
  • application/jobs/new_job/common/job_creator/util/model_memory_estimator.test.ts
  • application/services/anomaly_explorer_charts_service.test.ts
  • application/services/ml_server_info.test.ts
  • application/services/new_job_capabilities/new_job_capabilities._service.test.ts
  • application/settings/calendars/edit/new_calendar.test.js
  • application/settings/calendars/list/calendars_list.test.js
  • application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_list_modal.test.js
  • application/settings/filter_lists/edit/edit_filter_list.test.js
  • application/settings/filter_lists/list/filter_lists.test.js
  • application/settings/filter_lists/list/table.test.js
@jgowdyelastic jgowdyelastic added Meta :ml refactoring technical debt Improvement of the software architecture and operational architecture labels Mar 22, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta :ml refactoring technical debt Improvement of the software architecture and operational architecture v8.16.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants