Skip to content

[ui-importer] Public API integration #4137

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

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Conversation

ramprasadagarwal
Copy link
Collaborator

What changes were proposed in this pull request?

  • (Please fill in changes proposed in this fix)

How was this patch tested?

  • (Please explain how this patch was tested. Ex: unit tests, manual tests)
  • (If this patch involves UI changes, please attach a screen-shot; otherwise, remove this)

Please review Hue Contributing Guide before opening a pull request.

Harshg999 and others added 12 commits April 25, 2025 18:44
Improves file handling with dedicated metadata detection API:
- Adds API error handler decorator for consistent error responses
- Introduces libmagic for more reliable file type detection
- Separates upload and metadata detection functionality
- Adds support for TSV files and multiple sheet Excel detection
- Enhances metadata output with column types and sample data

Removes commented-out legacy format detection code
Adds new endpoint for file metadata detection functionality
Introduces python-magic library for file type detection
Adds polars with calamine support for enhanced data handling

Updates URL pattern for file upload endpoint to be more precise with trailing slash handling
Extracts file processing logic into a separate operation module
Adds TSV to supported file formats
Updates API documentation with clearer descriptions

The change simplifies the upload endpoint by moving file handling logic
to a dedicated operation, making the code more maintainable and
easier to test.
Changes the file metadata detection endpoint to be more efficient and accurate:
- Renames endpoint from 'detect_metadata' to 'guess_metadata'
- Switches to GET method and improves parameter handling
- Optimizes file reading by using sampling instead of full file loads
- Simplifies metadata response to include only essential information
- Adds support for both local and remote file systems
- Improves memory usage by using file streams and BytesIO

The changes make the API more RESTful and improve performance for large files by using content sampling.
Changes request data source from body to query params for file metadata
Adds proper UTF-8 decoding for file samples
Enhances error logging with full stack traces

Improves robustness of CSV/delimited file handling by properly handling byte streams
Removes unnecessary file existence check that could cause false negatives
Enhances file type detection reliability by:
- Adding proper error handling for python-magic import
- Removing dependency on file extensions for type detection
- Simplifying delimiter-based file format detection logic
- Improving error messaging when magic lib is unavailable

Makes file type detection more robust and maintainable by focusing on content analysis rather than extensions.
Implements new preview endpoint to support file imports with:
- Excel file preview with sheet selection
- Delimited file preview (CSV, TSV) with configurable separators
- SQL type mapping for multiple dialects (Hive, Impala, Trino, Phoenix, SparkSQL)
- Automatic header detection
- Error handling improvements for file processing

Enhances the importer API with robust data preview capabilities before import
@ramprasadagarwal ramprasadagarwal changed the base branch from master to new-importer-working-dir May 6, 2025 15:20
Copy link

github-actions bot commented May 6, 2025

✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅

Harshg999 added 10 commits May 6, 2025 20:57
Improves file handling with dedicated metadata detection API:
- Adds API error handler decorator for consistent error responses
- Introduces libmagic for more reliable file type detection
- Separates upload and metadata detection functionality
- Adds support for TSV files and multiple sheet Excel detection
- Enhances metadata output with column types and sample data

Removes commented-out legacy format detection code
Adds new endpoint for file metadata detection functionality
Introduces python-magic library for file type detection
Adds polars with calamine support for enhanced data handling

Updates URL pattern for file upload endpoint to be more precise with trailing slash handling
Extracts file processing logic into a separate operation module
Adds TSV to supported file formats
Updates API documentation with clearer descriptions

The change simplifies the upload endpoint by moving file handling logic
to a dedicated operation, making the code more maintainable and
easier to test.
Changes the file metadata detection endpoint to be more efficient and accurate:
- Renames endpoint from 'detect_metadata' to 'guess_metadata'
- Switches to GET method and improves parameter handling
- Optimizes file reading by using sampling instead of full file loads
- Simplifies metadata response to include only essential information
- Adds support for both local and remote file systems
- Improves memory usage by using file streams and BytesIO

The changes make the API more RESTful and improve performance for large files by using content sampling.
Changes request data source from body to query params for file metadata
Adds proper UTF-8 decoding for file samples
Enhances error logging with full stack traces

Improves robustness of CSV/delimited file handling by properly handling byte streams
Removes unnecessary file existence check that could cause false negatives
Enhances file type detection reliability by:
- Adding proper error handling for python-magic import
- Removing dependency on file extensions for type detection
- Simplifying delimiter-based file format detection logic
- Improving error messaging when magic lib is unavailable

Makes file type detection more robust and maintainable by focusing on content analysis rather than extensions.
Implements new preview endpoint to support file imports with:
- Excel file preview with sheet selection
- Delimited file preview (CSV, TSV) with configurable separators
- SQL type mapping for multiple dialects (Hive, Impala, Trino, Phoenix, SparkSQL)
- Automatic header detection
- Error handling improvements for file processing

Enhances the importer API with robust data preview capabilities before import
@Harshg999 Harshg999 force-pushed the new-importer-working-dir branch from 92bb7d1 to 5ed73c2 Compare May 6, 2025 15:29
Copy link

github-actions bot commented May 6, 2025

@ramprasadagarwal ramprasadagarwal self-assigned this May 7, 2025
Harshg999 added 8 commits May 12, 2025 17:12
Improves file handling with dedicated metadata detection API:
- Adds API error handler decorator for consistent error responses
- Introduces libmagic for more reliable file type detection
- Separates upload and metadata detection functionality
- Adds support for TSV files and multiple sheet Excel detection
- Enhances metadata output with column types and sample data

Removes commented-out legacy format detection code
Adds new endpoint for file metadata detection functionality
Introduces python-magic library for file type detection
Adds polars with calamine support for enhanced data handling

Updates URL pattern for file upload endpoint to be more precise with trailing slash handling
Extracts file processing logic into a separate operation module
Adds TSV to supported file formats
Updates API documentation with clearer descriptions

The change simplifies the upload endpoint by moving file handling logic
to a dedicated operation, making the code more maintainable and
easier to test.
Changes the file metadata detection endpoint to be more efficient and accurate:
- Renames endpoint from 'detect_metadata' to 'guess_metadata'
- Switches to GET method and improves parameter handling
- Optimizes file reading by using sampling instead of full file loads
- Simplifies metadata response to include only essential information
- Adds support for both local and remote file systems
- Improves memory usage by using file streams and BytesIO

The changes make the API more RESTful and improve performance for large files by using content sampling.
Changes request data source from body to query params for file metadata
Adds proper UTF-8 decoding for file samples
Enhances error logging with full stack traces

Improves robustness of CSV/delimited file handling by properly handling byte streams
Removes unnecessary file existence check that could cause false negatives
Enhances file type detection reliability by:
- Adding proper error handling for python-magic import
- Removing dependency on file extensions for type detection
- Simplifying delimiter-based file format detection logic
- Improving error messaging when magic lib is unavailable

Makes file type detection more robust and maintainable by focusing on content analysis rather than extensions.
Implements new preview endpoint to support file imports with:
- Excel file preview with sheet selection
- Delimited file preview (CSV, TSV) with configurable separators
- SQL type mapping for multiple dialects (Hive, Impala, Trino, Phoenix, SparkSQL)
- Automatic header detection
- Error handling improvements for file processing

Enhances the importer API with robust data preview capabilities before import
@Harshg999 Harshg999 force-pushed the new-importer-working-dir branch from 5ed73c2 to 04bcf00 Compare May 12, 2025 11:48
@Harshg999 Harshg999 force-pushed the new-importer-working-dir branch from 7771b36 to f0d3ecb Compare May 19, 2025 15:49
@Harshg999 Harshg999 force-pushed the new-importer-working-dir branch from 583a86d to 708e75a Compare May 28, 2025 19:42
Base automatically changed from new-importer-working-dir to master May 30, 2025 10:32
Copy link

github-actions bot commented Jun 6, 2025

UI Coverage Report

Lines Statements Branches Functions
Coverage: 32%
39.15% (30527/77959) 31.01% (14247/45936) 23.89% (2130/8915)

Copy link

github-actions bot commented Jun 6, 2025

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 💤 0 ❌ 0 🔥 5m 55s ⏱️

@ramprasadagarwal ramprasadagarwal marked this pull request as ready for review June 12, 2025 16:14
@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 16:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request integrates the updated public API endpoints and adapts the importer code to the new data formats and type names. Key changes include updating utility functions and type definitions (e.g., using FilePreviewTableColumn and FilePreviewResponse), revising API endpoint configurations, and modifying UI components and tests to work with the new API responses and settings.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
desktop/core/src/desktop/js/apps/newimporter/utils/utils.ts Updated column conversion using toCamelCase and revised data source generation based on FilePreviewResponse.
desktop/core/src/desktop/js/apps/newimporter/utils/utils.test.ts Updated tests to reflect the new FilePreview table column and data types.
desktop/core/src/desktop/js/apps/newimporter/types.ts Renamed types (e.g., GuessFieldTypesColumn to FilePreviewTableColumn) and refined interface definitions.
desktop/core/src/desktop/js/apps/newimporter/constants.ts Modified enum values and updated source configuration to include a new sheet name option.
desktop/core/src/desktop/js/apps/newimporter/api.ts Revised API endpoint URLs to match the new public API routes.
desktop/core/src/desktop/js/apps/newimporter/ImporterSourceSelector/ImporterSourceSelector.tsx Changed response field mapping to use the updated file API field names.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/SourceConfiguration/SourceConfiguration.tsx Adjusted input handling and updated the onChange signature to work with CombinedFileFormat.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/SourceConfiguration/SourceConfiguration.test.tsx Updated tests to account for new select element expectations based on file type.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.tsx Replaced useEffect-based data handling with useLoadData hooks and updated table data conversion, integrating new API fields.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.test.tsx Revised tests to match the new API response structure and updated type definitions.
Comments suppressed due to low confidence (3)

desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/SourceConfiguration/SourceConfiguration.test.tsx:119

  • [nitpick] Double-check the expected number of Select components for non-EXCEL file types; the discrepancy in counts between EXCEL and non-EXCEL tests could indicate an unintended UI change.
expect(selectElement).toHaveLength(5);

desktop/core/src/desktop/js/apps/newimporter/utils/utils.ts:35

  • Ensure that converting column names to camelCase is compatible with all consumers of the table data, as this key transformation may affect downstream matching.
dataIndex: toCamelCase(item.name),

desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.tsx:138

  • [nitpick] Confirm that the structure of previewData returned by the API fully conforms to the expected format for convertToDataSource, ensuring that all required keys are present and correctly mapped.
const tableData = convertToDataSource(previewData?.previewData ?? {});

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.

2 participants