Skip to content

Commit

Permalink
Reduce Python INFO logging verbosity at start-up (#27577)
Browse files Browse the repository at this point in the history
* Reduce Python INFO logging verbosity at start-up

* Formatting
  • Loading branch information
jrmccluskey authored Jul 20, 2023
1 parent 51512ca commit 65ef488
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sdks/python/apache_beam/runners/worker/sdk_worker_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _import_beam_plugins(plugins):
for plugin in plugins:
try:
importlib.import_module(plugin)
_LOGGER.info('Imported beam-plugin %s', plugin)
_LOGGER.debug('Imported beam-plugin %s', plugin)
except ImportError:
try:
_LOGGER.debug((
Expand All @@ -61,7 +61,7 @@ def _import_beam_plugins(plugins):
plugin)
module, _ = plugin.rsplit('.', 1)
importlib.import_module(module)
_LOGGER.info('Imported %s for beam-plugin %s', module, plugin)
_LOGGER.debug('Imported %s for beam-plugin %s', module, plugin)
except ImportError as exc:
_LOGGER.warning('Failed to import beam-plugin %s', plugin, exc_info=exc)

Expand Down
10 changes: 5 additions & 5 deletions sdks/python/container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ func launchSDKProcess() error {
if err != nil {
return errors.New(
"failed to create a virtual environment. If running on Ubuntu systems, " +
"you might need to install `python3-venv` package. " +
"To run the SDK process in default environment instead, " +
"set the environment variable `RUN_PYTHON_SDK_IN_DEFAULT_ENVIRONMENT=1`. " +
"In custom Docker images, you can do that with an `ENV` statement. " +
fmt.Sprintf("Encountered error: %v", err))
"you might need to install `python3-venv` package. " +
"To run the SDK process in default environment instead, " +
"set the environment variable `RUN_PYTHON_SDK_IN_DEFAULT_ENVIRONMENT=1`. " +
"In custom Docker images, you can do that with an `ENV` statement. " +
fmt.Sprintf("Encountered error: %v", err))
}
cleanupFunc := func() {
os.RemoveAll(venvDir)
Expand Down
11 changes: 6 additions & 5 deletions sdks/python/container/piputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ func pipInstallRequirements(files []string, dir, name string) error {
// as possible PyPI downloads. In the first round the --find-links
// option will make sure that only things staged in the worker will be
// used without following their dependencies.
args := []string{"-m", "pip", "install", "-r", filepath.Join(dir, name), "--no-cache-dir", "--disable-pip-version-check", "--no-index", "--no-deps", "--find-links", dir}
args := []string{"-m", "pip", "install", "-r", filepath.Join(dir, name), "--no-cache-dir", "--disable-pip-version-check", "--no-index", "--no-deps", "--find-links",
"-q", dir}
if err := execx.Execute("python", args...); err != nil {
fmt.Println("Some packages could not be installed solely from the requirements cache. Installing packages from PyPI.")
}
// The second install round opens up the search for packages on PyPI and
// also installs dependencies. The key is that if all the packages have
// been installed in the first round then this command will be a no-op.
args = []string{"-m", "pip", "install", "-r", filepath.Join(dir, name), "--no-cache-dir", "--disable-pip-version-check", "--find-links", dir}
args = []string{"-m", "pip", "install", "-r", filepath.Join(dir, name), "--no-cache-dir", "--disable-pip-version-check", "--find-links", "-q", dir}
return execx.Execute("python", args...)
}
}
Expand Down Expand Up @@ -76,18 +77,18 @@ func pipInstallPackage(files []string, dir, name string, force, optional bool, e
// installed version will match the package specified, the package itself
// will not be reinstalled, but its dependencies will now be resolved and
// installed if necessary. This achieves our goal outlined above.
args := []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", "--upgrade", "--force-reinstall", "--no-deps",
args := []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", "--upgrade", "--force-reinstall", "--no-deps", "-q",
filepath.Join(dir, packageSpec)}
err := execx.Execute("python", args...)
if err != nil {
return err
}
args = []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", filepath.Join(dir, packageSpec)}
args = []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", "-q", filepath.Join(dir, packageSpec)}
return execx.Execute("python", args...)
}

// Case when we do not perform a forced reinstall.
args := []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", filepath.Join(dir, packageSpec)}
args := []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", "-q", filepath.Join(dir, packageSpec)}
return execx.Execute("python", args...)
}
}
Expand Down

0 comments on commit 65ef488

Please sign in to comment.