Skip to content

Make the hyperliquid script import from csv#5176

Open
IvanIvanoff wants to merge 1 commit into
masterfrom
hyperliquid-from-csv
Open

Make the hyperliquid script import from csv#5176
IvanIvanoff wants to merge 1 commit into
masterfrom
hyperliquid-from-csv

Conversation

@IvanIvanoff
Copy link
Copy Markdown
Member

@IvanIvanoff IvanIvanoff commented May 21, 2026

Changes

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • Chores
    • The Hyperliquid source-slug mapping seed script now loads mappings from a CSV file (path required) instead of using built-in static configuration.
    • CSV parsing skips blank lines/comments, trims fields, and validates rows with clear error reporting.
    • Existing validation and conflict-resolution behavior is preserved; inline/no-argument execution is no longer supported and a usage/help message is shown when invoked incorrectly.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0c435c6-a95b-476d-8f65-88c358f08034

📥 Commits

Reviewing files that changed from the base of the PR and between 93f9912 and 80f6a79.

📒 Files selected for processing (1)
  • scripts/seed_hyperliquid_source_slug_mappings.exs

📝 Walkthrough

Walkthrough

Script refactored to accept a CSV path, parse {hl_coin, sanbase_slug} rows, and feed those mappings into the existing mapping-processing pipeline; top-level invocation now requires a CSV argument and prints usage/exit when missing.

Changes

CSV-driven Hyperliquid Mapping Seeding

Layer / File(s) Summary
API contract and documentation
scripts/seed_hyperliquid_source_slug_mappings.exs
Module docstring and run/1 signature updated to accept csv_path parameter. Documentation clarifies CSV format as {hl_coin, sanbase_slug} pairs linking Hyperliquid coins to Sanbase project slugs.
CSV loading and validation
scripts/seed_hyperliquid_source_slug_mappings.exs
New load_csv/1 helper verifies file existence, streams lines, skips blanks and # comments, parses comma-separated fields into trimmed tuples, and raises with line context on malformed rows.
CLI argument handling and entrypoint
scripts/seed_hyperliquid_source_slug_mappings.exs
Top-level execution now requires csv_path from command-line arguments, calls run/1 with the path, and prints usage message before exiting with code 1 when argument is missing. Removed old no-argument immediate invocation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • santiment/sanbase2#5168: This PR's CSV-driven SourceSlugMapping seeding feeds slug lookups used by downstream BboPrices timeseries calculations.

Poem

🐰 A CSV hops in, static maps now flee,
Parsers trim and count each cautious row,
Arguments guide the script where it should be,
Mappings born where Hyperliquid slugs go,
Tiny rabbit cheers — seeds planted, off they grow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: refactoring the hyperliquid seed script to import mappings from a CSV file instead of using inline static data.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hyperliquid-from-csv

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/seed_hyperliquid_source_slug_mappings.exs`:
- Around line 64-65: The pattern match that returns [{String.trim(coin),
String.trim(slug)}] allows empty coin or slug (e.g., ",bitcoin" or "btc,");
update the clause that matches [coin, slug | _] to trim both values and reject
them if either is blank by raising the same error (using idx and line) instead
of returning a mapping; reference the variables coin, slug, the call
String.trim, and the raise expression so you verify non-empty trimmed_coin and
trimmed_slug before producing the tuple.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 85277ff1-6f99-4e18-9f9d-635c2b9f7f4d

📥 Commits

Reviewing files that changed from the base of the PR and between a5d5ebe and 93f9912.

📒 Files selected for processing (1)
  • scripts/seed_hyperliquid_source_slug_mappings.exs

Comment thread scripts/seed_hyperliquid_source_slug_mappings.exs Outdated
@IvanIvanoff IvanIvanoff force-pushed the hyperliquid-from-csv branch from 93f9912 to 80f6a79 Compare May 21, 2026 13:03
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.

1 participant