DEV Community

Hyunjin Shin (Jin)
Hyunjin Shin (Jin)

Posted on • Updated on

Project Chronicles (Release 0.1)

/* This post will keep updated until this Friday(Sep 13). After this Saturday(Sep 14), the project progress will be updated in a new post */

Sep 10

I've started my project for osd600. It is a tool, written in Python, translating a source file written in one programming language into another language. The translation will be done by Large Language Model AI(such as ChatGPT).

So far, I have implemented a part that gets arguments and options user enters when running the tool and reads the file(checked if it is properly read by printing on console).
Currently, to run this tool in terminal, user needs to use this commend

python3 translator.py source_file -t python
Enter fullscreen mode Exit fullscreen mode

I personally find it ugly. Instead, what I want is running it with the following commend

translator source_file -t python -o result
Enter fullscreen mode Exit fullscreen mode

From my 3 hours research, I learned that I should use Poetry(.toml) to do this. I could create a script in bin folder connecting it to the python file with softlink(this is just for continuous update for changes).

How to run it without python3 and .py (generated by ChatGPT)

  1. Add Shebang: Ensure the script starts with #!/usr/bin/env python3.
  2. Move Script: Place the script in a directory like ~/bin and rename it to remove .py.
  3. Make Executable: Use chmod +x to make the script executable.
  4. Update PATH: Add the directory to your PATH environment variable.

However, it wouldn't work for other users, since it is set up locally. As a result, I need to use Poetry.
How it works is, it creates a virtual environment and generate a script in the virtual environment that can run the python script(the tool), so that I can run the python script without specifying "python3"

Since it is new to me and quite complicated, I need to study more about it.

There are a lot to do for release 0.1

  1. Using Poetry
  2. Integrating LLM API into the tool

Sep 11

I deleted the whole project and then recreated a new project since I messed up the project structure. I also changed the name into code-mage While I was trying to use Poetry, for some reason things were messed up and didn't work well. Therefore, I deleted the whole project and recreated it although I used the core logic of the previous the code.

I started the project with Poetry, and copied the core code into the new project and then integrated LLM API into the tool, and it translate the source_file into a target language.

It works, however, sometimes it gives unnecessary explanation or parts. Although I send the prompt with "system" like "Only display the code without anything else", it still gives some unnecessary part.

It only works for some core functions and options, I have a lot to do still. I can use the tool as follows

poetry run codemage <file>
Enter fullscreen mode Exit fullscreen mode

However, I still haven't figured out how to run it like:

codemage <file>
Enter fullscreen mode Exit fullscreen mode

I think that in order to do so I need to build and package the whole project and make available with pip or pipx. I don't know it yet, so I need to study during the weekends.

For Lab1, I am going to review Anh Chien Vu's project, and he will review my code. I had a short look at his project, and I think there are something that I can help or suggest.

Sep 13

In today's Lab Class, I saw a demo of one amazing student. He also implemented his tool with python, and it was better than my tool in every single way. I contacted him in Slack, and I am going to ask him how to package the tool and how can I run the tool without poetry run commend.

Today, I reviewed my code and applied the issues that other class mates left in my repo. I refactored my code and groomed it. There are still many things to improve and fix. I will work on it after this weekend.(I currently have too many assignments...)

Top comments (0)