from Joshua import Patience

Over the last little while, I have worked to develop a tool to be used for parsing imports in python. This tool has had several different versions and specifications, but this week finally found its use. This week I decide to get into the belly of the beast, and begin hashing away at the improper imports in the keras, and tests directories.

Identifying The Problem

The purpose of the tool is to check for absolute and relative imports in a specified directory or file. Thanks to some intuition, my tool does exactly this! The results are a dictionary of filenames as keys, with the error(s) as values, which tells me the problem and on which line.

Screen Shot 2019-03-22 at 1.15.46 PM

Screen Shot 2019-03-22 at 1.18.02 PM

Absolute vs Relative

Anywhere a relative import can be used, an absolute can as well, just as with absolute and relative paths. This idea can be seen as follows:

Absolute

import PackageA.A1
import PackageA.SubA.A2

Relative

from . import A1
from .SubA import A2

The Solution

With everything set up, and my tool working, I began to pick away at dictionary full of errors, starting with the absolute imports. There were over 58 files with errors in them, all with at least 1 error. I began to go through the errors solving them one by one. Currently I have completed all import errors in the keras directory, changing relative imports to absolute, with only the tests directory to go.

Closing Thoughts

Given how long the keras directory took, the tests directory will take even longer. The tests directory has less files, but more errors to be fixed. This gives me an opportunity to get my hands dirty, and touch a number of files in the repository.

Until next time…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s