Skip to content

Conversation

@Fematich
Copy link
Contributor

@Fematich Fematich commented Jul 10, 2018

This pull request finishes the preparation of the io subpackage for Python 3 support. The work for io was started in #5715, however the py27-lint3 test was missing in tox.ini, resulting in some open issues and missing checks for new PRs.

The PR is part of a series in which all subpackages will be updated using the same approach.
This approach has been documented here and the first pull request in the series (Futurize coders subpackage) demonstrating this approach can be found at #5053.

R: @aaltay @tvalentyn @RobbeSneyders @charlesccychen @superbobry

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
--- --- --- ---

@charlesccychen
Copy link
Contributor

Run Python PostCommit

@charlesccychen
Copy link
Contributor

Run Python Dataflow ValidatesRunner

Copy link
Contributor

@superbobry superbobry left a comment

Choose a reason for hiding this comment

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

LGTM.

FYI #5869 replaces all NameError-based dispatch with past imports, including the ones you change in this PR.

Copy link
Contributor

@charlesccychen charlesccychen left a comment

Choose a reason for hiding this comment

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

Thanks!

and self._start == other._start and self._end == other._end)

def __hash__(self):
return hash((type(self), self._start, self._end))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add self._split_freq to __eq__ and __hash__?

return type(self) == type(other) and self.__dict__ == other.__dict__

def __hash__(self):
return hash((type(self), self.__dict__))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does self.__dict__ work here for hashing?

return self.stat == other.stat and self.getvalue() == self.getvalue()

def __hash__(self):
return hash((self.stat, self.getvalue()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the dictionary self.stat?

(other.name, other.genotype, other.phaseset, other.info))

def __hash__(self):
return hash((self.name, self.genotype, self.phaseset, self.info))
Copy link
Contributor

Choose a reason for hiding this comment

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

self.info is a dict. Is this a problem?

@Fematich Fematich force-pushed the io branch 2 times, most recently from b0579e9 to 64298fa Compare July 13, 2018 15:13
@aaltay
Copy link
Member

aaltay commented Jul 13, 2018

R: @tvalentyn @charlesccychen

Copy link
Contributor

@tvalentyn tvalentyn left a comment

Choose a reason for hiding this comment

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

Thank you, @Fematich! Overall looks good, a few comments below. I think we can remove some of the added hash functions but others might be useful.

return type(self) == type(other) and self.__dict__ == other.__dict__

def __hash__(self):
return hash((type(self), frozenset(self.__dict__.items())))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be dead code. I suggest:

# To maintain compatibility with Python 3
__hash__ = None

self.attributes == other.attributes)

def __hash__(self):
return hash((type(self), self.payload, self.attributes))
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's simplify this to hash(self.payload).

def __eq__(self, other):
return self.stat == other.stat and self.getvalue() == self.getvalue()

def __hash__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be dead code. I suggest:

# To maintain compatibility with Python 3
__hash__ = None

vars(self) == vars(other))

def __hash__(self):
return hash((type(self), vars(self)))
Copy link
Contributor

Choose a reason for hiding this comment

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

vars(self) is unhashable since it's a dict.
I think this would be dead code, so I suggest instead:

# To maintain compatibility with Python 3
__hash__ = None

(other.name, other.genotype, other.phaseset, other.info))

def __hash__(self):
return hash((self.name, self.genotype,
Copy link
Contributor

Choose a reason for hiding this comment

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

self.genotype is unhashable object. I think this would be dead code, so I suggest instead:

# To maintain compatibility with Python 3
__hash__ = None

and self._end == other._end
and self._split_freq == other._split_freq)

def __hash__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be dead code. I suggest:

# To maintain compatibility with Python 3
__hash__ = None

@tvalentyn
Copy link
Contributor

The test failure looks strange, perhaps something changed on master and we should rebase this?

@Fematich
Copy link
Contributor Author

Exactly, apparently a change in the master in the time between me doing a rebase (before the push to the branch) and the test being run :-p. Small window ;-). Pushing the updated commit now.

@tvalentyn
Copy link
Contributor

LGTM, thank you!

@aaltay aaltay merged commit 7bd73a5 into apache:master Jul 30, 2018
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.

5 participants