
From PHP to Python with the help of Amazon Q Developer
In this blog post I share how I was able to use Amazon Q Developer CLI to refactor code from one programming language to another
- it had not created all the routes required
- it had missed nearly all the templates needed to support the routes
- there were some issues with the data model having some missing entities
can you update the code, including the sql to work for a local sqlite db
when trying to run the createdb script it generates an error - RuntimeError(unboundmessage) from None RuntimeError: Working outside of application context.
- It was important to understand errors that came back, and then feed back the right supporting information back to Amazon Q Developer to help it suggest the right code updates. Initially when I was just feeding back the error messages, the problems persisted (and on one occasion got significantly worse). By reviewing and understanding the stack trace, I was able to add what I thought the root of the problem was and was then provided with good fixes that in most cases resolved the problem.
- I felt like I was playing the role of a QA or Test engineer, testing fixes as the code was being deployed and then feeding back issues that came up. I asked Amazon Q Developer to tackle these one at a time, as this provided the better responses. When provided a list of issues, it would make a good attempt but not always resolve them. It was only when I started tackling these one by one that I got much better success.
- Keeping the chat session going was important in improving the output produced. At one point I had to leave the session and then come back to a new window. I lost a lot of the memory and context, and the initial output did not align with the previous sessions which led to some more errors initially (for example, it had forgotten about renaming some of the data entities, which led to code errors - these were simple to fix, but demonstrated that the original session and history was important).
- In future attempts I am going to try and split out the source and destination directories separately to make it cleaner. As you will see from the repo, its all mixed together and aside from this making the project less readable, I worry that this might also confuse AI Coding Assistants (but I have no data to support that, just a hunch!)
- I should have used the /acceptall at the beginning of the session, to avoid Amazon Q Developer having to wait on me to press Y!
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.