Python package for interacting with the PubPub v6 API (pubpub.org). Created for The Unjournal (unjournal.org) to automate the production process for evaluation packages.
90% automation achieved! Now supports importing Word documents with properly rendered tables directly via the PubPub API.
- Word Document Import: Upload
.docxfiles and import them with proper table rendering - Table Support: Tables are converted to native ProseMirror format (not raw HTML text)
- Automated Pipeline: HTML β Word β PubPub import with full formatting preservation
- Fixed Table Headers: Proper multi-row headers for metrics and journal ranking tables
from scripts.pubpub_automation.package_assembler import PaperMetadata, EvaluationData, EvaluationPackageData
from scripts.pubpub_automation.create_package_from_data import EvaluationPackageCreator
import conf
# 1. Define paper
paper = PaperMetadata(
title='Your Paper Title',
authors=['Author 1', 'Author 2'],
doi='10.1234/example'
)
# 2. Define evaluations
evaluations = [
EvaluationData(
ratings={'overall_assessment': 90, 'methods': 85},
review_source_type='latex', # or 'markdown', 'text'
review_source_path='/path/to/review.tex',
evaluator_name='Jane Doe',
is_public=False # Anonymous for draft mode
)
]
# 3. Create package
creator = EvaluationPackageCreator(
email=conf.email, password=conf.password,
community_url=conf.community_url, community_id=conf.community_id
)
package_data = EvaluationPackageData(paper=paper, evaluations=evaluations)
result = creator.create_package(package_data, draft_mode=True)
# Done! Package is live with all content automatically importedβ
Word Document Import - Import .docx files with tables via API
β
Automatic LaTeX Conversion - LaTeX reviews β markdown β PubPub
β
Automatic Ratings Tables - Generate formatted tables from data
β
Draft/Final Workflow - Anonymous posting β add names after consent
β
Template System - Auto-filled evaluation summaries
β
Coda Integration - Fetch evaluations from Coda.io (ready to test)
β
General Purpose - Works for any evaluation
from pypubpub import Pubshelper_v6
pubhelper = Pubshelper_v6(
community_url="https://unjournal.pubpub.org",
community_id="your-community-id",
email="your@email.com",
password="your-password"
)
pubhelper.login()
# Upload and import a Word document with tables
file_url = pubhelper.upload_file('evaluation_summary.docx')
file_size = os.path.getsize('evaluation_summary.docx')
# Import to pub - tables will render properly!
result = pubhelper.import_to_pub(pub_id, file_url, 'evaluation_summary.docx', file_size)| Task | Before | After |
|---|---|---|
| Convert LaTeX review | 30 min | Automatic |
| Create ratings tables | 20 min | Automatic |
| Fill templates | 20 min | Automatic |
| Import to PubPub | 20 min | Automatic |
| Total | 2-3 hours | ~12 minutes |
- AUTOMATION_COMPLETE.md - Complete automation overview
- docs/AUTOMATION_WORKFLOW.md - Detailed usage guide
- scripts/pubpub_automation/README.md - Quick reference
- AUTOMATION_STATUS.md - Current capabilities (85% automated)
- CLAUDE.md - Developer guide
# Install package in development mode
pip install -e .
# Or with dev dependencies
pip install -e ".[dev]"- Create
.envfile in repository root (already templated for you) - Add your Coda API credentials:
CODA_API_KEY=your_api_key_here CODA_DOC_ID=your_doc_id_here CODA_TABLE_ID=your_table_id_here
- See docs/CODA_SETUP.md for detailed instructions
# Check .env configuration
python scripts/coda_integration/check_env.py
# Test Coda connection (after adding API key)
python scripts/coda_integration/test_coda_connection.py
# Test LaTeX conversion
python scripts/pubpub_automation/latex_to_markdown.py input.tex output.mdpypubpub/
βββ pypubpub/ # Core API client library
β βββ Pubv6.py # Main API classes (Pubshelper_v6, EvaluationPackage)
β βββ utils.py # Utility functions
β βββ repec/ # RePEc metadata generation
β
βββ scripts/
β βββ pubpub_automation/ # NEW: Automated package creation
β β βββ create_package_from_data.py # Main automation script
β β βββ package_assembler.py # Package assembly
β β βββ latex_to_markdown.py # LaTeX converter
β β βββ ratings_table_generator.py # Table generator
β β βββ template_generator.py # Template system
β β
β βββ coda_integration/ # Coda.io API integration
β β βββ fetch_from_coda.py # Fetch evaluation data
β β βββ setup_coda.py # Setup wizard
β β βββ check_env.py # Verify configuration
β β
β βββ utilities/ # Utility scripts
β
βββ docs/ # Documentation
β βββ AUTOMATION_WORKFLOW.md # Complete usage guide
β βββ AUTOMATION_GUIDE.md # Original guide
β βββ CODA_SETUP.md # Coda setup instructions
β βββ CODA_WORKFLOW.md # Coda integration details
β
βββ examples/ # Example evaluation packages
β βββ evaluation_packages/
β βββ scale_use_heterogeneity/ # Working example
β
βββ tests/ # Test suite
# For LaTeX reviews, PDF ratings, local data
creator.create_from_files(
paper_metadata=paper,
evaluation_files=[...],
draft_mode=True
)# Fetch from Coda and create package
from scripts.coda_integration.fetch_from_coda import fetch_evaluation_data
coda_data = fetch_evaluation_data("Paper Title")
creator.create_from_coda(coda_data, paper_metadata)# Step 1: Draft (anonymous)
result = creator.create_package(package_data, draft_mode=True)
# Share with authors...
# Step 2: Final (with names after consent)
for eval in evaluations:
if evaluator_consented:
eval.is_public = True
result = creator.create_package(package_data, draft_mode=False)- β
.envfile gitignored - safe for credentials - β
conf.pygitignored - never committed - β
Sensitive evaluation data in
evaluation_data/confidential/(gitignored) - β Comprehensive .gitignore patterns for secrets
β οΈ Never commit API keys or passwordsβ οΈ Never commit evaluator pseudonyms or confidential comments
# Run all tests
pytest
# Run specific test
pytest tests/test_create/test_create_eval_package.py
# Test with verbose output
pytest -vTest configuration in tests/conf_settings.py (copy from tests/conf_settings_template.py).
Main API client with methods for:
get_many_pubs()- Query and retrieve pubscreate_pub()- Create new publicationsconnect_pub()- Link pubs togetherset_attribution()- Manage authorsreplace_pub_text()- Update contentdownloadpubexport()- Export in various formatsupload_file()- Upload files to PubPub's S3 storageimport_to_pub()- Import Word/HTML documents with proper table renderingimport_html_to_pub()- Convenience method for HTML import
High-level class for creating complete evaluation packages:
- Looks up paper metadata from DOI
- Creates evaluation summary + individual evaluations
- Sets up all connections
- Associates authors/evaluators
NEW automated workflow:
- Convert LaTeX/Word β Markdown
- Generate ratings tables
- Fill evaluation templates
- Import content to PubPub
- Handle draft/final modes
# Create from data with automation
python scripts/pubpub_automation/create_package_from_data.py --config config.jsonfrom pypubpub.scripttasks.backup import backupV6
backupV6(pubhelper=pubhelper, output_dir="./backups", format='plain')from pypubpub.repec import RePEcPopulator
populator = RePEcPopulator(pubhelper=pubhelper, inputdir="./repec_rdfs")
metadata = populator.build_metadata_file()- PubPub API Docs: https://www.pubpub.org/apiDocs
- The Unjournal: https://unjournal.org
- Production Work: https://github.com/daaronr/unjournalpubpub_production
- Task Tracking: https://coda.io/d/_dOyXJoZ6imx
- Automate evaluation package creation β 85% complete
- Enable ad-hoc adjustments and bulk fixes β Complete
- Build RePEc metadata β Complete
- Enable feeds and updates π§ In progress
- Coda integration π§ Ready to test
This is an internal tool for The Unjournal. For issues or questions:
- See documentation in
docs/ - Check
AUTOMATION_STATUS.mdfor current capabilities - Refer to
CLAUDE.mdfor development guidelines
Internal project for The Unjournal.
Status: Production-ready automation system (90% automated) Last Updated: December 2024 Maintainer: The Unjournal team