- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist data > Model data
Admin
I feel comfortable saying this wtf went over my head. I don't understand what the code snippet is even trying to do.
Admin
Let me try a new easy reader version: they dynamically create new classes at runtime, and then instantiate them, when they 100% DO NOT need to do that, and the way they do it is also wrong, based on how they call the superclass constructor.
Admin
Me too. I read this site for entertainment, and today's article's WTF was too technical to be entertaining.
Admin
"Darn it Jim I'm a ML researcher not a programmer"
Admin
I am forced to use python 2 because management is afraid of having python 2 and 3 installed on the same machine.
Admin
Then management is TRWTF. In other news, water's wet, a bear's Catholic, and the Pope shits in the woods.
Admin
Write a switch statement for each allowed env.modelname. Convince yourself that's a problem. If you want to add a new modelname, you will have to create a model file, and add a case to the switch statement. So extensibility.
Start thinking of the file api and read each env.modelname from disk.
This implementation wraps whatever is in that file in it's own class. Also it overwrites the file parameters with it's own. So no isolation in those files. All that work for extensibility is immediately thrown in the garbage. If you wanted to use that modelname file somewhere else, it's not the same as usual. Different types. Different arguments.
Also there's file api injection. What if the ML platform sends a '*' or '/' to your function, or if someone checks in something wront to the modelname directory?
I plead guilty to doing something similar with JS. RxJS uses module augmentation and patching. If I could I would use babel read file. I really don't know why. If I did it though I would do it in build time, not run time, and run a lot of tests on it and also alerts something new has been added.
Admin
If a Pope shits in the woods, does anyone hear it fall?
Admin
Admin
Switch/case is okay, but much more Pythonic is
if path in ['acceptable','model','names']: # do stuff
Admin
It's a class, Jim, but not as we know it.
Admin
The Pope himself, presumably. Do you reckon he has problems with it sticking to his fur?
Admin
This is Python. No such thing exists. You're not allowed to have efficient and clean concepts from other languages.
Admin
The article was interesting for how it showed up Remi's biases (for example,
__init__
is an initialiser, not actually a constructor, and worrying about exceptions in constructors is just weird) but the useless wrapper class is definitely best got rid of.Admin
I thought it's 'does the Pope shit in a bear's doc martens?'
Admin
I don't know enough about Python to understand or appreciate today's WTF.
Admin
ty it's been a while
Admin
Since learning Rust, I've started to prefer using factory methods, like Model.load_from_file(file) calling Model(fields) which merely initializes fields.
Addendum 2020-09-04 22:20: However, reading this post, I didn't realize the subclass was unnecessary.