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

Arguments #101

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Arguments #101

wants to merge 4 commits into from

Conversation

someparsa
Copy link

Focus on these updates are on the arguments.

  • Interactive argument updated
  • Preview-only argument replaced by an interactive tabular report
  • Read-me updated

@someparsa
Copy link
Author

Hi Julian, I had problem with conflicts on the version on had on my account and the version I imported from the main repo. So I deleted my own fork and did a fresh fork. So my commits here are based on the latest package release. To decrease my mistakes with GIT, I will separate each of my tries in a new branch and will use a little more simple functions of the GIT. Please advise me over the updates and guide me through the next steps and the desired upgrades. I believe we can add a progress bar afterwards.

@someparsa
Copy link
Author

I also did tests using virtual environment for the python, as your described for me in your other comments. It made the test and functionality really fast. Thanks!

Copy link
Owner

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

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

That was fast! Well done on keeping these changes on a separate branch. The --visual argument is an interesting idea, though I think you may have bitten off more than you can chew at this time.

Hi Julian, I had problem with conflicts on the version on had on my account and the version I imported from the main repo. So I deleted my own fork and did a fresh fork.

Sorry to hear that. I guess it was not too much of a loss this time, but next time you run into such troubles, feel welcome to ask for help. Generally, such conflicts can be fixed without any loss of data.

So my commits here are based on the latest package release. To decrease my mistakes with GIT, I will separate each of my tries in a new branch and will use a little more simple functions of the GIT.

Good plan!

For now, there is just one thing you need to fix in your branches. It seems you accidentally advanced your develop with the first commit on your arguments branch. You can rewind your develop as follows, so it realigns with develop on my repo:

git checkout develop
git reset --hard upstream/develop
git push --force origin develop

Please advise me over the updates and guide me through the next steps and the desired upgrades. I believe we can add a progress bar afterwards.

I will certainly guide you. Baby steps, though!

I also did tests using virtual environment for the python, as your described for me in your other comments. It made the test and functionality really fast. Thanks!

Please remind me, what did I write about that? Probably unrelated, but: when I try the tests on your code, they fail.

So, now for the actual review. I like some of the things you did, but I'm afraid you got ahead of yourself and made a bit of a mess in the process. Most importantly:

  • You made unnecessary breaking changes. pip-review without arguments no longer shows available updates, which is causing the tests to fail and would certainly frustrate lots of users. In addition, the precedence of the --raw and --auto arguments switched, which is likely to break some people's scripts.
  • You lost track of the possible interactions between the arguments. There are many ways to make pip-review do convoluted or even nonsensical things.

You need to exercise minimalism. What I would like you to do (please ask for help if you run into any difficulty at any step):

  • Read my comments below, but don't follow up on them yet. Just make some mental notes.
  • Make a copy of your current arguments branch so you can look back at it if necessary.
git branch arguments-bak arguments
  • Rewind the arguments branch all the way back to upstream/develop. In the next steps, you will start over, making small improvements on top of the work of @kunif.
git checkout arguments
git reset --hard upstream/develop
  • First problem to solve: pip-review --preview --raw will show both a table and the raw format, which is pointless. For a human reader, the raw format adds no information and is less readable than the table. For a machine, only the raw format is parsable. Try to make the smallest possible code change so that pip-review --preview --raw behaves exactly like pip-review --preview; in other words, so that --raw is ignored if --preview is also passed. Do not change any other behavior. Do not continue before you have solved this problem and committed your changes.
  • Second problem to solve: pip-review --preview will show both a table and the wordy format, which is also pointless. Solve this problem, again trying to find the smallest possible code change and without changing any other behavior. Succeed and commit before continuing.
  • With your previous change in place, the --preview-only argument is redundant. Remove it. Make sure you update all parts of the code that have something to do with the removed argument. Commit again.
  • Force-push the new version of your arguments branch. This will update the current pull request.
  • Let me know that you are ready for another review.
  • Create a new issue ticket for your idea for the --visual argument. I think we need to discuss it.

Please let me know if you have any questions or comments!

@@ -57,7 +57,7 @@ Example, preview for update target list by ``pip list --outdated`` format, with
$ pip-review --auto --preview
... <same above and pip install output>

Example, only preview for update target list:
Example, preview a table of the update target list, which is a combination of the interactive and preview formats:
Copy link
Owner

Choose a reason for hiding this comment

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

This is not a combination, is it? I think the next example is just the preview (table) format.

Copy link
Owner

Choose a reason for hiding this comment

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

Also, note that it is still saying --preview-only on line 64.

@@ -69,30 +69,62 @@ def parse_args():
description=description,
epilog=EPILOG+version_epilog(),
)

# ----------------------------
Copy link
Owner

Choose a reason for hiding this comment

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

I'm in favor of adding a blank line here. The ruler is maybe not so necessary. If you want to keep the ruler, please give it the same indentation as the surrounding code.

Comment on lines +79 to +83
''' example:
ezdxf==1.0.2 is available (you have 0.8.0)
pip==23.0.1 is available (you have 22.0.4)
setuptools==67.3.2 is available (you have 58.1.0)
'''
Copy link
Owner

Choose a reason for hiding this comment

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

This is a nice touch, makes the meaning of the arguments more tangible for the programmer.

This comment is in the wrong place, though; --verbose does not mean "show me the wordy format" but it means "show all output with logger.debug in addition to all output with logger.info". It so happens that pip-review does not have such output anymore; all former calls to logger.debug were in Vincent Driessen's custom logic to compute the outdated packages, which fell out of the codebase when we transitioned to a thin wrapper around pip list --outdated in version 1.0.0. It is only now that I realize that the --verbose flag doesn't make any difference anymore because of this!

Anyway, the comment you wrote here would probably be more appropriate on line 73, where you put the ruler. This is because the wordy format is the default format, which appears if you don't pass --raw or --preview. You could further clarify this by changing the header from just example: to default format:.

Oh, and one more thing: it is conventional to use double triple quotes for comments, so """ instead of '''.

Comment on lines +89 to +93
''' example:
ezdxf==1.0.2
pip==23.0.1
setuptools==67.3.2
'''
Copy link
Owner

Choose a reason for hiding this comment

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

This is correct here. 👍

Comment on lines +115 to +122
''' exmple:
Package Version Latest Type
-------------------------------
ezdxf 0.8.0 1.0.2 wheel
pip 22.0.4 23.0.1 wheel
setuptools 58.1.0 67.3.2 wheel
-------------------------------
'''
Copy link
Owner

Choose a reason for hiding this comment

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

Again correct, and nice for consistency. Would be even better if you move the argument and this comment up, so they come directly after --raw and its comment. That would group all the formats together.

Comment on lines +314 to +318
if args.verbose:
for pkg in outdated:
logger.info('{0}=={1} is available (you have {2})'.format(
pkg['name'], pkg['latest_version'], pkg['version']
))
Copy link
Owner

Choose a reason for hiding this comment

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

Here, you're changing the meaning of the --verbose flag. Please don't change the meaning of already released flags!

Comment on lines +315 to +318
for pkg in outdated:
logger.info('{0}=={1} is available (you have {2})'.format(
pkg['name'], pkg['latest_version'], pkg['version']
))
Copy link
Owner

Choose a reason for hiding this comment

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

Also, this same snippet of code now appears in three places. Keep it DRY: Don't Repeat Yourself!

Comment on lines +320 to +321
# --raw
# --interactive
Copy link
Owner

Choose a reason for hiding this comment

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

These comments don't really add information; it already says if args.raw and args.interactive on the next line.

else:
logger.info('You chose to quit the update process')

return
Copy link
Owner

Choose a reason for hiding this comment

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

There are way too many changes on the past 80 lines. Firstly, because you did not need to make so many changes, secondly, because some of the changes are disruptive for users, and thirdly, because you lost track of all the possible interactions between the options. Let us compare pip-review's behavior in the past to what these changes made of it.

Behavior in all published releases so far (up to 1.3.0), by order of precedence of options:

  • pip-review
    • report: wordy
    • updates: none
  • pip-review --auto
    • report: no output
    • updates: all
  • pip-review --raw
    • report: raw
    • updates: none
  • pip-review --interactive
    • report: wordy (combined with selection)
    • updates: interactive selection
  • --verbose combined with any of the above: would give diagnostic output, if our code would actually use that

Behavior on develop (after changes by @kunif):

  • pip-review
    • report: wordy
    • updates: none
  • pip-review --preview-only
    • report: table
    • updates: none
  • pip-review --preview
    • report: table
    • updates: none, but repeats all available updates in wordy format
  • pip-review --preview --auto
    • report: table
    • updates: all
  • pip-review --preview --raw
    • report: table
    • updates: none, but also raw report shown
  • pip-review --preview --interactive
    • report: table
    • updates: interactive selection (in wordy format)
  • pip-review --auto
    • report: no output
    • updates: all
  • pip-review --raw
    • report: raw
    • updates: none
  • pip-review --interactive
    • report: wordy (combined with selection)
    • updates: interactive selection
  • --verbose combined with any of the above: would give diagnostic output, if our code would actually use that

Behavior that I think would make most sense (nearly the same but no --preview-only and no --preview --raw):

  • pip-review
    • report: wordy
    • updates: none
  • pip-review --preview
    • report: table
    • updates: none (as --preview-only on current develop)
  • pip-review --preview --auto
    • report: table
    • updates: all
  • pip-review --preview --interactive
    • report: table
    • updates: interactive selection (in wordy format)
  • pip-review --auto
    • report: no output
    • updates: all
  • pip-review --raw
    • report: raw
    • updates: none
  • pip-review --interactive
    • report: wordy (combined with selection)
    • updates: interactive selection
  • --verbose combined with any of the above: would give diagnostic output, if our code would actually use that

Behavior after your changes in d05f518..d0c7792:

  • pip-review
    • nothing happens, this is a breaking change!
  • pip-review --verbose
    • report: wordy
    • updates: none
    • also enables diagnostic input as before
  • pip-review --verbose --raw
    • report: wordy
    • updates: none, but also raw report shown
  • pip-review --verbose --interactive
    • report: wordy
    • updates: interactive selection (each available update mentioned twice)
  • pip-review --verbose --interactive --auto
    • report: wordy
    • first round of updates: interactive selection (each available update mentioned twice)
    • second round of updates: all (based on situation before previous round)
  • pip-review --verbose --interactive --preview
    • first report: wordy
    • updates: interactive selection (each available update mentioned twice)
    • second report: table (based on data before interactive update)
  • pip-review --verbose --interactive --preview --visual
    • first report: wordy
    • first round of updates: interactive selection (each available update mentioned twice)
    • second report: table (based on data before interactive update)
    • second round of updates:
      • interactive selection (still based on data before previous interactive update)
      • selection displayed in a table
      • confirmation
  • pip-review --verbose --interactive --visual
    • report: wordy
    • first round of updates: interactive selection (each available update mentioned twice)
    • second round of updates:
      • interactive selection (based on data before previous interactive update)
      • selection displayed in a table
      • confirmation
  • pip-review --verbose --auto
    • report: wordy
    • updates: all
  • pip-review --verbose --preview
    • first report: wordy
    • second report: table
  • pip-review --verbose --preview --visual
    • first report: wordy
    • second report: table
    • updates:
      • interactive selection (each available update mentioned three times)
      • selection displayed in a table
      • confirmation
  • pip-review --verbose --visual
    • report: wordy
    • updates:
      • interactive selection (each available update mentioned twice)
      • selection displayed in a table
      • confirmation
  • pip-review --raw
    • report: raw
    • updates: none
  • pip-review --interactive
    • report: wordy (combined with selection)
    • updates: interactive selection
  • pip-review --interactive --auto
    • report: wordy (combined with selection)
    • first round of updates: interactive selection
    • second round of updates: all (based on situation before previous round)
  • pip-review --interactive --preview
    • first report: wordy (combined with selection)
    • updates: interactive selection
    • second report: table (based on data before interactive update)
  • pip-review --interactive --preview --visual
    • first report: wordy (combined with selection)
    • first round of updates: interactive selection
    • second report: table (based on data before interactive update)
    • second round of updates:
      • interactive selection (still based on data before previous interactive update)
      • selection displayed in a table
      • confirmation
  • pip-review --auto
    • report: no output
    • updates: all
  • pip-review --preview
    • report: table
    • updates: none
  • pip-review --preview --visual
    • report: table
    • updates:
      • interactive selection
      • selection displayed in a table
      • confirmation
  • pip-review --visual
    • updates:
      • interactive selection
      • selection displayed in a table
      • confirmation


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
sys.stdout.write('\nAborted\n')
sys.exit(0)
sys.exit(0)
Copy link
Owner

Choose a reason for hiding this comment

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

Don't strip newlines from the ends of files! Some tools rely on those newlines being there.

@someparsa
Copy link
Author

Sorry to hear that. I guess it was not too much of a loss this time, but next time you run into such troubles, feel welcome to ask for help. Generally, such conflicts can be fixed without any loss of data.

Thank you, yes I got lost between the upstream, master, branches and all. The easiest way to get rid of the hell was to do a clear fork. I remember the first days I was using the VIM and NVIM. The cross icon on top of the terminal window was my scape way! :))

Sure I will ask you any questions from now on. It is not wise to delete my whole fork as I will miss my content and progress.

For now, there is just one thing you need to fix in your branches. It seems you accidentally advanced your develop with the first commit on your arguments branch. You can rewind your develop as follows, so it realigns with develop on my repo:

I think I again messed my fork!

PS C:\...\pip-review> git status
On branch arguments
Your branch is up to date with 'origin/arguments'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        pip_review/venv/
        venv/

nothing added to commit but untracked files present (use "git add" to track)

PS C:\...\pip-review> git branch
* arguments
  develop

PS C:\...\pip-review> git checkout develop
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.

PS C:\...\pip-review> git reset --hard upstream/develop
fatal: ambiguous argument 'upstream/develop': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

PS C:\...\pip-review> git push --force origin develop
Everything up-to-date

Please remind me, what did I write about that? Probably unrelated, but: when I try the tests on your code, they fail.

I read the 'virtual environment' here (link), so I made 'venv's to do my checks in virtual environments. python -m venv venv

Following up, you prepared several virtual environments with different sets of packages installed, some outdated. In each virtual environment, you ran pip-review several times, recording the total CPU time each time. You also made multiple measurements of the time required to run just pip list --outdated. You found that pip-review took significantly longer than pip list --outdated on average. Then, you posted the above comment.

  • Read my comments below, but don't follow up on them yet. Just make some mental notes.
  • Sure, will do it!
  • Make a copy of your current arguments branch so you can look back at it if necessary.
  • Sure, I can do this. Thanks.
  • Rewind the arguments branch all the way back to upstream/develop. In the next steps, you will start over, making small improvements on top of the work of @kunif.
  • I am afraid I make mess with the current development. Maybe later, if you agree.
  • First problem to solve: pip-review --preview --raw will show both a table and the raw format, which is pointless. For a human reader, the raw format adds no information and is less readable than the table. For a machine, only the raw format is parsable. Try to make the smallest possible code change so that pip-review --preview --raw behaves exactly like pip-review --preview; in other words, so that --raw is ignored if --preview is also passed. Do not change any other behavior. Do not continue before you have solved this problem and committed your changes.
  • I have put interaction between the arguments at my second priority. First I have in mind to polish the arguments and then I will move to the interactions. So, if arg1 and arg2:, will be my second task after finishing up with the present development on arguments. If this is not good, please advise me.
  • Second problem to solve: pip-review --preview will show both a table and the wordy format, which is also pointless. Solve this problem, again trying to find the smallest possible code change and without changing any other behavior. Succeed and commit before continuing.

I think I have solved this issue. This is the output of the --preview arguement. The problem was with the nested if's afterwards. This is what I see. I miss-understand, or if it is not what you convey, please advise me more.

Package    Version Latest Type 
-------------------------------
ezdxf      0.8.0   1.0.2  wheel
pip        22.0.4  23.0.1 wheel
setuptools 58.1.0  67.3.3 wheel
-------------------------------
  • With your previous change in place, the --preview-only argument is redundant. Remove it. Make sure you update all parts of the code that have something to do with the removed argument. Commit again.

Sure will do it. I am replacing it with the visual arguement.

  • Force-push the new version of your arguments branch. This will update the current pull request.

Sure will do it after the developments.

  • Let me know that you are ready for another review.
  • Create a new issue ticket for your idea for the --visual argument. I think we need to discuss it.

Sure will do it. Many thanks for all the comments. I am afraid I lose track of your points, but please be patient, I am not a professional software engineer. I am a civil engineer. So my speed may be not as much as expected. But I am working on this, in my free time.

@jgonggrijp
Copy link
Owner

For now, there is just one thing you need to fix in your branches. It seems you accidentally advanced your develop with the first commit on your arguments branch. You can rewind your develop as follows, so it realigns with develop on my repo:

I think I again messed my fork!

Ah, I see what's missing. You did not add my public repository as a remote yet. Do this first:

git remote add -f upstream https://github.com/jgonggrijp/pip-review.git

Then you can git checkout develop and resume the sequence of commands from git reset --hard upstream/develop onwards.

I read the 'virtual environment' here (link), so I made 'venv's to do my checks in virtual environments. python -m venv venv

Ah, the performance tests. Now I remember.

  • Rewind the arguments branch all the way back to upstream/develop. In the next steps, you will start over, making small improvements on top of the work of @kunif.
  • I am afraid I make mess with the current development. Maybe later, if you agree.

Agreed. After adding the upstream remote and resetting your develop, I think you will be able to resume safely from this point.

  • First problem to solve: pip-review --preview --raw will show both a table and the raw format, which is pointless. For a human reader, the raw format adds no information and is less readable than the table. For a machine, only the raw format is parsable. Try to make the smallest possible code change so that pip-review --preview --raw behaves exactly like pip-review --preview; in other words, so that --raw is ignored if --preview is also passed. Do not change any other behavior. Do not continue before you have solved this problem and committed your changes.
  • I have put interaction between the arguments at my second priority. First I have in mind to polish the arguments and then I will move to the interactions. So, if arg1 and arg2:, will be my second task after finishing up with the present development on arguments. If this is not good, please advise me.

What do you mean by "polishing the arguments"? As far as I'm concerned, fixing the interactions between arguments (as well as their semantics alone) is polishing the arguments.

  • Second problem to solve: pip-review --preview will show both a table and the wordy format, which is also pointless. Solve this problem, again trying to find the smallest possible code change and without changing any other behavior. Succeed and commit before continuing.

I think I have solved this issue. This is the output of the --preview arguement. The problem was with the nested if's afterwards. This is what I see. I miss-understand, or if it is not what you convey, please advise me more.

You are right, you fixed this. However, I want you to start over and fix it with the smallest possible code change. Your current set of changes causes a lot of new trouble as a side effect!

  • With your previous change in place, the --preview-only argument is redundant. Remove it. Make sure you update all parts of the code that have something to do with the removed argument. Commit again.

Sure will do it. I am replacing it with the visual arguement.

For now, please just remove it. Save the --visual for a later pull request.

Sure will do it. Many thanks for all the comments. I am afraid I lose track of your points, but please be patient, I am not a professional software engineer. I am a civil engineer. So my speed may be not as much as expected. But I am working on this, in my free time.

Sure, no worries and no hurry. Everyone needs to start from zero and I am doing this in my spare time, too. Let's just focus on getting the branches right, first.

@someparsa
Copy link
Author

someparsa commented Feb 21, 2023

What do you mean by "polishing the arguments"? As far as I'm concerned, fixing the interactions between arguments (as well as their semantics alone) is polishing the arguments.

I have this in mind: I assume their semantics alone is the first priority and then we solve the interactions between arguments. I have a sense maybe if we are not sure about the arguments themselves, we may not successfully approach the interactions. Maybe we approach the interactions and later we need to fix something in semantics themselves that may affect the interactions. That will be a duplicate work. May be I am wrong, not sure.

For now, please just remove it. Save the --visual for a later pull request.

Sure will open a new ticket for this and will archive it.

Sure, no worries and no hurry. Everyone needs to start from zero and I am doing this in my spare time, too. Let's just focus on getting the branches right, first.

Good, Sure I will work on the branches for now.

@jgonggrijp
Copy link
Owner

If you first want to fix pip-review --preview, so it does not output the wordy report, and then pip-review --preview --raw, so it does not output the raw report, that is fine by me, too. Still though, please start from scratch and seek the smallest possible changes.

@someparsa
Copy link
Author

Got it, sounds good. This way we have a list of actions and steps. I will update you on my progress.

  • GIT --> Branches
  • Fix --> pip-review -- preview
  • Fix --> pip-review -- preview --raw

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.

None yet

2 participants