bcgov / bcgov/automated-statusing-tool
Monolithic Code - Should consider a refactor to something more modular
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
My understanding is that the current AST tool is a bit of a complex monolith and that Moez has already done a lot to try and make it a bit more modular.
Monolithic code structures are a bit difficult to interpret and work on collaboratively. As we look into developing this tool further, we should do so with an eye to smaller compoents which are orchestrated by a runner script. The benefit to this strategy is we might find efficiencies and components we can reuse going forward on other projects (possibly even a GeoBC Python library with many modules which are task focussed). We should keep going in the direction Moez was headed.
**A couple suggestions on how to refactor this code:**
- Each component should have one single job. Mishmashing analysis and output creation, etc...we can separate those out.
- A modular component needs a predictable input and output. These should be python objects which get passed around. Raw dataframes with rows and indexes should be made explicit. Instead of df[row]["Attribute"], these should be assigned to python objects someting like object.property (or object.method()) should be used.
- We should identify higher level functions with broad applicability (eg, BCGW query infrastructure) and consider rolling these into a GeoBC library.
- I haven't found an explict data model. This should be an artifact which gets created and stored in the repo. Changes should be documented.
- Each component should have meaningful error handling and error codes.
- Should look into logging at the orchestrator level, possible to put this into a geobc library?
- Each component should be testable and include a test input/output. If a function can only be tested by running the whole script/ pipeline, it is too monolithic.
- Configuration (paths, schemas, credentials, hard coded values, etc) should be entirely separate from the code and kept in a config/ env file.
Contributor guide
No contributing guide indexed for this repository
Research direction
No files, tests, or entry points are named, so begin by mapping the current AST tool and identifying the runner, analysis, output, configuration, and data-model boundaries. Define a modularization plan with explicit Python-object inputs and outputs, component-level tests, error handling, logging, and documented completion criteria before changing code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-engineering, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100