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

Start working with ttrack integration #2

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

Conversation

luabida
Copy link

@luabida luabida commented Jun 8, 2022

Pull Request description

This is a initial branch meant to saving my work for today, but furthermore it will be the implementation of ttrack in the invoices
Working on #1

How to test these changes

  • Uncomment ttrack.py
  • copy your .timetrackdb into data_test/
  • run $python invoicex/ttrack.py from the root of the project

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling. (DRAFT)
  • The code is well commented, especially in the parts that contain more complexity. (DRAFT)
  • New and old tests passed locally. (DRAFT)

Additional information

Reviewer's checklist

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved .

@luabida
Copy link
Author

luabida commented Jun 14, 2022

How to test these changes
OPT: choose the month in df = self._filter_by_month()
OPT: choose the tasks in self._get_query()
run $python invoicex/ttrack.py from the root of the project

OBS: If the output is TypeError: 'NoneType' object cannot be interpreted as an integer, you should stop the current task from TTrack and recopy the database.

pyproject.toml Outdated
@@ -26,6 +26,7 @@ black = "^22.3.0"
flake8 = "^4.0.1"
isort = "^5.10.1"
pre-commit = "^2.18.1"
humanfriendly = "^10.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for including this new dep?

btw, adding a new dep to a project could be very impacting ..
be very careful adding a new dep to a project, normally you should have a very good reason for that.

.gitignore Outdated
@@ -1,2 +1,4 @@
*.env*
__pycache__
.vscode/
data_test/.timetrackdb*
Copy link
Contributor

Choose a reason for hiding this comment

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

if you will have a sample for tests, (for python projects) you normally add it to/tests/data

@@ -24,7 +24,7 @@ Example:
```bash
python invoicex/main.py \
--year-month 2022-04 \
--gh-user xmnlab \
--gh-user $USER \
Copy link
Contributor

Choose a reason for hiding this comment

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

this is just an example, it is not a problem to have a fixed user here.
$USER is a system user, not a gh user, so it will be more confusing

Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment

@@ -5,8 +5,9 @@
import os
import time

import reader
import invoicex.reader.github as github
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import invoicex.reader.github as github
from invoicex.reader import ComposeReader

the idea is to hide all the complexity and use ComposeReader as the main interface for the reading.

ComposeReader will receive the parameters about which datasets/data-sources will be used (for now, we just have github and ttrack)

Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment

import report
import invoicex.reader.ttrack as ttrack
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import invoicex.reader.ttrack as ttrack

in main.py we don't need to access ttrack nor github .. just ComposeReader

Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment

invoicex/main.py Outdated

return parser


async def main():
args = cli_parser().parse_args()
results = await reader.get_data(args)
results = await github.get_data(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

ComposeReader will return the data from ttrack and github combined


# e = TTrack(TTRACK_DB)
# print(e())
def get_data(args) -> pd.DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

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

keep in mind that it would be just temporary because ComposeReader will instantiate TTrack inside (probably an attribute called ttrack inside the ComposeReader class)

Copy link
Author

Choose a reason for hiding this comment

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

I'll handle all the comments in next commits, sending now what I got while trying to async TTrack to see if it is correct before externalizing it in ComposeReader

@luabida
Copy link
Author

luabida commented Jun 16, 2022

How to test these changes

run make ttrack-db
run python invoicex/main.py \
--year-month 2022-06 \
--gh-user $USER \
--gh-org osl-incubator/invoicex \
--timezone "-0400"
--ttrack-task <task>

OBS: If the output is TypeError: 'NoneType' object cannot be interpreted as an integer, you should stop the current task from TTrack and recopy the database.

@@ -1,2 +1,4 @@
*.env*
__pycache__
.vscode/
data_test/
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want a test data folder change it to:

Suggested change
data_test/
tests/data

it is the most common way to do that

.ONESHELL:

.PHONY:ttrack-db
ttrack-db:
Copy link
Contributor

Choose a reason for hiding this comment

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

is it used just for development right? if yes, better to have a name that forces this idea:

Suggested change
ttrack-db:
dev-dump-ttrack-db:

@@ -24,7 +24,7 @@ Example:
```bash
python invoicex/main.py \
--year-month 2022-04 \
--gh-user xmnlab \
--gh-user $USER \
Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment

@@ -5,8 +5,9 @@
import os
import time

import reader
import invoicex.reader.github as github
Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment

import report
import invoicex.reader.ttrack as ttrack
Copy link
Contributor

Choose a reason for hiding this comment

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

please check this comment


return parser


async def main():
args = cli_parser().parse_args()
results = await reader.get_data(args)
await report.generate(results, args)
results = await ttrack.get_data(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

here you should instantiate the ComposeReader, not the ttrack class

return df_grouped


async def get_data(args) -> pd.DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

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

you probably will not need this function because all the construction should be done by the ComposeReader

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