X Tutup
The Wayback Machine - https://web.archive.org/web/20230329061656/https://github.com/PowerShell/PowerShell/pull/18474
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

Do not require activity when creating a completed progress record #18474

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

MartinGC94
Copy link
Contributor

@MartinGC94 MartinGC94 commented Nov 6, 2022

PR Summary

Fixes #15252
Allows you to complete progress records with Write-Progress without specifying an activity.
This is done by using a predefined string in the activity for Complete records because the API expects a non-empty string and updating the API would cause issues in remoting scenarios with a different PowerShell host.

PR Context

PR Checklist

@MartinGC94
Copy link
Contributor Author

It doesn't seem possible to fix this with parametersets without making a breaking change.
If there's no default parameterset set then the parameter binding can't resolve the parameterset in scenarios like Write-Progress -Activity "Something" -Id 1 -Completed.
If it's set to the current parameterset then it will prompt for an Activity value for Write-Progress -Completed.
If it's set to the new parameterset then it will prompt for a Completed value for Write-Progress -Activity "Something"

It seems like the only option left is to keep the current parameterset and simply make Activity optional, then if no value is provided either provide a default value, or throw an error unless it's a Completed progress record.

@MartinGC94 MartinGC94 changed the title Do not require activity when creating a completed progress record WIP: Do not require activity when creating a completed progress record Nov 6, 2022
@SteveL-MSFT SteveL-MSFT added the WG-Cmdlets general cmdlet issues label Nov 7, 2022
@SteveL-MSFT
Copy link
Member

I'll queue this up for discussion on Cmdlets WG

@SteveL-MSFT
Copy link
Member

This script example seems to work?

[cmdletbinding(DefaultParameterSetName='two')]
param(
	[parameter(ParameterSetName='one', mandatory=$true)]
	[parameter(ParameterSetName='two', mandatory=$false)]
	[string]$activity,

	[parameter(ParameterSetName='two')]
	[switch]$completed
)

$activity
$completed

@MartinGC94
Copy link
Contributor Author

That's not an accurate example though. Completed still needs to exist in the old parameter set so we don't break backwards compatibility with scripts like Write-Progress -Activity bla -SecondsRemaining 0 -Completed.

This example is more accurate:

function Write-Progress2
{
    [CmdletBinding(DefaultParameterSetName = "two")]
    Param
    (
	    [parameter(ParameterSetName='one', mandatory=$true)]
	    [parameter(ParameterSetName='two', mandatory=$false)]
	    [string]$activity,

        [parameter(ParameterSetName='one', Mandatory = $false)]
	    [parameter(ParameterSetName='two', Mandatory = $false)]
	    [switch]$completed
    )
    $PSCmdlet.ParameterSetName
}

but by making parameter set "two" the default set and the "completed" switch optional we allow people to call it without any parameters at all: Write-Progress2. We can fix that by making the switch mandatory but then calling it with Write-Progress2 -Activity bla will default to set 2 and prompt for a value for the "completed" parameter.

@msftbot msftbot bot added the Review - Needed The PR is being reviewed label Nov 15, 2022
@msftbot
Copy link

msftbot bot commented Nov 15, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@SteveL-MSFT
Copy link
Member

@PowerShell/wg-powershell-cmdlets reviewed this. We agreed to make -Activity not mandatory and allow null/empty value. We understand that new scripts using this will cause older PowerShell to prompt to fill in this parameter, but proper documentation can alleviate this.

@msftbot msftbot bot removed the Review - Needed The PR is being reviewed label Mar 1, 2023
@iSazonov iSazonov added the Documentation Needed Documentation is needed label Mar 1, 2023
@MartinGC94 MartinGC94 changed the title WIP: Do not require activity when creating a completed progress record Do not require activity when creating a completed progress record Mar 2, 2023
@msftbot msftbot bot added the Review - Needed The PR is being reviewed label Mar 12, 2023
@msftbot
Copy link

msftbot bot commented Mar 12, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@msftbot msftbot bot added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Review - Needed The PR is being reviewed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Mar 13, 2023
@iSazonov
Copy link
Collaborator

@PowerShell/wg-powershell-cmdlets reviewed this. We agreed to make -Activity not mandatory and allow null/empty value. We understand that new scripts using this will cause older PowerShell to prompt to fill in this parameter, but proper documentation can alleviate this.

@SteveL-MSFT Did you discuss Clear-Progress instead of the change?

@msftbot msftbot bot added the Review - Needed The PR is being reviewed label Mar 21, 2023
@msftbot
Copy link

msftbot bot commented Mar 21, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@SteveL-MSFT
Copy link
Member

@iSazonov no, Clear-Progress didn't come up in the WG discussion. Let me bring that up to the WG, as that would avoid any breaking change concerns.

@msftbot msftbot bot removed the Review - Needed The PR is being reviewed label Mar 27, 2023
@MartinGC94
Copy link
Contributor Author

@SteveL-MSFT @iSazonov If you decide to go that route I think a better verb choice would be Complete, as in Complete-Progress.

@pull-request-quantifier
Copy link

This PR has 11 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +7 -4
Percentile : 4.4%

Total files changed: 2

Change summary by file extension:
.cs : +6 -3
.ps1 : +1 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  👌  👎 (Email)
Customize PullRequestQuantifier for this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Needed Documentation is needed Extra Small WG-Cmdlets general cmdlet issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write-Progress -Completed requires an -Activity argument, even though it is pointless
4 participants
X Tutup