• Edd (unregistered)

    Frist data > Model data

  • doubtingposter (unregistered)

    I feel comfortable saying this wtf went over my head. I don't understand what the code snippet is even trying to do.

  • (author) in reply to doubtingposter

    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.

  • huppenzuppen (unregistered) in reply to doubtingposter

    Me too. I read this site for entertainment, and today's article's WTF was too technical to be entertaining.

  • ADHDeveloper (unregistered)

    "Darn it Jim I'm a ML researcher not a programmer"

  • shebang (unregistered)

    I am forced to use python 2 because management is afraid of having python 2 and 3 installed on the same machine.

  • Naomi (unregistered) in reply to shebang

    Then management is TRWTF. In other news, water's wet, a bear's Catholic, and the Pope shits in the woods.

  • West Coast Extendgers (unregistered) in reply to doubtingposter

    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.

  • OldCoder (unregistered) in reply to Naomi

    If a Pope shits in the woods, does anyone hear it fall?

  • I'm not a robot (unregistered)
    But far, far more annoying is that the super-class constructor, ModelBase.__init__, isn’t called until the end.
    Given that the code that runs before the super-class constructor is to determine the arguments to call the super-class constructor with, I'm not sure how you think it could work in any other order.
  • AAaaaaaa (unregistered) in reply to West Coast Extendgers

    Switch/case is okay, but much more Pythonic is if path in ['acceptable','model','names']: # do stuff

  • Sole Purpose of Visit (unregistered) in reply to ADHDeveloper

    It's a class, Jim, but not as we know it.

  • Prime Mover (unregistered) in reply to OldCoder

    The Pope himself, presumably. Do you reckon he has problems with it sticking to his fur?

  • (nodebb) in reply to West Coast Extendgers

    Write a switch statement

    This is Python. No such thing exists. You're not allowed to have efficient and clean concepts from other languages.

  • (nodebb)

    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.

  • Dave (unregistered) in reply to OldCoder

    I thought it's 'does the Pope shit in a bear's doc martens?'

  • not a python guy (unregistered)

    I don't know enough about Python to understand or appreciate today's WTF.

  • West Coast Extendgers (unregistered)

    ty it's been a while

  • (nodebb)

    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.

Leave a comment on “Learning the Hard Way”

Log In or post as a guest

Replying to comment #517363:

« Return to Article