emanjavacas / pie

A fully-fledge PyTorch package for Morphological Analysis, tailored to morphologically rich and historical languages.
MIT License
22 stars 10 forks source link

Unwrapping of main functionality from `run` functions #27

Closed emanjavacas closed 5 years ago

emanjavacas commented 5 years ago

Hi @PonteIneptique, I was wondering if there was a compelling reason to wrap all main blocks inside a run function (e.g. pie/scripts/evaluate.py)? I would prefer to unwrap them if it's ok, since that allows me to easily inspect the instantiated objects in the script (using python -i).

PonteIneptique commented 5 years ago

Well, I think so.

  1. This is what ends up being up at the CLI level : https://github.com/emanjavacas/pie/blob/master/pie/scripts/group.py . The if main should actually disappear now that I think about it.
  2. Having a cli registered function (using decorators) and a separate run function is good design because it allows to test it separately (I have had really bad time setting up test for comands and this design ends up being the easiest to deal with ultimately)
  3. A benefit but not technically the objective, this provides a simple to use API for users if they want to call that from within python.

Note that if you need to get access to some items inside, could we simply move some to Classes with __call__() and give access to some states ?

emanjavacas commented 5 years ago

Right. I had forgotten about the CLI. :-) Nevermind. I feel changing anything now in the suggested direction would make everything more difficult to maintain. I will just look for an alternative solution!