packages feed

hydra-0.15.0: src/main/haskell/Hydra/Demos/Genpg/GeneratePython.hs

-- | Python code generation for the GenPG demo.
--
-- This module provides functions to generate all Python modules needed for
-- the GenPG demo, including:
--   - hydra.pg.model, hydra.pg.mapping
--   - hydra.pg.graphson.* (coder, construct, syntax, utils)
--   - hydra.encode.pg.*, hydra.decode.pg.*
--   - hydra.demos.genpg.transform
--   - hydra.demos.genpg.sales (sales database/graph schemas and mapping)
--   - hydra.demos.genpg.health (health database/graph schemas and mapping)
--
-- Usage from GHCI:
--   > import Hydra.Demos.GenPG.GeneratePython
--   > generatePythonModules

module Hydra.Demos.GenPG.GeneratePython where

import Hydra.ExtGeneration
import Hydra.Sources.All (kernelModules)
import Hydra.Sources.Ext (hydraExtModules, genpgModules)
import Hydra.Demos.GenPG.Modules (salesModule, healthModule)
import System.Directory (createDirectoryIfMissing)
import System.IO (hFlush, stdout)


-- | Generate all Python modules for the GenPG demo.
--
-- This generates to demos/src/main/python:
--   - hydra.pg.* modules
--   - hydra.demos.genpg.transform
--   - hydra.demos.genpg.sales
--   - hydra.demos.genpg.health
generatePythonModules :: IO ()
generatePythonModules = do
  let outputDir = "../../demos/src/main/python"
  createDirectoryIfMissing True outputDir

  putStrLn "=== Generate Python GenPG Modules ==="
  putStrLn ""
  putStrLn $ "Output directory: " ++ outputDir
  putStrLn ""
  putStrLn "Generating modules:"
  putStrLn "  - hydra.pg.model"
  putStrLn "  - hydra.pg.mapping"
  putStrLn "  - hydra.pg.graphson.* (coder, construct, syntax, utils)"
  putStrLn "  - hydra.encode.pg.*, hydra.decode.pg.*"
  putStrLn "  - hydra.demos.genpg.transform"
  putStrLn "  - hydra.demos.genpg.sales"
  putStrLn "  - hydra.demos.genpg.health"
  putStrLn ""
  hFlush stdout

  -- Universe includes kernel and hydra-ext modules for dependency resolution
  -- We generate genpgModules plus the sales and health modules
  let universeModules = kernelModules ++ hydraExtModules ++ [salesModule, healthModule]
  let modulesToGenerate = genpgModules ++ [salesModule, healthModule]
  writePython outputDir universeModules modulesToGenerate

  putStrLn ""
  putStrLn "=== Done! ==="