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

[utils] Add micro-mordred #190

Merged
merged 2 commits into from
Aug 22, 2018
Merged

[utils] Add micro-mordred #190

merged 2 commits into from
Aug 22, 2018

Conversation

valeriocos
Copy link
Member

@valeriocos valeriocos commented Aug 1, 2018

This code proposes a tiny version of mordred to execute just once raw, merge identities, enrich, panels tasks of mordred on a given set of backends (declared in a cfg file passed as input). The micro-mordred overcomes the current limitations of the p2o script in ELK, which is not able to execute multiple studies for the input backend and requires constant changes to align its logic with the ELK one. The micro-mordred isn't supposed to require constant changes, since there is not gap between its logic and the mordred one.

In order to execute the micro-mordred on git and github, an example of the command is shown below:
micro --raw --identities --enrich --panels --cfg ./setup.cfg --backends git github:issue github:pull.

@coveralls
Copy link

coveralls commented Aug 1, 2018

Pull Request Test Coverage Report for Build 468

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 52.613%

Totals Coverage Status
Change from base Build 464: 0.0%
Covered Lines: 1037
Relevant Lines: 1971

💛 - Coveralls

@aswanipranjal
Copy link
Contributor

@valeriocos I tried this with the github data source. These are the steps that are required to get the studies for github:

  • Step1: Generate the enriched index for issues category
  • Step2: Generate the enriched index for pull_requests category
  • Step3: run the studies for github

The steps Step1 and Step2 cannot be run simultaneously because currently, we can supply only one backend to the --backend flag in micro.py

For studies related to the github backend, we need the indices from both: issues and pull_request category because the enrich_onion study is done for both the categories simultaneously in grimoire-elk/enriched/github.py.

And to generate the enriched pull_requests only index too, we will need both the indices, thus we will need two backend sections.

Can you please modify the code so that we are able to run multiple backends simultaneously?
I tried it, something like this:

def micro_mordred(cfg_path, backend_sections, raw, arthur, enrich):
   
    config = Config(cfg_path)

    if raw:
        for backend in backend_sections:
            get_raw(config, backend, arthur)

    if enrich:
        for backend in backend_sections:
            get_enrich(config, backend)


def get_params_parser():
    """Parse command line arguments"""
...
parser.add_argument("--backend", dest='backend_sections', default=[],
                        nargs='*', help="Backend section to execute")

Please comment if this makes sense?

@valeriocos
Copy link
Member Author

Thank you @aswanipranjal for the suggestions! I have just modified the PR, which now includes the changes you proposed (the example has been modified accordingly as well).

Let me know if you have any other suggestion or feedback.

@aswanipranjal
Copy link
Contributor

Thank you @valeriocos. This works perfectly for me.

@sduenas please review?

aswanipranjal added a commit to aswanipranjal/grimoirelab-elk that referenced this pull request Aug 5, 2018
This code adds the `enrich_pull_requests` study to the enriched/github.py
file. This study aims at adding additional fields that are related to
pull request items but are not fetched by perceval directly for items of the
pull_requests category.
This study should be used using the functionality added by the PR:
chaoss/grimoirelab-sirmordred#190.

This study takes in an input param: `raw_issues_index` which should contain
the data fetched from the same repository from which the pull requests data
is fetched. Using this `raw_issues_index`, the additional data is extracted from
related issue and that data is enriched and added to the relevant pull request
and updated in the enriched pull request index.
aswanipranjal added a commit to aswanipranjal/grimoirelab-mordred that referenced this pull request Aug 5, 2018
This code adds `enrich_pull_requests` as one of the studies that can
be run, in the studies tuple in the `get_study_section` method.

This code helps add the functionality to to enrich pull requests only
index with additional fields. PRs related to this code are:
- chaoss#190
- chaoss/grimoirelab-elk#419
aswanipranjal added a commit to aswanipranjal/grimoirelab-elk that referenced this pull request Aug 6, 2018
This code adds the `enrich_pull_requests` study to the enriched/github.py
file. This study aims at adding additional fields that are related to
pull request items but are not fetched by perceval directly for items of the
pull_requests category.
This study should be used using the functionality added by the PR:
chaoss/grimoirelab-sirmordred#190.

This study takes in an input param: `raw_issues_index` which should contain
the data fetched from the same repository from which the pull requests data
is fetched. Using this `raw_issues_index`, the additional data is extracted from
related issue and that data is enriched and added to the relevant pull request
and updated in the enriched pull request index.

This code also:
- uses `str_to_datetime` function to convert date in string format to datetime
where ever time difference between two dates is being calculated
- corrects typo in enriched/git.py
valeriocos pushed a commit to chaoss/grimoirelab-elk that referenced this pull request Aug 6, 2018
This code adds the `enrich_pull_requests` study to the enriched/github.py
file. This study aims at adding additional fields that are related to
pull request items but are not fetched by perceval directly for items of the
pull_requests category.
This study should be used using the functionality added by the PR:
chaoss/grimoirelab-sirmordred#190.

This study takes in an input param: `raw_issues_index` which should contain
the data fetched from the same repository from which the pull requests data
is fetched. Using this `raw_issues_index`, the additional data is extracted from
related issue and that data is enriched and added to the relevant pull request
and updated in the enriched pull request index.

This code also:
- uses `str_to_datetime` function to convert date in string format to datetime
where ever time difference between two dates is being calculated
- corrects typo in enriched/git.py
jgbarah pushed a commit that referenced this pull request Aug 7, 2018
This code adds `enrich_pull_requests` as one of the studies that can
be run, in the studies tuple in the `get_study_section` method.

This code helps add the functionality to to enrich pull requests only
index with additional fields. PRs related to this code are:
- #190
- chaoss/grimoirelab-elk#419
@jgbarah
Copy link
Contributor

jgbarah commented Aug 8, 2018

@aswanipranjal @valeriocos could you please explain the rationale for why we need this, instead of just using sirmordred (maybe with some new option)?

@valeriocos
Copy link
Member Author

That's a good idea and probably the correct evolution of micro-morded. However, for the moment I would keep the micro-modred and sirmordred separated (since I don't know how much work is needed to modify sirmordred to include the micro-mordred option).

@aswanipranjal
Copy link
Contributor

@valeriocos @sduenas @jgbarah is there any progress on merging this PR?

@valeriocos
Copy link
Member Author

This PR needs #198 before merging

@valeriocos valeriocos force-pushed the replace-p2o branch 2 times, most recently from a940a13 to 690502b Compare August 22, 2018 15:19
Copy link
Member

@sduenas sduenas left a comment

Choose a reason for hiding this comment

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

LGTM

This code proposes a tiny version of mordred to execute just
once raw, merge identities, enrich, panels tasks of mordred
on a given set of backends (declared in a cfg file passed
as input). The micro-mordred overcomes the current limitations
of the p2o script in ELK, which is not able to execute
multiple studies for the input backend and requires constant
changes to align its logic with the ELK one. The micro-mordred
isn't supposed to require constant changes, since there is not
gap between its logic and the mordred one.

In order to execute the micro-mordred on git and github, an
example of the command is shown below:
`micro --raw --identities --enrich --panels
--cfg ./setup.cfg --backends git github:issue github:pull`.
This code includes examples of the setup.cfg, projects.json and
menu.yaml to execute micro-mordred.
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.

5 participants