Postgresql record insertion
Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/postgresql-record-insertion
Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder
npx -y skills add HolobiomicsLab/asb-skill-collections --skill postgresql-record-insertionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when after successful gensim LDA inference has produced a JSON result file (e.g., myexp.ldaresult.json) and you need to make those topic assignments and model parameters queryable and accessible to a Django web application.
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.3 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
postgresql-record-insertion
Summary
Load gensim LDA result JSON files into a PostgreSQL database via command-line insertion. This skill bridges topic modeling output and persistent storage, enabling subsequent web-based visualization and querying of LDA topics inferred from metabolomics data.
When to use
After successful gensim LDA inference has produced a JSON result file (e.g., myexp.ldaresult.json) and you need to make those topic assignments and model parameters queryable and accessible to a Django web application. Use this when you have completed the corpus generation and LDA inference steps in the ms2ldaviz pipeline and are ready to populate the database for visualization.
When NOT to use
- LDA result JSON file has not yet been generated (run gensim step first)
- PostgreSQL database is not running or credentials are incorrect
- Experiment identifier already exists in the database (will cause collision or duplicate key error)
Inputs
- LDA result JSON file (myexp.ldaresult.json)
- PostgreSQL username (string, e.g., 'stefanv')
- Experiment identifier (string, e.g., 'myexp')
- Running PostgreSQL database instance (port 5432)
Outputs
- PostgreSQL database records containing LDA topics, word–topic associations, and experiment metadata
- Database record accessible to Django web application
- Experiment queryable by name in ms2ldaviz interface
How to apply
Execute the run_gensim.py insert command with three required arguments: the LDA result JSON filename, a PostgreSQL username (e.g., stefanv), and an experiment identifier (e.g., myexp). The command parses the JSON file containing topic distributions, word–topic associations, and metadata, then inserts records into the PostgreSQL schema. Verify success by confirming the absence of error messages and by querying the database to confirm the experiment record and associated topic data are accessible. For faster insertion, an alternative gensim-formatted workflow (insert_gensim) can be used, which excludes LDA info from the JSON and imports a gensim-native dataset format instead.
Related tools
- PostgreSQL (Target relational database for persistent storage of LDA results and experiment metadata)
- gensim (Prior LDA inference engine; produces JSON result files consumed by this insertion step)
- Python (run_gensim.py script interpreter for executing the insert command)
- Docker (Optional container runtime for PostgreSQL database instance)
- Django (Web application framework that queries the populated PostgreSQL database for visualization) — https://github.com/glasgowcompbio/ms2ldaviz
Examples
./run_gensim.py insert myexp.ldaresult.json stefanv myexp
Evaluation signals
- Command executes without errors or warnings; stdout/stderr is clean
- Database contains inserted records: query
SELECT * FROM experiments WHERE name='myexp'returns non-empty result - Topic and word–topic association records exist in their respective tables (e.g.,
topics,words,topic_word_assignments) - Django web application can retrieve and display the experiment in the
/uploads/interface - Row counts in database tables match expected structure (e.g., number of topics, number of unique words)
Limitations
- Requires pre-existing PostgreSQL database with schema initialized (run Django migrations first)
- Username must have INSERT and UPDATE privileges on the target schema
- Experiment identifier must be unique; duplicate names will fail insertion or produce database conflicts
- JSON file must conform to the expected gensim LDA output schema; malformed or incomplete files may cause parsing errors
- Alternative gensim-formatted insertion (insert_gensim) requires tarballing (tar -zcf) and manual tarball upload via web interface for some deployments
Evidence
- [other] The insert step consumes the LDA result JSON file (myexp.ldaresult.json) and loads it into the database using the command ./run_gensim.py insert with parameters for the result file, a username (stefanv), and an experiment name (myexp).: "The insert step consumes the LDA result JSON file (myexp.ldaresult.json) and loads it into the database using the command ./run_gensim.py insert with parameters for the result file, a username"
- [other] Execute the database insertion command via ./run_gensim.py insert with arguments: LDA result JSON filename, PostgreSQL username, and experiment identifier.: "Execute the database insertion command via ./run_gensim.py insert with arguments: LDA result JSON filename, PostgreSQL username, and experiment identifier."
- [readme] ./run_gensim.py insert myexp.ldaresult.json stefanv myexp: "./run_gensim.py insert myexp.ldaresult.json stefanv myexp"
- [readme] The last command inserts the gensim lda results into the database.: "The last command inserts the gensim lda results into the database."
- [readme] docker run --name some-pg -d -p 5432:5432 -e POSTGRES_PASSWORD=j7z3rL40w9 -e POSTGRES_USER=django postgres: "docker run --name some-pg -d -p 5432:5432 -e POSTGRES_PASSWORD=j7z3rL40w9 -e POSTGRES_USER=django postgres"