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

running "bazel build //cc/google/fhir_examples:ParsePatients" on Ubuntu creates errors #9

Closed
KiwiFPVHarry opened this issue Nov 9, 2020 · 12 comments

Comments

@KiwiFPVHarry
Copy link

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Repository fhir_bazel_pip_dependencies instantiated at:
/home/h/fhir-examples/WORKSPACE:23:12: in
/home/h/.cache/bazel/_bazel_h/53cd8c1ffe775ea94a7e4204fd2a4fc0/external/rules_python/python/pip.bzl:128:15: in pip3_import
Repository rule pip_import defined at:
/home/h/.cache/bazel/_bazel_h/53cd8c1ffe775ea94a7e4204fd2a4fc0/external/rules_python/python/pip.bzl:51:29: in
ERROR: An error occurred during the fetch of repository 'fhir_bazel_pip_dependencies':
Traceback (most recent call last):
File "/home/h/.cache/bazel/_bazel_h/53cd8c1ffe775ea94a7e4204fd2a4fc0/external/rules_python/python/pip.bzl", line 49, column 13, in _pip_import_impl
fail("pip_import failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: pip_import failed: (Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in run_code
exec(code, run_globals)
File "/home/h/.cache/bazel/bazel_h/53cd8c1ffe775ea94a7e4204fd2a4fc0/external/rules_python/tools/piptool.par/main.py", line 71, in
File "/tmp/tmpusr4m7d
/pip-tmp/pip/init.py", line 43, in
from pip.utils import get_installed_distributions, get_prog
File "/tmp/tmpusr4m7d
/pip-tmp/pip/utils/init.py", line 23, in
from pip.locations import (
File "/tmp/tmpusr4m7d
/pip-tmp/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py)
)
ERROR: no such package '@fhir_bazel_pip_dependencies//': pip_import failed: (Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in run_code
exec(code, run_globals)
File "/home/h/.cache/bazel/bazel_h/53cd8c1ffe775ea94a7e4204fd2a4fc0/external/rules_python/tools/piptool.par/main.py", line 71, in
File "/tmp/tmpusr4m7d
/pip-tmp/pip/init.py", line 43, in
from pip.utils import get_installed_distributions, get_prog
File "/tmp/tmpusr4m7d
/pip-tmp/pip/utils/init.py", line 23, in
from pip.locations import (
File "/tmp/tmpusr4m7d
/pip-tmp/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py)
)

@KiwiFPVHarry
Copy link
Author

Python is version 3.8.6, Bazel is verison 3.7.0, Java 11.0.9, Ubuntu 20.10 64 bit.

@Cam2337
Copy link

Cam2337 commented Nov 9, 2020

Hi @KiwiFPVHarry!

Could you confirm whether there's a pip binary installed for your Python interpreter?

python3 --version
python3 -m pip

The Bazel workspace installs pip requirements during setup, and in doing so will require pip to be discoverable on your PATH. Even if you're trying to build for a target in //cc/... you'll need to have an environment that supports the workspace setup.

Based on the error message you may need to install python3-distutils it seems? I'd be curious to see if:

apt list | grep -i distutils

shows anything?

@Cam2337
Copy link

Cam2337 commented Nov 9, 2020

We'll look at to see if there's any way we can split this more cleanly too -- as for someone just interested in //cc/..., it seems unnecessary to also provision Python, go, ..., etc.

@KiwiFPVHarry
Copy link
Author

KiwiFPVHarry commented Nov 9, 2020

after installing pip it has now completed only to get the next error when tryignt o run bazel-bin

bazel build //cc/google/fhir_examples:ParsePatients
Starting local Bazel server and connecting to it...
INFO: Analyzed target //cc/google/fhir_examples:ParsePatients (60 packages loaded, 2452 targets configured).
INFO: Found 1 target...
Target //cc/google/fhir_examples:ParsePatients up-to-date:
bazel-bin/cc/google/fhir_examples/ParsePatients
INFO: Elapsed time: 19.726s, Critical Path: 2.24s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
h@h-virtual-machine:~/fhir-examples$ bazel-bin/cc/google/fhir_examples:ParsePatient $WORKSPACE
bash: bazel-bin/cc/google/fhir_examples:ParsePatient: No such file or directory

@Cam2337
Copy link

Cam2337 commented Nov 9, 2020

h@h-virtual-machine:~/fhir-examples$ bazel-bin/cc/google/fhir_examples:ParsePatient $WORKSPACE
bash: bazel-bin/cc/google/fhir_examples:ParsePatient: No such file or directory

Ah I see -- this looks to be an error in the README.md which I've since corrected internally. The corrected documentation will be included in the next push to the public repo.

Try running:

bazel-bin/cc/google/fhir_examples/ParsePatients $WORKSPACE

Which is just a relative path to the compiled binary created from the bazel target: //cc/google/fhir_examples:ParsePatients.

Let me know if that ends up fixing things for you!

@KiwiFPVHarry
Copy link
Author

Thank you - running now..should taht take quite some time? running on a Ubuntu VM inside of WIndows

@Cam2337
Copy link

Cam2337 commented Nov 9, 2020

It shouldn't be considerably long, maybe a minute or so, to parse all 1000 records. It should be dumping to STDOUT as well as it's making progress. What are you seeing?

@KiwiFPVHarry
Copy link
Author

Reading /home/h/fhirdata and blinking cursor...for about 10 minutes already

@KiwiFPVHarry
Copy link
Author

did just run it again...cursor stops blinking after a few seconds

@Cam2337
Copy link

Cam2337 commented Nov 9, 2020

Yeah something's not right. I'm guessing that the generate_synthea.sh script didn't execute properly, and that you have no files in $WORKSPACE/ndjson. Could you verify if this is true?

ls $WORKSPACE/ndjson/

@KiwiFPVHarry
Copy link
Author

all good now..have re-run the synthea script after deleting all but top folder and then all the commands executed successfully..:) thnaks for all the help..:)

@Cam2337
Copy link

Cam2337 commented Nov 10, 2020

Glad to hear it! :)

To add some additional context for what you might have encountered -- unfortunately the generate_synthea.sh script can fail certain steps but continue execution and appear as though it succeeded. I noticed, for example, on one Ubuntu VM, that since I didn't have a bazel alias (the correct invocation was bazel-3.2.0), the bazel build @com_google_fhir//java:SplitBundle command would fail but the rest of the script would continue. This resulted in no files output to $WORKSPACE/ndjson.

Because of this, when we eventually would try to execute the compiled ParsePatients binary, we were actually spinning indefinitely within the while loop as no data was ever read, since no files existed within $WORKSPACE/ndjson to begin with. Hence the hanging cursor you were seeing after Reading <workspace> was printed to STDOUT.

I've added additional safety to parse_patients.cc so that it will error and exit clearly if these problems occur. I'll also look into adding some additional safety to generate_synthea.sh.

Glad things are working, thanks for your help and patience! :)

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

No branches or pull requests

2 participants