NamamiShanker's Blog

Week 6: Continuing working on the frontend argparse

NamamiShanker
Published: 07/27/2022

Continuing working on the frontend in the draft PR

What did I do this week?

I implemented some changes suggested by reviewers on my draft PR

Firstly, I added typing support to the functions I have made. Therefore, currently: f2pyarg.py, service.py, utils.py have typing support. Initially I had added typing library for type annotations. But Bas Van Beek suggested to replace them with buitlins type annotations. These are not currently supported in Python versions below 3.9, but can be used by from __future__ import annotations statement. The __future__ module is somewhat unique in that import therefrom enable behaviours that will only become default in future python versions. Older examples of this include the print functions and with statement, but a more recent addition is the postponed evaluation of annotations (PEP 563), which implicitly stringifies all annotations during runtime (e.g. a: int automatically becomes a: "int"). 

However, for Any type annotation I would still need to rely on typing module. Also, the Optional type annotation can also be replaced by builtins by piping the type with None keyword. (e.g. arr: Optional[list] can be replaced by arr: list | None). The tests work fine with the changes and the frontend looks more complete. The mid evaluation starts from the next week and I would need to present the changes to writers of F2PY. I hope my work is ready.

What will I do next week?

I will fill out the mid evaluation form, and make changes according to the review.

Did I get stuck anywhere?

No, I mostly applied changes requested in the review. These were mostly clear requests with helpful reviewers who clarified any doubts I had.

View Blog Post

Week 5: The argparse F2PY is here

NamamiShanker
Published: 07/27/2022

Finishing with F2PY's new frontend

What did I do this week?

I am so happy to say that I have completed a working and functioning argparse frontend for F2PY. If you had read my last week's post, I had said that I still had to debug and implement a few changes for F2PY.

Specifically:-

1. F2PY's compilation tests were failing, because there were some bug in --f2cmap flag.
2. F2PY would not compile .pyf.src files.
3. I forgot to add version mentioning flag.

I have fixed all the bugs and updated my one and only draft PR: https://github.com/numpy/numpy/pull/21923

All the tests are working correctly and the new f2pyarg should work exactly as f2py2e used to work. Also I found a few bugs that I will report and add fix for. These bugs are:

1. No test for verifying F2PY will work with .pyf.src files.
2. F2PY's test_kind test fails on Max OSX M1 chip.

Also, Rohit and I decided to drop one of our original goals. Before GSoC started we thought it would be a good idea to replace the current class based tests of F2PY to modern fixtures based tests. But we dropped it as the class based structure was performing very well, and the classes were responsible for compiling modules for testing.

What will I do next week?

I need to add some documentation changes and a release note for the changes have taken place. That's probably all I need to do for the next week, if another bug doesn't pop up.

Did I get stuck anywhere?

No, this week was comparatively a smooth sailing. I had already built the framework last week and, all I needed to do was to fix the bugs.

View Blog Post

Week 4: Continuing F2PY's frontend

NamamiShanker
Published: 07/27/2022

Reimplemeting F2PY's frontend with `argparse`

What did I do this week?

I continued with implementing F2PY's frontend with argparse library. This week I implemented compilation functionality provided by F2PY in the frontend framework. I have written a detailed blog here: https://namamishanker.github.io/posts/argparse-f2py/

It was much more difficult that we expected, mostly because of the fact that we needed to maintain backwards compatibility with numpy's distutils. The full integration is still on the way and should be completed by the mid of the next week.

What will I do the next week?

I will continue to implement compilation functionality in F2PY. The base work has been done this week, but I still need to debug and verify the working of argparse F2PY. 

Did I get stuck anywhere?

I'm glad you asked that. I did get stuck a lot this week. The way f2py2e integrated with numpy.distutils was a bit messy and much more complicated than I earlier expected. Please go through my linked blog if you are interested in the details. But then again, you probably aren't. Just know that it was a bit difficult.

View Blog Post

Week 3: Renovating F2PY's frontend

NamamiShanker
Published: 07/06/2022

Reimplmenting F2PY's frontend with `argparse` library

What did I do this week?

This week I worked on re-implementing `f2py2e's` run_main() function in with `argparse` library. The aim is to split up one big f2py2e.py into 2 files. One file `f2pyarg.py` is responsible for parsing arguments file while other `service.py` deals with f2py core functionalities.

I have opened a draft PR here - https://github.com/numpy/numpy/pull/21923. I will continue to add my frontend contributions to this branch.

I have tried to be keep my distance from F2PY's core functionalities. These functions are convoluted with each other and a small change in one core functionality might break another.

What will I do next week?

Some upcoming goals are:- 

  • Implement run_main(). It is the function responsible for generating wrappers and .pyf files.
  • Implement run_compile() responsible for compiling and building shared libraries.
  • Decide and implement deprecation of flags. For ex. - `--f2py-wrapper-output`, `--skip-empty-wrappers`
  • Code cleanup. Will involve refactoring and deciding which flags belong to which subparser.

Did I get stuck anywhere?

It was difficult to integrate a new frontend to an existing and very old codebase. I kept getting stuck many times, but bebugged my way out of it. Currently some older tests are failing, but I think thats probably because of installation problems. Will look into it in the next meeting with my mentor Rogit Goswami.

View Blog Post

Week 2: A study of F2PY's backend build system

NamamiShanker
Published: 07/06/2022

Week 2  Moving F2PY to Meson build system

What did I do this week?

I did an extensive study on F2PY's build system functionality and what it would take to implement them in Meson. I wrote this extensive blog on Moving F2PY to Meson build system providing details.

I did not contribute any code this week as I was mostly studying Meson's documentation and finding f2py equivalent functionality.

 

What will I be doing next week?

I will start with implementing F2PY's frontend with `argparse` library.

 

Did I get stuck anywhere?

No, everything proceeds smoothly.

 

View Blog Post