Skip to content

Refactor: Reorganize codebase into installable package structure#8

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/refactor-repository-structure
Draft

Refactor: Reorganize codebase into installable package structure#8
Copilot wants to merge 6 commits into
mainfrom
copilot/refactor-repository-structure

Conversation

Copilot AI commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

Restructures repository from flat service-oriented layout to standard Python package structure, eliminating code duplication and enabling proper local development workflow.

Changes

Package Structure

  • Created src/irc_setfit_ollama_demo/ as installable package with:
    • common/ - Issue data model
    • config/ - Label and model configuration managers
    • models/ - Ollama and SetFit model interfaces
    • scraping/ - GitHub scraping utilities
  • Added pyproject.toml for dependency management
  • Moved utility scripts to scripts/
  • Added basic test suite in tests/

Service Refactoring

  • Reduced services/ui/app.py and services/setfit_inference/setfit_api.py to thin entrypoints
  • Services now import from package instead of duplicating code:
# Before: services/ui/app.py
from llm_model import llm_classify
from label_config_manager import get_label_manager
from scraping.github_scraper import scrape_github_issues

# After: services/ui/app.py  
from irc_setfit_ollama_demo.models import llm_classify
from irc_setfit_ollama_demo.config import get_label_manager
from irc_setfit_ollama_demo.scraping import scrape_github_issues

Build System

  • Updated Dockerfiles to install package via pip install -e .
  • Modified Makefile targets: install, install-dev replace per-service installs
  • Updated to Docker Compose v2 syntax (docker compose vs docker-compose)

Removed

  • common/ directory (consolidated into package)
  • Duplicate implementations in service directories
  • Per-service model/config/scraping modules

Installation

# Local development
make install

# With dev dependencies  
make install-dev

Services remain accessible via same Makefile targets (make run-ui, make docker-compose-up).

Original prompt

Refactor the repository structure to make local testing easier, follow standard Python project layout, and keep data out of src. Preserve functionality with Makefile and docker-compose.

Goals:

  • Move all shared and reusable Python code into src/irc_setfit_ollama_demo/ (make this an installable package).
  • Clean up service folders (services/ollama, services/setfit_inference, services/ui) so they only contain files needed for deployment and startup (entrypoints, configs, Dockerfile, NOT duplicated business logic).
  • All services should import shared logic from src/irc_setfit_ollama_demo/ instead of copying code.
  • Relocate test code under a top-level tests/ directory.
  • Move utility scripts (for local usage/testing/demo) into scripts/.
  • Data should remain top-level in data/, outside of src/.
  • Update Makefile and docker-compose if needed for compatibility with the new layout.
  • Cleanup README to clarify new structure and provide instructions for both local testing and Docker-based usage.
  • Do not copy logic between src and services. Only thin entrypoint wrappers in services, importing from src.

Example layout:

IRC-setfit-ollama-demo/
├── README.md
├── LICENSE
├── Makefile
├── docker-compose.yaml
├── requirements.txt / pyproject.toml
├── .gitignore
├── config/
├── data/
├── common/
├── src/
│   └── irc_setfit_ollama_demo/
│        ├── __init__.py
│        ├── main.py
│        ├── classifier.py
│        └── utils.py
├── tests/
├── scripts/
├── dockerfiles/
└── services/
    ├── ollama/
    ├── setfit_inference/
    └── ui/

Please implement these changes and keep the repository working as before, ensuring local development and testing is easy and code is not duplicated.

This pull request was created as a result of the following prompt from Copilot chat.

Refactor the repository structure to make local testing easier, follow standard Python project layout, and keep data out of src. Preserve functionality with Makefile and docker-compose.

Goals:

  • Move all shared and reusable Python code into src/irc_setfit_ollama_demo/ (make this an installable package).
  • Clean up service folders (services/ollama, services/setfit_inference, services/ui) so they only contain files needed for deployment and startup (entrypoints, configs, Dockerfile, NOT duplicated business logic).
  • All services should import shared logic from src/irc_setfit_ollama_demo/ instead of copying code.
  • Relocate test code under a top-level tests/ directory.
  • Move utility scripts (for local usage/testing/demo) into scripts/.
  • Data should remain top-level in data/, outside of src/.
  • Update Makefile and docker-compose if needed for compatibility with the new layout.
  • Cleanup README to clarify new structure and provide instructions for both local testing and Docker-based usage.
  • Do not copy logic between src and services. Only thin entrypoint wrappers in services, importing from src.

Example layout:

IRC-setfit-ollama-demo/
├── README.md
├── LICENSE
├── Makefile
├── docker-compose.yaml
├── requirements.txt / pyproject.toml
├── .gitignore
├── config/
├── data/
├── common/
├── src/
│   └── irc_setfit_ollama_demo/
│        ├── __init__.py
│        ├── main.py
│        ├── classifier.py
│        └── utils.py
├── tests/
├── scripts/
├── dockerfiles/
└── services/
    ├── ollama/
    ├── setfit_inference/
    └── ui/

Please implement these changes and keep the repository working as before, ensuring local development and testing is easy and code is not duplicated.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits November 22, 2025 15:51
Co-authored-by: peppocola <45401861+peppocola@users.noreply.github.com>
Co-authored-by: peppocola <45401861+peppocola@users.noreply.github.com>
Co-authored-by: peppocola <45401861+peppocola@users.noreply.github.com>
Co-authored-by: peppocola <45401861+peppocola@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor repository structure for easier local testing Refactor: Reorganize codebase into installable package structure Nov 22, 2025
Copilot AI requested a review from peppocola November 22, 2025 16: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.

2 participants