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

Refactor and improve Molecule API's SMILES endpoint for better maintainability and performance #2246

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

adambasha0
Copy link
Contributor

  • rather 1-story 1-commit than sub-atomic commits

  • commit title is meaningful => git history search

  • commit description is helpful => helps the reviewer to understand the changes

  • code is up-to-date with the latest developments of the target branch (rebased to it or whatever) => ⏩-merge for linear history is favoured

  • added code is linted

  • tests are passing (at least locally): we still have some random test failure on CI. thinking of asking spec/examples.txt to be commited

  • in case the changes are visible to the end-user,  video or screenshots should be added to the PR => helps with user testing

  • testing coverage improvement is improved.

  • CHANGELOG :  add a bullet point on top (optional: reference to github issue/PR )

  • parallele PR for documentation  on docusaurus  if the feature/fix is tagged for a release

@adambasha0 adambasha0 self-assigned this Nov 26, 2024
molecule = Molecule.find_or_create_dummy if molecule.blank?
end
return unless molecule
molecule = Chemotion::SmilesProcessor.new(params).process

Choose a reason for hiding this comment

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

Metrics/ClassLength: Class has too many lines. [244/200]

molecule = Molecule.find_or_create_dummy if molecule.blank?
end
return unless molecule
molecule = Chemotion::SmilesProcessor.new(params).process

Choose a reason for hiding this comment

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

Metrics/ClassLength: Class has too many lines. [242/200]

if svg.present?
svg_process = SVG::Processor.new.structure_svg(params[:editor], svg, molfile)
mol = molecule.molfile.lines.first(2)
if mol[1]&.strip&.match?('OpenBabel')

Choose a reason for hiding this comment

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

Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.

end
end


Choose a reason for hiding this comment

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

Layout/EmptyLines: Extra blank line detected.

iupac_name: 'cubane',
names: ['cubane']
}
context 'with decoupled true' do

Choose a reason for hiding this comment

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

RSpec/NestedGroups: Maximum example group nesting exceeded [4/3].

expect(m.molecule_svg_file).to match(/\w{128}\.svg/)
end

context 'with missing SVG file' do

Choose a reason for hiding this comment

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

RSpec/NestedGroups: Maximum example group nesting exceeded [4/3].

Copy link

LCOV of commit 71a02f6 during Continuous Integration #4167

Summary coverage rate:
  lines......: 65.5% (14087 of 21517 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@PiTrem PiTrem marked this pull request as draft November 29, 2024 13:50
@@ -30,59 +30,10 @@ class MoleculeAPI < Grape::API
optional :editor, type: String, desc: 'SVGProcessor', default: 'ketcher'
end
post do
smiles = params[:smiles]
svg = params[:svg_file]
molecule, temp_svg, ob_log = Chemotion::SmilesProcessor.new(params).process

Choose a reason for hiding this comment

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

Metrics/ClassLength: Class has too many lines. [242/200]


it 'returns a molecule instance with valid attributes' do
processor_result = described_class.new(params).process
binding.pry

Choose a reason for hiding this comment

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

Lint/Debugger: Remove debugger entry point binding.pry.

Copy link

LCOV of commit ab9722a during Continuous Integration #4170

Summary coverage rate:
  lines......: 65.8% (14137 of 21487 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@@ -30,59 +30,11 @@ class MoleculeAPI < Grape::API
optional :editor, type: String, desc: 'SVGProcessor', default: 'ketcher'
end
post do
smiles = params[:smiles]
svg = params[:svg_file]
result = Chemotion::SmilesProcessor.new(params).process
Copy link

Choose a reason for hiding this comment

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

Metrics/ClassLength: Class has too many lines. [243/200]

Copy link

github-actions bot commented Dec 2, 2024

LCOV of commit d8f2c96 during Continuous Integration #4174

Summary coverage rate:
  lines......: 65.9% (14159 of 21488 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

end

it 'has different inchikeys' do

Copy link

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

end

it 'creates a new bad molecule if it does not exist' do

Copy link

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.


it 'creates a new bad molecule if it does not exist' do

expect(described_class.find_by(inchikey: bad_info[:inchikey], is_partial: false))
Copy link

Choose a reason for hiding this comment

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

RSpec/VoidExpect: Do not use expect() without .to or .not_to. Chain the methods or remove it.

end

it 'does not create a good molecule after a bad one' do
molecule = described_class.find_or_create_by_molfile(bad_info[:molfile])
Copy link

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - molecule. Did you mean molecule_good?

molecule_good = described_class.find_or_create_by_molfile(good_info[:molfile])
expect(molecule_good).to be_persisted
expect(molecule_good.inchikey).to eq(good_info[:inchikey])
end
Copy link

Choose a reason for hiding this comment

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

RSpec/EmptyLineAfterExample: Add an empty line after it.

expect(molecule_good.inchikey).to eq(good_info[:inchikey])
end
it 'does not transform a bad smiles into molfile' do

Copy link

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

end
it 'does not transform a bad smiles into molfile' do

rw_mol = begin
Copy link

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.


rw_mol = begin
RDKitChem::RWMol.mol_from_smiles(smiles_bad)
rescue StandardError => e
Copy link

Choose a reason for hiding this comment

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

Layout/RescueEnsureAlignment: rescue at 105, 15 is not aligned with rw_mol = begin at 103, 6.

rw_mol = begin
RDKitChem::RWMol.mol_from_smiles(smiles_bad)
rescue StandardError => e
e.message
Copy link

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.

RDKitChem::RWMol.mol_from_smiles(smiles_bad)
rescue StandardError => e
e.message
end
Copy link

Choose a reason for hiding this comment

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

Layout/BeginEndAlignment: end at 107, 15 is not aligned with rw_mol = begin at 103, 6.

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

Successfully merging this pull request may close these issues.

2 participants