Skip to content

HBASE-29454: Update hbase-examples scripts to be compatible with Python 3 - #7161

Merged
taklwu merged 11 commits into
apache:masterfrom
kgeisz:HBASE-29454-update-examples-to-python3
Jul 21, 2025
Merged

HBASE-29454: Update hbase-examples scripts to be compatible with Python 3#7161
taklwu merged 11 commits into
apache:masterfrom
kgeisz:HBASE-29454-update-examples-to-python3

Conversation

@kgeisz

@kgeiszkgeisz commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/HBASE-29454

Some Python scripts in hbase-examples were never updated from Python 2 to Python 3. This pull request updates those scripts to be compatible with Python 3. The scripts were updated using 2to3 -w <script>. They were verified using python3 -m compileall <script>. Python 3.11.12 was used for the conversion and verification.

This pull request also renames the gen-py directory found in hbase-examples/src/main/python/thrift1 and hbase-examples/src/main/python/thrift2 to gen_py. This is done because the gen_py module needs to be added to the import statement in the Python scripts in order to prevent import errors. Python does not allow dashes in module names, so the dash in the module name must be replaced with an underscore.

kgeisz added 4 commits July 16, 2025 13:38
Change-Id: Idaebd4e7272160848d20aab0820bfa54b5ceebf1
Change-Id: I2904aa1a5e52befed827bf57ada3bf12db71c0ef
Change-Id: I3793a29690f30eabdfc18c1cca1a6fb67d912b00
Change-Id: If0c0137358f392e06c9828c21aef898d8ecb3cc2
@taklwu
taklwu requested a review from CopilotJuly 16, 2025 20:56

This comment was marked as outdated.

taklwu
taklwu previously approved these changes Jul 16, 2025

@taklwutaklwu left a comment

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.

LGTM, mostly just add those missing parentheses for print function

@Apache-HBase

This comment has been minimized.

@taklwu

Copy link
Copy Markdown
Contributor

can you also check if hbase-server/src/main/python/hbase/merge_conf.py has anything to do with python3?

@Apache-HBase

This comment has been minimized.

Change-Id: If2cb2431b9826971ff90c6da93eccfe99b4cd9a6
@Apache-HBase

This comment has been minimized.

Change-Id: I543b962431dad73529f96341a87dd8d6609f8892
@kgeisz
kgeisz requested a review from CopilotJuly 17, 2025 00:03

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request updates Python scripts in the HBase examples to be compatible with Python 3. The changes were made using the 2to3 tool and address syntax differences between Python 2 and Python 3.

  • Updates print statements from Python 2 syntax to Python 3 function calls
  • Converts exception handling from Python 2 to Python 3 syntax
  • Updates string formatting to use modern f-string syntax
  • Replaces deprecated print statement redirection with modern file parameter

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
hbase-server/src/main/python/hbase/merge_conf.pyUpdates stderr print redirection to use file parameter
hbase-examples/src/main/python/thrift2/DemoClient.pyConverts print statements to function calls
hbase-examples/src/main/python/thrift1/demo_hbase_thrift_over_http_tls.pyUpdates print statements and string formatting to Python 3 syntax
hbase-examples/src/main/python/thrift1/DemoClient.pyComprehensive Python 3 conversion including print statements, exception handling, and error raising

Comment threadhbase-examples/src/main/python/thrift1/DemoClient.py Outdated
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@taklwu
taklwu self-requested a review July 17, 2025 04:26
@taklwu
taklwu dismissed their stale reviewJuly 17, 2025 04:26

need another round of review

@Apache-HBase

This comment has been minimized.

@Kota-SHKota-SH left a comment

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.

LGTM.

nit: Consider updating the shebangs for consistency with other py scripts.

kgeisz added 3 commits July 17, 2025 16:42
Change-Id: Ibd7cd5fb5113625cec45cfecb097085bbdd02ec1
Change-Id: I0e94cbf019ec815e90dbcc6368ad212b05522a29
Change-Id: Icfe904511d4a77173c3ba501ef8aa694a4d064d2
@kgeisz
kgeisz requested a review from taklwuJuly 17, 2025 23:51
@Apache-HBase

This comment has been minimized.

kgeisz added 2 commits July 17, 2025 17:01
Change-Id: Icb44cafecf10d650ed7c3746d7e3ae1975465932
Change-Id: I103e43ca65bf6f9aca52bf21f745f642e96e85b3
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@kgeisz

Copy link
Copy Markdown
ContributorAuthor

retest

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 33sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+0 🆗shelldocs0m 1sShelldocs was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ master Compile Tests _
+0 🆗mvndep0m 32sMaven dependency ordering for branch
+1 💚mvninstall4m 9smaster passed
+1 💚spotless0m 56sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗mvndep0m 11sMaven dependency ordering for patch
+1 💚mvninstall3m 36sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
-0 ⚠️pylint1m 24s/results-pylint.txtThe patch generated 3 new + 2022 unchanged - 4 fixed = 2025 total (was 2026)
+1 💚shellcheck0m 0sNo new issues.
+1 💚spotless0m 51spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 46sThe patch does not generate ASF License warnings.
14m 47s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7161/6/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#7161
JIRA IssueHBASE-29454
Optional Testsdupname asflicense codespell detsecrets spotless javac pylint shellcheck shelldocs
unameLinux 7f87da62357d 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 6a8dcb2
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count83 (vs. ulimit of 30000)
modulesC: hbase-server hbase-examples . U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7161/6/console
versionsgit=2.34.1 maven=3.9.8 pylint=2.15.5 shellcheck=0.8.0
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 28sDocker mode activated.
-0 ⚠️yetus0m 2sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+0 🆗mvndep0m 10sMaven dependency ordering for branch
+1 💚mvninstall3m 14smaster passed
+1 💚javadoc2m 35smaster passed
_ Patch Compile Tests _
+0 🆗mvndep0m 12sMaven dependency ordering for patch
+1 💚mvninstall3m 2sthe patch passed
+1 💚javadoc2m 36sthe patch passed
_ Other Tests _
+1 💚unit285m 18sroot in the patch passed.
304m 43s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7161/6/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#7161
JIRA IssueHBASE-29454
Optional Testsjavac javadoc unit
unameLinux f83cf3250189 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 6a8dcb2
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7161/6/testReport/
Max. process+thread count8619 (vs. ulimit of 30000)
modulesC: hbase-server hbase-examples . U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7161/6/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@taklwu
taklwu merged commit dd33e66 into apache:masterJul 21, 2025
1 check passed
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Jan 23, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
guluo2016 pushed a commit that referenced this pull request Feb 6, 2026
…on 3 (#7161) (#7671)
Signed-off-by: Peng Lu <lupeng@apache.org>
Co-authored-by: Kevin Geiszler <kgeiszler@cloudera.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 11, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 11, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 13, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 13, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 25, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
liuxiaocs7 pushed a commit to liuxiaocs7/hbase that referenced this pull request Feb 27, 2026
…on 3 (apache#7161)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
Reviewed by: Kota-SH <shanmukhaharipriya@gmail.com>
Sign up for freeto 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

@kgeisz@Apache-HBase@taklwu@Kota-SH