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