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

53 subphase support #54

Merged
merged 10 commits into from
Oct 1, 2020
Merged

53 subphase support #54

merged 10 commits into from
Oct 1, 2020

Conversation

bradybray
Copy link
Contributor

Merging in development branch for review. Added subphase support. Unsure how to execute scripts to test against live file but used test file provided by @lifflander to develop process.

@bradybray bradybray self-assigned this Jun 27, 2020
@bradybray bradybray requested review from ppebay and removed request for ppebay July 3, 2020 19:08
@lifflander
Copy link
Contributor

lifflander commented Jul 3, 2020

@bradybray Can you prefix your commit messages with the GitHub issue number for reference? On the VT repository we have automatic checks for this, but not on this repository.

Example commit message: "#53: adding processing for subphases"

This helps us refer to the work done by each commit via the issue

Copy link
Contributor

@ppebay ppebay left a comment

Choose a reason for hiding this comment

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

Can you please test with the new dataset data/vt_example_lb_stats_subphases/stats.0.out added by @lifflander and output result for comparison? Given the fact that the LB algorithm is unchanged (only considers phases), the result should be identical to that obtained without sub-phases. Or @PhilMiller @lifflander are we understanding this issue has having to perform LB after each subphase too?

@@ -140,14 +140,19 @@ def read(self, node_id, time_step=-1, comm=False):
n_entries = len(row)

# Handle three-entry case that corresponds to an object load
Copy link
Member

Choose a reason for hiding this comment

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

This comment is no longer accurate

# Converting these into integers and floats before using them or
# inserting the values in the dictionary
try:
phase, o_id = map(int, row[:2])
time = float(row[2])
Nsubphases = int(row[3])
# Trim first and last brackets
row[4] = float(row[4][1:])
Copy link
Member

Choose a reason for hiding this comment

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

Is this leaving all the subphase times between the first and last as unparsed text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that would appear to be the case. Given there is a number of sub phases there can be an additional loop that converts the strings to their respective types (floats I would assume).

Copy link
Member

Choose a reason for hiding this comment

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

I think you could do the same as seen a couple lines above, with map(float, row[first:last]). Given that, it would be nice if trimming out the brackets were applied separately from parsing the values.

I.e.

row[4] = row[4][1:]
row[-1] = row[-1][:-1]
row[4:] = map(float, row[4:])

Copy link
Member

Choose a reason for hiding this comment

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

Actually, better to not modify the row any more, and assign a separate variable

subphase_times = row[4:]
assert len(subphase_times) == Nsubphases
subphase_times[0] = subphase_times[0][1:]
subphase_times[1] = subphase_times[-1][:-1]
subphase_times = map(float, subphase_times)

for i in range(0,Nsubphases):
print("subphase-time-" + str(i) + "= {}".format(
row[4 + i]
end='')
Copy link
Member

Choose a reason for hiding this comment

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

If we had a parsing error, then we can't trust that the value of Nsubphases accurately represents the content of the row we failed to parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A parsing error? As in the CSV reader fails?

Copy link
Member

Choose a reason for hiding this comment

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

The parsing errors that could be caught by this except clause would be when the values within the row weren't suitable for conversion to int or float. If that happens, some of the variable assignments would have failed, and so our exception handling would raise new exceptions on accesses to undefined variables. Worse, if the failure is not on the first row, by Python's variable scoping rules, those variables will be initialized, with the values from previous loop iterations, and the error message will be horribly confused.

time))
time,
Nsubphases,
end=''))
Copy link
Member

Choose a reason for hiding this comment

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

Not the fault of this PR, but this entire print is questionable - we failed at parsing and hence assigning these variables, so try printing the variables that we didn't parse? The print should be of the (ideally unmodified) row

@bradybray
Copy link
Contributor Author

bradybray commented Jul 14, 2020

Can you please test with the new dataset data/vt_example_lb_stats_subphases/stats.0.out added by @lifflander and output result for comparison? Given the fact that the LB algorithm is unchanged (only considers phases), the result should be identical to that obtained without sub-phases. Or @PhilMiller @lifflander are we understanding this issue has having to perform LB after each subphase too?

@ppebay

Yes. I'll pull in the modules and try to run them against the included stat files.

Braden Mailloux added 3 commits July 15, 2020 14:26
…ated data containing random number of subphases composed of standard normal inputs. I did not alter the original data but instead generated some backup statistics for testing.

# Handle four-entry case that corresponds to a communication weight
elif n_entries == 5:
elif '[' not in row[4]:
Copy link
Member

Choose a reason for hiding this comment

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

The if and elif cover all possibilities. This elif should keep itself more narrowly tailored to the case it actually handles, so that the else still gets run for lines that aren't ever going to be parsed correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My latest commit addresses this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@lifflander lifflander left a comment

Choose a reason for hiding this comment

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

Looks like this is ready to me

@bradybray bradybray merged commit 48b26fc into develop Oct 1, 2020
@bradybray bradybray deleted the 53-subphase-support branch October 1, 2020 06:11
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.

4 participants