def run(self, start_time: float) -> ExitCode: self.scrub_pythonpath() options_bootstrapper = OptionsBootstrapper.create(env=self.env, args=self.args, allow_pantsrc=True) with warnings.catch_warnings(record=True): bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # We enable logging here, and everything before it will be routed through regular # Python logging. setup_logging(global_bootstrap_options, stderr_logging=True) if self._should_run_with_pantsd(global_bootstrap_options): try: remote_runner = RemotePantsRunner(self.args, self.env, options_bootstrapper) return remote_runner.run() except RemotePantsRunner.Fallback as e: logger.warning( "Client exception: {!r}, falling back to non-daemon mode". format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner # We only install signal handling via ExceptionSink if the run will execute in this process. ExceptionSink.install( log_location=init_workdir(global_bootstrap_options), pantsd_instance=False) runner = LocalPantsRunner.create( env=self.env, options_bootstrapper=options_bootstrapper) return runner.run(start_time)
def run(self, start_time: float) -> ExitCode: self.scrub_pythonpath() options_bootstrapper = OptionsBootstrapper.create( env=self.env, args=self.args, allow_pantsrc=True ) with warnings.catch_warnings(record=True): bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # Initialize the workdir early enough to ensure that logging has a destination. workdir_src = init_workdir(global_bootstrap_options) ExceptionSink.reset_log_location(workdir_src) setup_warning_filtering(global_bootstrap_options.ignore_pants_warnings or []) # We enable logging here, and everything before it will be routed through regular # Python logging. setup_logging(global_bootstrap_options, stderr_logging=True) if self._should_run_with_pantsd(global_bootstrap_options): try: remote_runner = RemotePantsRunner(self.args, self.env, options_bootstrapper) return remote_runner.run() except RemotePantsRunner.Fallback as e: logger.warning("Client exception: {!r}, falling back to non-daemon mode".format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner runner = LocalPantsRunner.create(env=self.env, options_bootstrapper=options_bootstrapper) return runner.run(start_time)
def run(self): # Register our exiter at the beginning of the run() method so that any code in this process from # this point onwards will use that exiter in the case of a fatal error. ExceptionSink.reset_exiter(self._exiter) options_bootstrapper = OptionsBootstrapper(env=self._env, args=self._args) bootstrap_options = options_bootstrapper.get_bootstrap_options() global_bootstrap_options = bootstrap_options.for_global_scope() ExceptionSink.reset_should_print_backtrace_to_terminal( global_bootstrap_options.print_exception_stacktrace) ExceptionSink.reset_log_location( global_bootstrap_options.pants_workdir) if global_bootstrap_options.enable_pantsd: try: return RemotePantsRunner(self._exiter, self._args, self._env, bootstrap_options).run() except RemotePantsRunner.Fallback as e: logger.warn( 'caught client exception: {!r}, falling back to non-daemon mode' .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner runner = LocalPantsRunner.create( self._exiter, self._args, self._env, options_bootstrapper=options_bootstrapper) runner.set_start_time(self._start_time) return runner.run()
def _run(self, is_remote, exiter, args, env, process_metadata_dir=None, options_bootstrapper=None): if is_remote: try: return RemotePantsRunner(exiter, args, env, process_metadata_dir).run() except RemotePantsRunner.RECOVERABLE_EXCEPTIONS as e: # N.B. RemotePantsRunner will raise one of RECOVERABLE_EXCEPTIONS in the event we # encounter a failure while discovering or initially connecting to the pailgun. In # this case, we fall back to LocalPantsRunner which seamlessly executes the requested # run and bootstraps pantsd for use in subsequent runs. logger.debug( 'caught client exception: {!r}, falling back to LocalPantsRunner' .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner return LocalPantsRunner( exiter, args, env, options_bootstrapper=options_bootstrapper).run()
def run(self): options_bootstrapper = OptionsBootstrapper(env=self._env, args=self._args) bootstrap_options = options_bootstrapper.get_bootstrap_options() ExceptionSink.set_destination( bootstrap_options.for_global_scope().pants_workdir) if bootstrap_options.for_global_scope().enable_pantsd: try: return RemotePantsRunner(self._exiter, self._args, self._env, bootstrap_options).run() except RemotePantsRunner.Fallback as e: logger.warn( 'caught client exception: {!r}, falling back to non-daemon mode' .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner runner = LocalPantsRunner.create( self._exiter, self._args, self._env, options_bootstrapper=options_bootstrapper) runner.set_start_time(self._start_time) return runner.run()
def run(self, start_time: float) -> ExitCode: self.scrub_pythonpath() options_bootstrapper = OptionsBootstrapper.create(env=self.env, args=self.args, allow_pantsrc=True) with warnings.catch_warnings(record=True): bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # We enable logging here, and everything before it will be routed through regular # Python logging. stdin_fileno = sys.stdin.fileno() stdout_fileno = sys.stdout.fileno() stderr_fileno = sys.stderr.fileno() with initialize_stdio(global_bootstrap_options), stdio_destination( stdin_fileno=stdin_fileno, stdout_fileno=stdout_fileno, stderr_fileno=stderr_fileno, ): # N.B. We inline imports to speed up the python thin client run, and avoids importing # engine types until after the runner has had a chance to set PANTS_BIN_NAME. if self._should_run_with_pantsd(global_bootstrap_options): from pants.bin.remote_pants_runner import RemotePantsRunner try: remote_runner = RemotePantsRunner(self.args, self.env, options_bootstrapper) return remote_runner.run(start_time) except RemotePantsRunner.Fallback as e: logger.warning( f"Client exception: {e!r}, falling back to non-daemon mode" ) from pants.bin.local_pants_runner import LocalPantsRunner # We only install signal handling via ExceptionSink if the run will execute in this process. ExceptionSink.install( log_location=init_workdir(global_bootstrap_options), pantsd_instance=False) runner = LocalPantsRunner.create( env=CompleteEnvironment(self.env), options_bootstrapper=options_bootstrapper) return runner.run(start_time)
def _run(self, is_remote, exiter, args, env, options_bootstrapper=None): if is_remote: try: return RemotePantsRunner(exiter, args, env).run() except RemotePantsRunner.RECOVERABLE_EXCEPTIONS as e: # N.B. RemotePantsRunner will raise one of RECOVERABLE_EXCEPTIONS in the event we # encounter a failure while discovering or initially connecting to the pailgun. In # this case, we fall back to LocalPantsRunner which seamlessly executes the requested # run and bootstraps pantsd for use in subsequent runs. logger.debug( 'caught client exception: {!r}, falling back to LocalPantsRunner' .format(e)) return LocalPantsRunner( exiter, args, env, options_bootstrapper=options_bootstrapper).run()
def run(self): # Register our exiter at the beginning of the run() method so that any code in this process from # this point onwards will use that exiter in the case of a fatal error. ExceptionSink.reset_exiter(self._exiter) options_bootstrapper = OptionsBootstrapper.create(env=self._env, args=self._args) bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # We enable Rust logging here, # and everything before it will be routed through regular Python logging. self._enable_rust_logging(global_bootstrap_options) ExceptionSink.reset_should_print_backtrace_to_terminal( global_bootstrap_options.print_exception_stacktrace) ExceptionSink.reset_log_location( global_bootstrap_options.pants_workdir) for message_regexp in global_bootstrap_options.ignore_pants_warnings: warnings.filterwarnings(action='ignore', message=message_regexp) # TODO https://github.com/pantsbuild/pants/issues/7205 if self._should_run_with_pantsd(global_bootstrap_options): try: return RemotePantsRunner(self._exiter, self._args, self._env, options_bootstrapper).run() except RemotePantsRunner.Fallback as e: logger.warn( 'caught client exception: {!r}, falling back to non-daemon mode' .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner if self.will_terminate_pantsd(): logger.debug("Pantsd terminating goal detected: {}".format( self._args)) runner = LocalPantsRunner.create( self._exiter, self._args, self._env, options_bootstrapper=options_bootstrapper) runner.set_start_time(self._start_time) return runner.run()
def run(self, start_time: float) -> ExitCode: self.scrub_pythonpath() options_bootstrapper = OptionsBootstrapper.create(env=self.env, args=self.args) bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # Initialize the workdir early enough to ensure that logging has a destination. workdir_src = init_workdir(global_bootstrap_options) ExceptionSink.reset_log_location(workdir_src) # We enable logging here, and everything before it will be routed through regular # Python logging. setup_logging(global_bootstrap_options) ExceptionSink.reset_should_print_backtrace_to_terminal( global_bootstrap_options.print_exception_stacktrace ) # TODO: When we remove this deprecation, we'll change the default for the option to true. deprecated_conditional( lambda: global_bootstrap_options.is_default("enable_pantsd"), removal_version="1.30.0.dev0", entity_description="--enable-pantsd defaulting to False", hint_message=( "Pantsd improves runtime performance and will be enabled by default in the 1.30.x " "stable releases. To prepare for that change, we recommend setting the " "`[GLOBAL] enable_pantsd` setting to `True` in your pants.toml or pants.ini file." ), ) if self._should_run_with_pantsd(global_bootstrap_options): try: return RemotePantsRunner(self.args, self.env, options_bootstrapper).run(start_time) except RemotePantsRunner.Fallback as e: logger.warning("Client exception: {!r}, falling back to non-daemon mode".format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner runner = LocalPantsRunner.create(env=self.env, options_bootstrapper=options_bootstrapper) return runner.run(start_time)
def run(self): self.scrub_pythonpath() options_bootstrapper = OptionsBootstrapper.create(env=self._env, args=self._args) bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # Initialize the workdir early enough to ensure that logging has a destination. workdir_src = init_workdir(global_bootstrap_options) ExceptionSink.reset_log_location(workdir_src) # We enable Rust logging here, # and everything before it will be routed through regular Python logging. self._enable_rust_logging(global_bootstrap_options) ExceptionSink.reset_should_print_backtrace_to_terminal( global_bootstrap_options.print_exception_stacktrace) ExceptionSink.reset_log_location( global_bootstrap_options.pants_workdir) # TODO https://github.com/pantsbuild/pants/issues/7205 if self._should_run_with_pantsd(global_bootstrap_options): try: return RemotePantsRunner(self._exiter, self._args, self._env, options_bootstrapper).run() except RemotePantsRunner.Fallback as e: logger.warning( "caught client exception: {!r}, falling back to non-daemon mode" .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner if self.will_terminate_pantsd(): logger.debug("Pantsd terminating goal detected: {}".format( self._args)) runner = LocalPantsRunner.create( self._args, self._env, options_bootstrapper=options_bootstrapper) runner.set_start_time(self._start_time) return runner.run()
def run(self): options_bootstrapper = OptionsBootstrapper(env=self._env, args=self._args) bootstrap_options = options_bootstrapper.get_bootstrap_options() if bootstrap_options.for_global_scope().enable_pantsd: try: return RemotePantsRunner(self._exiter, self._args, self._env, bootstrap_options).run() except RemotePantsRunner.Fallback as e: logger.debug( 'caught client exception: {!r}, falling back to non-daemon mode' .format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner return LocalPantsRunner( self._exiter, self._args, self._env, options_bootstrapper=options_bootstrapper).run()
def run(self, start_time: float) -> None: self.scrub_pythonpath() # TODO could options-bootstrapper be parsed in the runners? options_bootstrapper = OptionsBootstrapper.create(env=self.env, args=self.args) bootstrap_options = options_bootstrapper.bootstrap_options global_bootstrap_options = bootstrap_options.for_global_scope() # Initialize the workdir early enough to ensure that logging has a destination. workdir_src = init_workdir(global_bootstrap_options) ExceptionSink.reset_log_location(workdir_src) # We enable Rust logging here, # and everything before it will be routed through regular Python logging. self._enable_rust_logging(global_bootstrap_options) ExceptionSink.reset_should_print_backtrace_to_terminal( global_bootstrap_options.print_exception_stacktrace) if self._should_run_with_pantsd(global_bootstrap_options): try: RemotePantsRunner(self._exiter, self.args, self.env, options_bootstrapper).run() return except RemotePantsRunner.Fallback as e: logger.warning( "Client exception: {!r}, falling back to non-daemon mode". format(e)) # N.B. Inlining this import speeds up the python thin client run by about 100ms. from pants.bin.local_pants_runner import LocalPantsRunner runner = LocalPantsRunner.create( env=self.env, options_bootstrapper=options_bootstrapper) runner.set_start_time(start_time) runner.run()