Skip to content

Add Python import tracking#41

Open
pixilcode wants to merge 13 commits intoproj/rust-rewritefrom
bb/python-import-tracking
Open

Add Python import tracking#41
pixilcode wants to merge 13 commits intoproj/rust-rewritefrom
bb/python-import-tracking

Conversation

@pixilcode
Copy link
Copy Markdown
Collaborator

NOTE: This PR is dependent on Fallback support and should not be reviewed until that PR is merged

This PR adds tracking for Python imports within a script by replacing the standard import mechanism (builtins.__import__) with a custom mechanism that tracks local imports.

Copy link
Copy Markdown
Contributor

@TimWhiting TimWhiting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me other than my bits of feedback. A lot of churn with the diagnostic change, which might have been better as a separate PR.

let (result, model_errors, expr_errors) =
runtime.eval_model_and_expressions(file, eval_expressions);

let mut model_saw_error_diagnostic = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is happening a lot, can we extract the error handling into a helper function?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would make sense. I'll add that in.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you split this file into smaller ones on purpose? Any reason for doing so? I would prefer to see fewer changes in a PR unless they are truly needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, once a file gets too big for me to navigate comfortably, I tend to split it up into smaller files. It speeds up development for me since I'm able to more effectively narrow down where I'm looking for something and I don't have to filter through as much content in a file.

Basically, it helps me to find things when code organization uses the file system rather than just the linear structure of text.

It makes sense to reduce the amount of file splitting in a PR, though. It can be hard to identify what is actually new content. Would it be better to submit a separate PR splitting a file before working with the split file? Also, do you believe that splitting this file is unnecessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a bunch of object boilerplate. I would keep it together. I would split large files when they have implementation details concerning different objects that make it natural to split. If the objects are small and the functions are simple I would keep them together.

Comment thread README.md

##### Fallback Calculations

Python functions may have dependencies that aren't always available, or may take a long time to run. You can specify a fallback calculation using the `?` operator. If the Python function fails (e.g., missing dependencies, runtime errors), Oneil will use the fallback and warn the user:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be clear that timeout is not currently supported, or support it with a flag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I can make that clear.

@pixilcode
Copy link
Copy Markdown
Collaborator Author

A lot of churn with the diagnostic change, which might have been better as a separate PR.

I agree. I started breaking up changes into smaller PRs with the three most recent PRs, but I didn't do it with Fallback support (submitted about a month ago).

Most of your feedback was actually on code submitted for Fallback support, so I'll make the changes in that PR then rebase this and future PRs off of that. The only commits that are supposed to be for this PR are the last three commits. Alas, Github stacked PRs aren't publicly available yet...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants