Skip to content

54 adding bulk insert support to telemetrycli - #58

Merged
ArnavG-it merged 5 commits into
devfrom
54-adding-bulk-insert-support-to-telemetrycli
Sep 13, 2025
Merged

ArnavG-it merged 5 commits into
devfrom
54-adding-bulk-insert-support-to-telemetrycli

Conversation

@whatdoes3plus1equalsto

Copy link
Copy Markdown

closes #54

@whatdoes3plus1equalsto whatdoes3plus1equalsto linked an issue Jul 12, 2025 that may be closed by this pull request
@whatdoes3plus1equalsto
whatdoes3plus1equalsto changed the base branch from main to dev July 12, 2025 20:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds bulk CSV insert support to the TelemetryInputCli tool, allowing users to load data into specified tables via a config.yaml schema.

  • Introduce config.yaml and load_table_configs() to map table names to expected CSV columns.
  • Add do_bulk_insert CLI command and insert_data_from_df helper to parse and write CSV records.
  • Update dependencies, README, and .gitignore to support YAML configs and CSV handling.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tools/telemetryInputCli/telemetryInputCli.py Bulk insert logic, config loader, CSV parsing, and helper methods
tools/telemetryInputCli/config.yaml Table schemas mapping for bulk CSV insert
tools/telemetryInputCli/README.MD Documentation for YAML dependency, .env requirements, and bulk insert config
tools/telemetryInputCli/.gitignore Ignore .csv files
Comments suppressed due to low confidence (1)

tools/telemetryInputCli/telemetryInputCli.py:122

  • [nitpick] Consider adding automated tests for do_bulk_insert and insert_data_from_df to cover key scenarios: valid CSV loads, missing columns, invalid table names, and timestamp conversions.
    def do_bulk_insert(self, arg):

Comment on lines +17 to +19
df_config = List[str]

def load_table_configs() -> Dict[str, df_config]:

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

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

The df_config alias isn’t necessary; you can use List[str] directly in the function signature. Consider replacing df_config usage with List[str] and removing the alias to simplify the code.

Suggested change
df_config = List[str]
def load_table_configs() -> Dict[str, df_config]:
def load_table_configs() -> Dict[str, List[str]]:

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +35
print(f"Invalid unix timestamp: {unix_timestamp}")
return None

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

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

This function is annotated to return datetime but returns None on invalid input. Either update the return type to Optional[datetime] or raise an exception to avoid unexpected None values later.

Suggested change
print(f"Invalid unix timestamp: {unix_timestamp}")
return None
raise ValueError(f"Invalid unix timestamp: {unix_timestamp}. Unix timestamp must be non-negative.")

Copilot uses AI. Check for mistakes.
if time is not None:
data = row.get('temperature') if table == "temp" else row.get('luminosity')
if pd.notnull(data):
insertDataIntoWell(well_num, table, data, time, self.payloadTag, self.write_api, self.bucket, self.org)

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

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

The code passes the table name as the field when calling insertDataIntoWell, but it should use the configured field names (self.wellTempField or self.wellLuminField) so that the InfluxDB field matches the actual data column.

Copilot uses AI. Check for mistakes.
Comment thread tools/telemetryInputCli/README.MD Outdated

### .env file

The script reuires a file called '.env' with the following format:

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

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

Fix typo: change reuires to requires.

Suggested change
The script reuires a file called '.env' with the following format:
The script requires a file called '.env' with the following format:

Copilot uses AI. Check for mistakes.
@whatdoes3plus1equalsto

Copy link
Copy Markdown
Author

need more documentation about the csv format (e.g. UNIX timestamp)

@ArnavG-it

Copy link
Copy Markdown

Sorry about the wait. I've tested it on my end and it works well. The Python script could be cleaned up more but it's just a tool so it's fine for now. I also added some example CSVs for convenience. Thanks Hugo!

@ArnavG-it
ArnavG-it merged commit e74c003 into dev Sep 13, 2025
6 checks passed
@Koloss0
Koloss0 deleted the 54-adding-bulk-insert-support-to-telemetrycli branch October 5, 2025 21:39
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.

Adding bulk insert support to TelemetryCLI

4 participants