How vikashishere/circleci-gcp-mlops-ner-project works
1. What this repo is
- A Python-based NER pipeline project organized around MLOps-style stages: ingest data, transform it, train/evaluate a model, and publish the best artifact for later inference.
- The codebase is split into a reusable ner package plus a few top-level entry scripts and deployment/CI assets.
2. Main execution entry points
- train.py is the training entry script and likely orchestrates the end-to-end training pipeline.
- app.py and demo.py are separate top-level runtime entry points for running the application or a demo/inference flow.
- These scripts depend on the reusable pipeline classes under ner/pipeline.
3. Core pipeline boundary
- ner/pipeline/train_pipeline.py and ner/pipeline/prediction_pipeline.py are the two main orchestration boundaries.
- Training pipeline coordinates ingestion → transformation → training → evaluation → pushing.
- Prediction pipeline is the inference-side boundary and likely loads the exported tokenizer/model artifacts to produce entity predictions.
4. Data and model lifecycle
- Raw and intermediate assets live under data/ and gcp_download/, including archive.zip and ner.csv.
- Serialized inference artifacts at the repo root, tokenizer.pkl and ids_to_labels.pkl, indicate the model’s preprocessing and label decoding are persisted separately from the model itself.
- This separation matters for the architecture diagram: inference depends on both the trained model and these supporting artifacts.
5. Pipeline components
- ner/components/data_ingestion.py handles bringing dataset files into the project and/or cloud storage.
- ner/components/data_transforamation.py performs preprocessing and token/label preparation for NER training.
- ner/components/model_trainer.py trains the model.
- ner/components/model_evaluation.py compares trained output against expected metrics or baseline criteria.
- ner/components/model_pusher.py publishes the approved model artifact to the deployment/storage target.
6. Configuration and typed contracts
- ner/entity/config_entity.py and ner/entity/artifact_entity.py define the structured objects passed between stages.
- This is the repo’s main internal contract layer: components should not pass raw dictionaries around; they exchange typed config/artifact objects.
- ner/constants likely holds shared names/paths/keys used across the pipeline.
7. Cloud integration
- ner/configuration/gcloud.py suggests direct Google Cloud integration for bucket or storage access.
- The README and file layout indicate GCP is used for data/model storage and deployment support.
- gcp_download/ and the model-pushing component point to a workflow where artifacts are staged in cloud storage before deployment.
8. Cross-cutting support code
- ner/exception and ner/logger provide centralized error handling and logging across the pipeline.
- ner/utils/utils.py likely contains shared helpers for file I/O, serialization, path handling, or cloud interactions.
- These modules are infrastructure for observability and robustness, not business logic.
9. Packaging and runtime environment
- setup.py, requirements.txt, and template.py indicate the repo is meant to be installable as a Python package and runnable in repeatable environments.
- Dockerfile and .dockerignore show containerized execution is part of the architecture, probably for both training and serving.
- The project is therefore designed to run locally, in containers, and in cloud-backed environments.
10. CI/CD and infrastructure automation
- .circleci/config.yml provides the CI/CD boundary for build/test/deploy automation.
- scripts/VM-machine-setup.sh is a provisioning script for setting up a machine or VM environment.
- Together with Docker and GCP, this indicates the delivery path is automated rather than manual.
11. Experimentation and documentation artifacts
- notebooks/NER_using_BERT.ipynb is the experimentation workspace where the modeling approach was likely developed.
- flowchart/ and projectflow.txt appear to document the intended pipeline and are useful as architectural references.
- These are not runtime dependencies, but they explain how the model and pipeline were designed.
12. Likely end-to-end flow for the diagram
- Dataset source or downloaded archive → ingestion stage → transformation/preprocessing stage → model training → evaluation gate → model push/store.
- Inference path: application/demo entry point → prediction pipeline → load tokenizer/label map/model artifact → return entity labels for input text.
- CI/CD and Docker wrap both flows, while GCP serves as the external storage/deployment backbone.
Main entry points: train_pipeline.py Train pipeline · prediction_pipeline.py Predict pipeline · Dockerfile Docker · data_ingestion.py Ingestion
Components 24
Runtime entrypoints
Top-level scripts that launch training or inference flows.
Pipelines
Orchestration boundaries for training and prediction.
- Train pipeline · Coordinates ingestion, transformation, training, evaluation, and push.
ner/pipeline/train_pipeline.py - Predict pipeline · Loads persisted artifacts and produces entity predictions.
ner/pipeline/prediction_pipeline.py
Core components
Reusable stage implementations used by the pipelines.
- Ingestion · Brings dataset into local or cloud storage.
ner/components/data_ingestion.py - Transform · Prepares text and labels for NER training.
ner/components/data_transforamation.py - Trainer · Fits the NER model from transformed data.
ner/components/model_trainer.py - Evaluation · Checks trained model quality against criteria.
ner/components/model_evaluation.py - Pusher · Publishes the approved model artifact for deployment or storage.
ner/components/model_pusher.py
Contracts
Typed entities and shared constants passed across stages.
- Config entities · Structured configuration objects shared across stages.
ner/entity/config_entity.py - Artifact entities · Structured artifact objects handed between pipeline stages.
ner/entity/artifact_entity.py
Support code
Logging, exceptions, utilities, and cloud configuration.
- GCloud config · Google Cloud integration for storage and deployment support.
ner/configuration/gcloud.py - Utilities · Common file, serialization, and path helpers.
ner/utils/utils.py - Logger · Centralized logging used across the repo.
ner/logger - Exceptions · Shared exception handling layer.
ner/exception
Ops and delivery
Container, CI/CD, and environment automation.
Data and artifacts
Datasets, downloaded inputs, and persisted inference assets.
- Data files · Local dataset inputs and downloaded archives.
data - GCP download · Downloaded archive staged from cloud storage.
gcp_download - Tokenizer · Persisted preprocessing artifact used for inference.
tokenizer.pkl - Label map · Persisted id-to-label mapping used for decoding predictions.
ids_to_labels.pkl
Connections 25
- train.py → Train pipeline: starts · Training script launches the main orchestration pipeline.
- app.py → Predict pipeline: runs · Application entry point uses the inference pipeline.
- demo.py → Predict pipeline: runs · Demo entry point uses the inference pipeline.
- Train pipeline → Ingestion: ingests · The training flow begins by collecting data.
- Train pipeline → Transform: transforms · Training flow prepares NER inputs and labels.
- Train pipeline → Trainer: trains · Training flow fits the model.
- Train pipeline → Evaluation: evaluates · Training flow checks model quality.
- Train pipeline → Pusher: publishes · Approved artifacts are pushed for later use.
- Predict pipeline → Tokenizer: loads · Inference uses the persisted tokenizer.
- Predict pipeline → Label map: loads · Inference uses the label decoder mapping.
- Predict pipeline → GCP download: reads · Inference may read staged artifacts or inputs from cloud downloads.
- Ingestion → Data files: reads/writes · Ingestion moves dataset files in and out of local storage.
- Ingestion → GCloud config: uses · Ingestion depends on cloud access configuration.
- Transform → Config entities: uses · Transformation is configured through typed entities.
- Trainer → Artifact entities: uses · Trainer exchanges structured artifacts with other stages.
- Evaluation → Artifact entities: uses · Evaluation consumes and emits artifact metadata.
- Pusher → GCloud config: pushes to · Model pusher interacts with cloud storage or deployment targets.
- Train pipeline → Logger: logs · Pipeline stages emit logs through the shared logger.
- Train pipeline → Exceptions: handles · Pipeline errors flow through centralized exception handling.
- Predict pipeline → Utilities: uses · Inference helpers likely rely on shared utility functions.
- train.py → Packaging: depends on · Entry scripts rely on installable project packaging.
- Docker → train.py: runs · Container image can execute the training entry point.
- Docker → app.py: runs · Container image can execute the application entry point.
- CircleCI → Docker: builds · CI/CD likely builds and validates the container image.
- VM setup → Docker: prepares · Provisioning supports container or environment setup.