From dbacd7fbfa03e42520e1dd795a0cd0701e68f6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 11 Apr 2024 18:39:49 +0200 Subject: [PATCH] Replace byebug with the debug gem included in Ruby Byebug hasn't been maintained for years, and it isn't fully compatible with Zeitwerk [1]. On the other hand, Ruby includes the debug gem since version 3.1.0. We tried to start using at after commit e74eff217, but couldn't do so because our CI was hanging forever in a test related to machine learning, with the message: > DEBUGGER: Attaching after process X fork to child process Y (Note this message appeared with debug 1.6.3 but not with the version we're currently using.) So we're changing the debug gem fork mode in the test so it doesn't hang anymore when running our CI. We tried to change the test so it wouldn't call `Process.fork`, but this required changing the code, and since there are no tests checking machine learning behavior with real scripts, we aren't sure whether these script would keep working after changing the code. [1] Issue 564 in https://github.com/deivid-rodriguez/byebug --- Gemfile | 2 +- Gemfile.lock | 17 +++++++++++++++-- spec/models/machine_learning_spec.rb | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index fdd7d9c47..7514d7801 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ gem "wkhtmltopdf-binary", "~> 0.12.6" group :development, :test do gem "bullet", "~> 7.1.6" - gem "byebug", "~> 11.1.3" + gem "debug", "~> 1.9.2" gem "factory_bot_rails", "~> 6.4.3" gem "faker", "~> 3.2.3" gem "i18n-tasks", "~> 0.9.37" diff --git a/Gemfile.lock b/Gemfile.lock index 537e4b816..538c88148 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,7 +106,6 @@ GEM bullet (7.1.6) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - byebug (11.1.3) cancancan (3.5.0) capistrano (3.18.1) airbrussh (>= 1.0.0) @@ -171,6 +170,9 @@ GEM daemons (1.4.1) dalli (3.2.8) date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) delayed_job (4.1.11) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.8) @@ -282,6 +284,10 @@ GEM ruby-vips (>= 2.0.17, < 3) invisible_captcha (2.3.0) rails (>= 5.2) + io-console (0.7.2) + irb (1.12.0) + rdoc + reline (>= 0.4.2) json (2.7.1) jwt (2.7.1) kaminari (1.2.2) @@ -438,6 +444,8 @@ GEM pronto-stylelint (0.10.3) pronto (>= 0.10, < 0.12) rugged (>= 0.24, < 2.0) + psych (5.1.2) + stringio public_suffix (4.0.7) puma (5.6.8) nio4r (~> 2.0) @@ -486,10 +494,14 @@ GEM rainbow (3.1.1) rake (13.1.0) rbtree3 (0.7.1) + rdoc (6.6.3.1) + psych (>= 4.0.0) recipient_interceptor (0.3.1) mail redcarpet (3.6.0) regexp_parser (2.9.0) + reline (0.5.1) + io-console (~> 0.5) request_store (1.6.0) rack (>= 1.4) responders (3.1.1) @@ -615,6 +627,7 @@ GEM net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) + stringio (3.1.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) terrapin (0.6.0) @@ -683,7 +696,6 @@ DEPENDENCIES autoprefixer-rails (~> 10.4.16) bing_translator (~> 6.2.0) bullet (~> 7.1.6) - byebug (~> 11.1.3) cancancan (~> 3.5.0) capistrano (~> 3.18.1) capistrano-bundler (~> 2.1.0) @@ -699,6 +711,7 @@ DEPENDENCIES cocoon (~> 1.2.15) daemons (~> 1.4.1) dalli (~> 3.2.8) + debug (~> 1.9.2) delayed_job_active_record (~> 4.1.8) devise (~> 4.9.3) devise-security (~> 0.18.0) diff --git a/spec/models/machine_learning_spec.rb b/spec/models/machine_learning_spec.rb index 1a0dd1735..a004b3fc9 100644 --- a/spec/models/machine_learning_spec.rb +++ b/spec/models/machine_learning_spec.rb @@ -378,6 +378,10 @@ describe MachineLearning do end describe "#run_machine_learning_scripts" do + let!(:original_fork_mode) { DEBUGGER__::CONFIG[:fork_mode] } + before { DEBUGGER__::CONFIG[:fork_mode] = "parent" } + after { DEBUGGER__::CONFIG[:fork_mode] = original_fork_mode } + it "returns true if python script executed correctly" do machine_learning = MachineLearning.new(job)