Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iterjobs() without database #1222

Merged
merged 7 commits into from
Nov 22, 2023
Merged

Fix iterjobs() without database #1222

merged 7 commits into from
Nov 22, 2023

Conversation

jan-janssen
Copy link
Member

No description provided.

@jan-janssen jan-janssen linked an issue Nov 7, 2023 that may be closed by this pull request
@jan-janssen
Copy link
Member Author

@liamhuber It would be great if you can take another look at this pull request. It took far too long on my side but I definitely want to merge it soon, to move on.

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

I appreciate the comment above the magic-value list, I think that clarifies it perfectly.

Taking a deeper dive, there are a few things I still don't like about this PR:

  1. It is made to patch a bug, but there is no change to the test suite. I can't tell it's fixing the bug without manually running the example in iter_jobs() fails without database  #1221, and without a test we're not guaranteeing that this new and improved behaviour will stick around.

  2. The high-level inspect and load calls get replaced with the low-level load_from_jobpath call. It didn't take much digging to see why -- load and inspect don't accept db_entry, but these high-level calls were created for a reason: to more clearly signify the intent of the action. Instead, let's empower them to also handle a db_entry instead of a job specifier.

  3. By forcing convert_to_object=True in line 619, we are changing behaviour. This actually invalidates the signature of iter_jobs as convert_to_object becomes totally disused. I see the comment a couple lines above that we will deprecate convert_to_object...but deprecate it to what? Always false or always true? Now we're deprecating the variable, but the comment sticks around?? I don't know what the intended future behaviour is, but without clarifying that and updating the "backwards compatibility" comment, I'm not comfortable changing the behaviour.

I'm stacking a patching PR now that addresses all three of these concerns. EDIT: #1228

Comment on lines +585 to +587
if not isinstance(self.db, FileTable):
job_lst = [[job_id, None] for job_id in job_table["id"]]
else:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: it is a bit of a smell to if not isinstance(); else instead of if isinstance(); else as it increases cognitive load to mentally negate, but I also see the argument for putting the "default" case at the top so I want to point it out but am comfortable either way.

@jan-janssen
Copy link
Member Author

  1. It is made to patch a bug, but there is no change to the test suite. I can't tell it's fixing the bug without manually running the example in iter_jobs() fails without database  #1221, and without a test we're not guaranteeing that this new and improved behaviour will stick around.

I agree - thanks for adding the test.

  1. The high-level inspect and load calls get replaced with the low-level load_from_jobpath call. It didn't take much digging to see why -- load and inspect don't accept db_entry, but these high-level calls were created for a reason: to more clearly signify the intent of the action. Instead, let's empower them to also handle a db_entry instead of a job specifier.

From my perspective there are two levels of APIs in pyiron, the user interface which we use interactively and the internal interface the different pyiron objects use to interact with each other. I do not expect a user to write the db_entry in a dictionary to load an object, but for an internal function this is usually easy. Consequently, I do not think the internal calls should be forced to use the same interface as the users.

  1. By forcing convert_to_object=True in line 619, we are changing behaviour. This actually invalidates the signature of iter_jobs as convert_to_object becomes totally disused. I see the comment a couple lines above that we will deprecate convert_to_object...but deprecate it to what? Always false or always true? Now we're deprecating the variable, but the comment sticks around?? I don't know what the intended future behaviour is, but without clarifying that and updating the "backwards compatibility" comment, I'm not comfortable changing the behaviour.

This was a bug - that is fixed now.

@jan-janssen jan-janssen merged commit 7a5f178 into main Nov 22, 2023
21 of 22 checks passed
@delete-merged-branch delete-merged-branch bot deleted the iter_jobs_no_db branch November 22, 2023 15:40
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.

iter_jobs() fails without database
2 participants