otsukare Thoughts after a day of work

Week notes - 2020 w14 - worklog - Human Core Dump

Human Core Dump

I worked as normal and until Wednesday evening, April 1st, 2020 and in the early hours of Thursday, April 2nd, 2020, I had an erratic heart incident that I thought was a stroke, but was probably an epilepsy. Fast forward. The body has been repaired I passed all the details of brain surgery. I will be probably slowly coming back into actions gradually. Thanks to the full webcompat team for the love and support and Mike Taylor for being always so human.

Just tremendously happy to be alive.

The interrupted work week below…

diagnosis

misc

test_results = ["/a/b/c.html", "/a/b/d.html", "/a/b/e.html", "/a/b/f.html", "/a/b/g.html"]
import os.path
os.path.commonprefix(test_results)
# '/a/b/'

but unfortunately it's not really path minded.

test_results = ["/a/b/cde.html", "/a/b/cdf.html"]
import os.path
os.path.commonprefix(test_results)
# '/a/b/cd'

which both makes sense and is slightly unfortunate at the same time.

from types import MappingProxyType
some_dict = {'fr': 'baguette', 'ja': 'furansupan'}
frozen_dict = MappingProxyType(some_dict)
frozen_dict['fr']
# 'baguette'
frozen_dict['fr'] = 'pain de mie' # heresy
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: 'mappingproxy' object does not support item assignment

fluent or not fluent in python for the webcompat ml code

I'm inheriting a machine learning project where I had 0 participation. And the learning curve is steep because of two things:

No specific blame to do here, but just different ways on how to think about specific code. I'm adding my comments on the code little by little, so I can keep track of my thoughts. There are a least two comments about modifying the object in place which makes me a bit uncomfortable.

Honestly I don't know if it's pythonic or not, but I find the code difficult to read and edgy if some operations are done in a different order

>>> class SomeClass:
...     def create_var(self):
            "instance method initializing a var list"
            var = []
...         self.var = var
...     def insert_to_var(self, value):
...         self.var.append(value)
...
>>> # This will work
>>> my_instance = SomeClass()
>>> my_instance.create_var()
>>> my_instance.insert_to_var(5)
>>> my_instance.var
[5]
>>> # But this will fail
>>> my_instance = SomeClass()
>>> my_instance.var
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'SomeClass' object has no attribute 'var'
>>> my_instance.insert_to_var(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in insert_to_var
AttributeError: 'SomeClass' object has no attribute 'var'

This seems more robust

>>> class SomeClass:
...     def __init__(self):
...         self.var = []
...     def insert_to_var(self, value):
...         self.var.append(value)
...
>>> my_instance = SomeClass()
>>> my_instance.var
[]
>>>

but i need to learn more about it.

git notes

git notes: Add or inspect object notes

Adds, removes, or reads notes attached to objects, without touching the objects themselves.

By default, notes are saved to and read from refs/notes/commits, but this default can be overridden. See the OPTIONS, CONFIGURATION, and ENVIRONMENT sections below. If this ref does not exist, it will be quietly created when it is first needed to store a note.

A typical use of notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log along with the original commit message.

There is a practical explanation given on AlBlue's blog.

commenting lines on specific commits in GitHub

It might also be possible to do it through comments on specific parts of the code. It might be simpler, plus it is sending a mail which will give nice links. I could even put a #tag inside the comment so it's easier to search, discriminate. To think.

Otsukare!