DEV Community


Posted on • Updated on

In Over My Head

Release 0.3

In Release 0.3 one of our tasks was to find another external repository to make a PR to. This was already really difficult to do when people were making repositories left and right during hacktoberfest, it got MUCH harder to find something for release 0.3.

I looked back over the repositories I had worked on in the past for hacktoberfest and most of them were up for hacktoberfest with the exception of Caprine but I did not want to do another darkmode css fix and as they say in their repo they are feature complete so I thought maybe I should try finding something else. Even just searching for a repository to contribute to is difficult, the more popular ones that you are most likely to come across when searching all seem incredibly involved and difficult to even understand at all, some of them like neovim use vimscript and lua which I have no idea how to work with but after taking a look at the neovim repo I wish I did. In any case, I did not have the time to learn a completely new language, or that was my thought process in any case.

Failure 1

At first I found what I thought was a good issue in fixing a docker compose for a project called Kinto. Essentially the problem they were having is that upon first starting up docker compose up frequently the database and the web site would start in the wrong order. I found a script I could use called which would be able to be run as a command in the docker compose yml to allow for the correct sequence of start ups. I can't remember the specifics now, but I remember in trying to build my own image of the kinto project to add the wait for it script to the scripts directory therein I ran into a problem I could not figure out. I decided I might not be advanced enough in my knowledge of Docker and of the Kinto project and moved on to the next possible repo.

Failure 2

This one I remember well because the wound is fresher. I do not know what I am doing with python and my path variables and never has it been more clear to me than in trying to get this repo to build.

Like with any other issue, I kind of look at it at large and think either "This seems do-able" or "Pass", this one was in the first category: openverse-catalog. I saw that I just had to add a string to some header and thought maybe this is something I can actually do. Maybe it was, I won't be able to find out because I could not get the project to run.

Instantly I ran into problems from trying to clone it. I forked the repo and tried cloning it into VS Code on my windows system and it did not want to go. I still don't know why but I opened a WSL2 of Ubuntu and cloned it in there and that worked, so after doing that I used explorer.exe . from my Ubuntu CLI to find where the files were to try and work with them.

This is where I have some unfortunate confessions to make about my knowledge or lack-thereof of my path variables. At first when I downloaded Python it was off of the Microsoft store, after having trouble installing pip packages I realized that was not the way and knocked it off, since then I downloaded 3 versions of Python: 3.8, 3.9 and 3.11. For some reason the Python command always used 3.8 and I still don't know why. I tried moving the other versions up on the path, I tried deleting python 3.8, even then it did not want to switch to another version instead it just complained:

C:\Users\stefe\podman-desktop>where python
INFO: Could not find files for the given pattern(s).
Enter fullscreen mode Exit fullscreen mode


In trying to figure out what was going on with python I also found that I had these alias settings in windows enabled which redirected to Microsoft/WindowsApps.

All this to say that when the project required me to run it in Python 3.10 I did not know how to do that.

For my own programs running python with the py command works fine, but when I try to run anything with python or python3 it's going to be a problem.

In any case, I managed to do the first few steps which was to create a virtual env in python, which I did with the py command which worked for me, but after that I am meant to source venv/bin/activate and I did not have a bin/activate, I did have a Scripts/activate which I tried just install with but it did not work and after having spent a long time messing around with my python versions on my path and learning how little I knew I was kind of upset and panicking.

At this point I really felt like I had to do something fast and that this was not going to be it.

I don't know if this one's a failure yet

I took a look at neovim and although I thought it was cool I also recognized I was wasting my time on stuff that I don't understand yet and I don't think I have the time to. Struggling to find something to work on still I went back through the OSD Slack chat and checked the open issues for podman, a repository my teacher David recommended, I found one that yet again I thought would be easy. I keep on thinking stuff is going to be easy. Nothing ever really is.

Here is the issue I chose to start working on and the one I currently have a draft PR up for: #822 and this is the draft PR

At first I thought, "Maybe I really can just manually concatenate the name of the extension and just handle it that way", to be honest it still crosses my mind because my solution is really not elegant.

What I did is I created a typescript class on each extension root directory for a logging wrapper that wraps console.* (log, warn and error). Each of the function overrides take an array of any type and variable size and they add the extensions name to the beginning of the list of arguments before applying console.{whatever}.

This results in 4 perfectly duplicate files of code and is very upsetting. I tried putting this log wrapping ts file a directory higher up but it ended up adding all of the extension names to the arguments list by the end so the result was [Lima-ext][Docker-ext][Kube-ext]logged message which was not exactly the goal.

I actually think that manual concatenation may have been the more conservative choice in this case given the amount of log methods that need an extension name appended to them but that is why I opened up a draft PR, I really need someone else's input on this because my brain is kind of fried from racing through repositories hoping I could find one I can make sense of.

Podman for the record is a huge project and very impressive but also one that I am barely coming to terms with for my small part right now (assuming what I am doing is on the right track). It's hard for me still after all of this time to understand how to get into a project so big, where do you start? How am I supposed to figure it all out for myself, is floundering while trying to write a log wrapper the way about it?

Well, that's what I'm doing, stay tuned and maybe you'll find out how it went :D

Edit 1:

I learned a few things since posting this, so lets get into it.

The issue that I am working on does not require me to write the log wrapping, that already existed in a much better form than what I had done, so I set about adding the extension to it.

At first I thought to get the stack I would have to throw an error and then I matched a hardcoded regular expression of the path to the extension files to the stack information.

Technically this worked but not the best idea, I learned that I don't have to throw an error to get access to the stack, I can just create an error object and access the stack property through it without throwing, so that is what I did.

//Create an error for its stack property
const stack = new Error().stack
Enter fullscreen mode Exit fullscreen mode

The next issue was that the list of extension names I was checking against was hardcoded, it is smarter to dynamically retrieve these somehow in case extensions are added for example.

At first I tried to find ways around editing the existing code but they all seemed to duplicate code so I made a private variable for the Extension Loader object, an object that already has its own listExtensions() method that maps some key values from the AnalyzedExtension member in the Extension Loader class to an array and returns that array of Extension Information.

Once I did that I could access the Extension IDs and the Extension names but it would also be best to take the path I want to match from the Extension Loader as well, so I added a path field to the Extension Information interface and added that field to be mapped from AnalyzedExtension to an array for me to use.

Afterwards, I could take that array and create a map in my own methods between extension path and extension name, then if I could find a match between my path and the stack information, I could return the name of the extension associated with it and append that to the console logs.

Edit 2

The regex that I was searching for was not platform agnostic, it did not work on the maintainer's Unix machine. I made two different regex to match, one for windows and one for other platforms, the maintainer let me know that if I just took the path, normalized it and used the string.includes method I did not have to use regex at all and that I was making it more complicated than it needed to be. So I did as he suggested, of course he was correct, it was much simpler and worked across platforms.

Top comments (0)