Page MenuHomeSoftware Heritage

Remove prepare() method from MetadataIndexer, it's inherited from BaseIndexer.
ClosedPublic

Authored by vlorentz on Oct 4 2018, 5:05 PM.

Diff Detail

Repository
rDCIDX Metadata indexer
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

I'm not sure on this one.

make test disagrees.

I did not check why for the moment.

make test passes on my computer. Could you copy-paste the output of make test?

In D482#9270, @vlorentz wrote:

make test passes on my computer. Could you copy-paste the output of make test?

Sure thing.

======================================================================
FAIL: test_revision_metadata_indexer (swh.indexer.tests.test_metadata.Metadata)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/tests/test_metadata.py", line 305, in test_revision_metadata_indexer
    self.assertEqual(expected_results, results)
AssertionError: Lists differ: [{'id[44 chars]f', 'translated_metadata': {'identifier': None[710 chars]: 7}] != [{'id[44 chars]f', 'indexer_configuration_id': 7, 'translated[13 chars]one}]

First differing element 0:
{'id'[43 chars]f', 'translated_metadata': {'identifier': None[709 chars]': 7}
{'id'[43 chars]f', 'indexer_configuration_id': 7, 'translated_metadata': None}

  [{'id': b'8dbb6aeb036e7fd80664eb8bfd1507881af1ba9f',
    'indexer_configuration_id': 7,
+   'translated_metadata': None}]
-   'translated_metadata': {'author': ['Andrew Nesbitt'],
-                           'codeRepository': [{'type': 'git',
-                                               'url': 'git+https://github.com/librariesio/yarn-parser.git'}],
-                           'description': ['Tiny web service for parsing '
-                                           'yarn.lock files'],
-                           'developmentStatus': None,
-                           'email': None,
-                           'identifier': None,
-                           'issueTracker': [{'url': 'https://github.com/librariesio/yarn-parser/issues'}],
-                           'keywords': [['yarn',
-                                         'parse',
-                                         'lock',
-                                         'dependencies']],
-                           'license': ['AGPL-3.0'],
-                           'maintainer': None,
-                           'name': ['yarn-parser'],
-                           'operatingSystem': None,
-                           'relatedLink': None,
-                           'softwareRequirements': [{'body-parser': '^1.15.2',
-                                                     'express': '^4.14.0',
-                                                     'yarn': '^0.21.0'}],
-                           'type': None,
-                           'url': ['https://github.com/librariesio/yarn-parser#readme'],
-                           'version': ['1.0.0']}}]
-------------------- >> begin captured logging << --------------------
swh.indexer: ERROR: Problem when indexing rev
Traceback (most recent call last):
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/metadata.py", line 175, in index
    detected_files)
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/metadata.py", line 230, in translate_revision_metadata
    c_metadata_indexer = ContentMetadataIndexer(tool, config)
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/metadata.py", line 36, in __init__
    super().__init__()
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/indexer.py", line 187, in __init__
    self.prepare()
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-indexer/swh/indexer/indexer.py", line 212, in prepare
    self.tools = list(self.register_tools(self.config['tools']))
KeyError: 'tools'
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 82 tests in 4.332s

FAILED (failures=1)
make: *** [../Makefile.python:22: test] Error 1

I have the same error with make test.
Maybe it's due to the initialization of the ContentIndexer during the RevisionIndexer.

Note that you are one commit behind on this diff but it shouldn't affect the result of the test.

I'll try adding more tests anyway.

Maybe it's due to the initialization of the ContentIndexer during the RevisionIndexer.

Right, It's totally that.
We do again some gymnastic to have both runtime and tests compliant.
That part needs to be simplified... if it's possible...

I'm considering ugly monkey-patching (config.parse_config_file call from within) as a more vertuous implementation than the current one. (<- for the tests only!)
Then again, i'd need to check my assertions.

Cheers,

The test passes and the duplicated code is gone, very nice.
But I should really write more tests, there are so many scenarios that aren't tested.

This revision is now accepted and ready to land.Oct 5 2018, 2:44 PM
This revision was automatically updated to reflect the committed changes.