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

Add experimental machine learning #4585

Merged
merged 3 commits into from Aug 16, 2021
Merged

Conversation

decabeza
Copy link
Collaborator

Objectives

Add experimental enrichment of CONSUL by running machine learning python scripts.

Visual Changes

New admin section

before

Script execution

during

Script success

sucess

Settings before

settings_before

Settings after

settings_after

Help section

help

Email success

email_sucess

Email error

email_error

@decabeza decabeza added the Admin label Jul 12, 2021
@@ -19,6 +19,6 @@ def translation_for_locale(content, locale)
end

def information_texts_tabs
[:basic, :debates, :community, :proposals, :polls, :layouts, :mailers, :management, :welcome]
[:basic, :debates, :community, :proposals, :polls, :layouts, :mailers, :management, :welcome, :machine_learning]

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [116/110] (https://rubystyle.guide#max-line-length)


return unless run_machine_learning_scripts

if updated_file?(MachineLearning.proposals_taggings_filename) && updated_file?(MachineLearning.proposals_tags_filename)

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [125/110] (https://rubystyle.guide#max-line-length)

update_machine_learning_info_for("tags")
end

if updated_file?(MachineLearning.investments_taggings_filename) && updated_file?(MachineLearning.investments_tags_filename)

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [129/110] (https://rubystyle.guide#max-line-length)

files = { tags: [], related_content: [], comments_summary: [] }

files[:tags] << proposals_tags_filename if File.exists?(DATA_FOLDER.join(proposals_tags_filename))
files[:tags] << proposals_taggings_filename if File.exists?(DATA_FOLDER.join(proposals_taggings_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [112/110] (https://rubystyle.guide#max-line-length)

files[:tags] << proposals_tags_filename if File.exists?(DATA_FOLDER.join(proposals_tags_filename))
files[:tags] << proposals_taggings_filename if File.exists?(DATA_FOLDER.join(proposals_taggings_filename))
files[:tags] << investments_tags_filename if File.exists?(DATA_FOLDER.join(investments_tags_filename))
files[:tags] << investments_taggings_filename if File.exists?(DATA_FOLDER.join(investments_taggings_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [116/110] (https://rubystyle.guide#max-line-length)

files[:tags] << proposals_taggings_filename if File.exists?(DATA_FOLDER.join(proposals_taggings_filename))
files[:tags] << investments_tags_filename if File.exists?(DATA_FOLDER.join(investments_tags_filename))
files[:tags] << investments_taggings_filename if File.exists?(DATA_FOLDER.join(investments_taggings_filename))
files[:related_content] << proposals_related_filename if File.exists?(DATA_FOLDER.join(proposals_related_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [121/110] (https://rubystyle.guide#max-line-length)

files[:tags] << investments_tags_filename if File.exists?(DATA_FOLDER.join(investments_tags_filename))
files[:tags] << investments_taggings_filename if File.exists?(DATA_FOLDER.join(investments_taggings_filename))
files[:related_content] << proposals_related_filename if File.exists?(DATA_FOLDER.join(proposals_related_filename))
files[:related_content] << investments_related_filename if File.exists?(DATA_FOLDER.join(investments_related_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [125/110] (https://rubystyle.guide#max-line-length)

files[:tags] << investments_taggings_filename if File.exists?(DATA_FOLDER.join(investments_taggings_filename))
files[:related_content] << proposals_related_filename if File.exists?(DATA_FOLDER.join(proposals_related_filename))
files[:related_content] << investments_related_filename if File.exists?(DATA_FOLDER.join(investments_related_filename))
files[:comments_summary] << proposals_comments_summary_filename if File.exists?(DATA_FOLDER.join(proposals_comments_summary_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [140/110] (https://rubystyle.guide#max-line-length)

files[:related_content] << proposals_related_filename if File.exists?(DATA_FOLDER.join(proposals_related_filename))
files[:related_content] << investments_related_filename if File.exists?(DATA_FOLDER.join(investments_related_filename))
files[:comments_summary] << proposals_comments_summary_filename if File.exists?(DATA_FOLDER.join(proposals_comments_summary_filename))
files[:comments_summary] << investments_comments_summary_filename if File.exists?(DATA_FOLDER.join(investments_comments_summary_filename))

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [144/110] (https://rubystyle.guide#max-line-length)

@@ -22,7 +22,7 @@ def deploysecret(key)
set :use_sudo, false

set :linked_files, %w[config/database.yml config/secrets.yml]
set :linked_dirs, %w[.bundle log tmp public/system public/assets public/ckeditor_assets]
set :linked_dirs, %w[.bundle log tmp public/system public/assets public/ckeditor_assets public/machine_learning/data]

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [117/110] (https://rubystyle.guide#max-line-length)

@decabeza decabeza force-pushed the experimental_machine_learning branch from 6d97497 to e41127b Compare July 12, 2021 14:39
@javierm javierm force-pushed the experimental_machine_learning branch from e41127b to ab1ed5a Compare July 15, 2021 21:59
create :machine_learning_info, script: "proposals_summary_comments_textrank.py", kind: "comments_summary"
comments_file = MachineLearning::DATA_FOLDER.join(MachineLearning.comments_filename)
File.open(comments_file, "w") { |file| file.write([].to_json) }
proposals_comments_summary_file = MachineLearning::DATA_FOLDER.join(MachineLearning.proposals_comments_summary_filename)

Choose a reason for hiding this comment

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

Layout/LineLength: Line is too long. [126/110] (https://rubystyle.guide#max-line-length)

@javierm javierm force-pushed the experimental_machine_learning branch from ab1ed5a to 05ea442 Compare July 15, 2021 22:27
@javierm javierm force-pushed the experimental_machine_learning branch 3 times, most recently from 05ea442 to eafbfd6 Compare August 2, 2021 19:04
@javierm javierm force-pushed the experimental_machine_learning branch 4 times, most recently from b84a1ba to 2ed643b Compare August 3, 2021 17:33
@javierm javierm force-pushed the experimental_machine_learning branch 7 times, most recently from b075221 to 981711b Compare August 5, 2021 22:56
@javierm javierm force-pushed the experimental_machine_learning branch from 981711b to 28e4a30 Compare August 16, 2021 14:18
@javierm javierm force-pushed the experimental_machine_learning branch from 28e4a30 to 52029e6 Compare August 16, 2021 14:24
javierm and others added 3 commits August 16, 2021 16:30
Note we're using the `call` method (which is equivalent to adding an ERB
file) because we were getting an error calling `render` from the `dates`
method:

```
ActionView::Base#lookup_context delegated to
view_renderer.lookup_context, but view_renderer is nil:
```

It might be because we aren't rendering the
`Adming::Budgets::DurationComponent` but just calling one method, and so
there's no view context in this case.
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants