text:
Type definition fails in Powershell 7.0.0-preview.5

 $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.5
PSEdition                      Core
GitCommitId                    7.0.0-preview.5
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Steps to reproduce
Add-Type -TypeDefinition @"
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;

namespace net.bannach.Helper.Sql
{
    public class SqlCommandExt<T>
    {
        public SqlCommandExt() {;}
        public SqlParameter[] AddArrayParameters(SqlCommand cmd, IEnumerable<T> values, string paramNameRoot, int start = 1, string separator = ", ")
        {
            var parameters = new List<SqlParameter>();
            var parameterNames = new List<string>();
            var paramNbr = start;
            foreach (var value in values)
            {
                var paramName = string.Format("@{0}{1}", paramNameRoot, paramNbr++);
                parameterNames.Add(paramName);
                parameters.Add(cmd.Parameters.AddWithValue(paramName, value));
            }

            cmd.CommandText = cmd.CommandText.Replace("@@" + paramNameRoot, string.Join(separator, parameterNames));

            return parameters.ToArray();
        }
    }
}
"@ -ReferencedAssemblies System.Data

Expected behavior
Type definition succeeds. As it does with all previous versions.

Actual behavior
Errors:
Add-Type: (10,50): error CS1069: The type name 'SqlCommand' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=4.6.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
        public SqlParameter[] AddArrayParameters(SqlCommand cmd, IEnumerable<T> values, string paramNameRoot, int start = 1, string separator = ", ")
                                                 ^

Add-Type: (10,16): error CS1069: The type name 'SqlParameter' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=4.6.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
        public SqlParameter[] AddArrayParameters(SqlCommand cmd, IEnumerable<T> values, string paramNameRoot, int start = 1, string separator = ", ")
               ^

Add-Type: (12,39): error CS1069: The type name 'SqlParameter' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=4.6.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
            var parameters = new List<SqlParameter>();
                                      ^

Add-Type: Cannot add type. Compilation errors occurred.

Environment data

@reflectedobject System.Data isn't a pre-loaded assembly. You'll need to add -ReferencedAssemblies 'System.Data to the Add-Type command call to load it in and use the types it contains, which include the System.Data.SqlClient namespace. 🙂

That is exactly what I am doing - please check the last line of my posted code.
"@ -ReferencedAssemblies System.Data'

@reflectedobject System.Data isn't a pre-loaded assembly. You'll need to add -ReferencedAssemblies 'System.Data to the Add-Type command call to load it in and use the types it contains, which include the System.Data.SqlClient namespace. 🙂

You're right, sorry, I didn't see that one.
I suspect the issue may come either from where the System.Data assemblies are installed (possibly in a location Windows PowerShell reaches by default, but must be targeted specifically for PS Core), or how they're built. If the System.Data assemblies depend on classes only available in .NET Framework, they may not be able to be loaded under .NET Core.
@potatoqualitee have you folx looked at using the System.Data assembly in PowerShell Core/7 thus far? Perhaps you might be more familiar working with this side of things than some of the other folx in the repo here. 🙂

SqlCommand is technically in the assembly System.Data.SqlClient now.  That said, the System.Data assembly does have a TypeForwardedTo pointing to the correct assembly, so maybe that should be accounted for in some way by Add-Type.

SqlCommand is technically in the assembly System.Data.SqlClient now.  That said, the System.Data assembly does have a TypeForwardedTo pointing to the correct assembly, so maybe that should be accounted for in some way by Add-Type.

Any pointer on how that can be accomplished? Never had to deal with TypeForwardTo before.

Short-term you should be able to just reference Systom.Daha.SqlClient instead in the -ReferencedAssemblies
Long term we probably need to try to determine how to handle that in Add-Type itself so that forwarded types are automatically picked up.

Thanks for all the feedback. I have tried a few referenced assembly variants and got the following:
Add-Type -TypeDefinition @" … omitted as same as at beginning of post ..."@ -ReferencedAssemblies System.Data.SqlClient

Give another set of hard to decrypt messages (for me at least).
It appears to be some ambiguity/conflict for the System.Runtime Assembly.
In the interim I have compiled the code into a .NET Core library and load the DLL rather than the script included code.
I'd be grateful for any pointers to get it to work like it did.
Add-Type: error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy
Add-Type: error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy
Add-Type: (27,34): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
            var parameters = new List<SqlParameter>();
                                 ^

Add-Type: error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy
Add-Type: (28,38): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
            var parameterNames = new List<string>();
                                     ^

Add-Type: (34,47): error CS0012: The type 'DbParameterCollection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
                parameters.Add(cmd.Parameters.AddWithValue(paramName, value));
                                              ^

Add-Type: (34,32): error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy
                parameters.Add(cmd.Parameters.AddWithValue(paramName, value));
                               ^

Add-Type: error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy       Add-Type: error CS1702: Assuming assembly reference 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy       Add-Type: Cannot add type. Compilation errors occurred.

Interesting. Not sure about the version # mismatches there, but it looks like you need -ReferencedAssemblies System.Data.Common, System.DataSqlClient and then also just check your using statements; List<> is in the Systems.Collection.Generic namespace, so make sure you have that in your using statements. 🙂

Yeah, looks like System.Data.SqlClient references System.Runtime, Version=4.2.2.0 when PS itself references 4.2.1.0.  You can get it to work by adding System.Runtime to the referenced assemblies and adding -IgnoreWarnings and -WarningAction None.
Add-Type needs some work when it comes to references, especially around version conflicts.
Here's a smaller repro that works:
Add-Type -WarningAction Ignore -IgnoreWarnings -ReferencedAssemblies System.Runtime, System.Data, System.Data.SqlClient -TypeDefinition '
        using System;
        using System.Data.SqlClient;
        public static class Testing {
            public static SqlCommand DoSomething() => throw new System.NotImplementedException();
        }'

authors: SeeminglyScience reflectedobject vexx32

repo: PowerShell/PowerShell


text:
Distribution Support Request: PowerShell for Android

Details of the Distribution

Name of the Distribution: Android
Version of the Distribution: Android 11
Package Types

[ ] Deb
[ ] RPM
[ ] Tar.gz
[x] apk

Processor Architecture (One per request): ARMv8
The following is a requirement for supporting a distribution without exception.

[ ] The version and architecture of the Distribution is supported by .NET Core.

The following are requirements for supporting a distribution.
Please write a justification for any exception where these criteria are not met and
the PowerShell committee will review the request.

[x] The version of the Distribution is supported for at least one year.
[x] The version of the Distribution is not an interim release or equivalent.

Progress

[ ] ~An issues has been filed to create a Docker image in https://github.com/powershell/powershell-docker~ Docker images are not needed

For PowerShell Team ONLY

[ ] Docker image created
[ ] Docker image published
[ ] Distribution tested
[ ] Update packages.microsoft.com deployment
[ ] Lifecycle updated
[ ] Documentation Updated

Please use Distribution Support Request template to create such request.

@iSazonov Done. Should I create separate issues for Android and iOS?

Yes, please create separate issues.

Done

@iSazonov
I had success there is one year one on Android with a modified SMA. (when I was testing WASM)

The problem is ... there is no Console at all.
Possible workaround :

use XtermJS as a Blazor Hybrid app (so same code base as WASM) but had a lot of bugs because XtermJS in a process or in a browser is not the same
use termux (I haven't any idea how to mix it with Xamarian Forms)

@hez2010 Do you work on the subject ?
For iOS, it doesn't work : "Since applications using Xamarin.iOS are compiled to static code, it is not possible to use any facilities that require code generation at runtime."
source : https://docs.microsoft.com/en-us/xamarin/ios/internals/limitations

@fMichaleczek I found a C# port of XtermJS may be able to work on Android: https://github.com/xamarin/XtermSharp

@hez2010 I will have a look.
There is 3 ways : Blazor or Maui or a mix of both.
Because I am working on the wasm port, I am more interested by Blazor Shared  Components.
But there is limitation until net7.0/8.0 on the Blazor/Maui gateway, so the standalobe Maui port is the better candidate for tomorrow.

@hez2010 It's not a port of Xterm.JS, it's a port of TerminalUI on top on an existant PTY. Android is a web OS, so pty is not a native API, so embedded XtermJS in a Blazor Shared Component exposed to Maui is still the roadmap for me. I'm still monitor the progression of aspnet teams, but it's still in experimental features (the MAUI/Blazor  samples)

This does not meet the distribution support requirements in the template.  Specifically .NET does not support this.

source: gharchive/issue

license: MIT

license_type: permissive

license_source: github-api


text:
Duplicate PowerShell\7-preview Path appended to $Env:PATH on startup

Prerequisites

[X] Write a descriptive title.
[X] Make sure you are able to repro it on the latest released version
[X] Search the existing issues.
[X] Refer to the FAQ.
[X] Refer to Differences between Windows PowerShell 5.1 and PowerShell.

Steps to reproduce
When PowerShell 7.4.0-preview.2 starts up, it appends its own path to the $Env:PATH variable, regardless of whether or not that variable already exists on the path. If a PowerShell script persists changes to the environment variable with [Environment]::SetEnvironmentVariable("PATH", $Env:PATH, [EnvironmentVariableTarget]::User), then the duplicate path is saved permanently. Upon closing and re-opening PowerShell (using either windows terminal or the standalone PowerShell client), another copy of the PowerShell path is appended.
Expected behavior
PS> $Env:PATH.split(";") | select-string "prev"

C:\Program Files\PowerShell\7-preview

PS> [Environment]::SetEnvironmentVariable("PATH", $Env:PATH, [EnvironmentVariableTarget]::User)

# Close and re-open terminal

PS> $Env:PATH.split(";") | select-string "prev"

C:\Program Files\PowerShell\7-preview

Actual behavior
PS> $Env:PATH.split(";") | select-string "prev"

C:\Program Files\PowerShell\7-preview

PS> [Environment]::SetEnvironmentVariable("PATH", $Env:PATH, [EnvironmentVariableTarget]::User)

# Close and re-open terminal

PS> $Env:PATH.split(";") | select-string "prev"

C:\Program Files\PowerShell\7-preview
C:\Program Files\PowerShell\7-preview

Error details
No response
Environment data
PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.2
PSEdition                      Core
GitCommitId                    7.4.0-preview.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals
No response

To add some background (I do see that the behavior can be considered problematic):

I think that PowerShell Core has always done this, presumably in an effort to ensure that using pwsh to launch another instance predictable targets the same PowerShell Core installation, given that multiple ones may be installed side by side.

As an aside: Using [Environment]::SetEnvironmentVariable("PATH", $Env:PATH, [EnvironmentVariableTarget]::User) to update the persistent definition of the Path environment variable is problematic, because it implicitly converts the registry value from REG_EXPAND_SZ to REG_SZ and in effect replaces entries that build on other environment variables with their expanded form at the time of making the call.

As an aside: Using [Environment]::SetEnvironmentVariable("PATH", $Env:PATH, [EnvironmentVariableTarget]::User) to update the persistent definition of the Path environment variable is problematic, because it implicitly converts the registry value from REG_EXPAND_SZ to REG_SZ and in effect replaces entries that build on other environment variables with their expanded form at the time of making the call.

As a Noob to Windows System management stuff, is there a better way for me to dynamically set a PATH variable?
For background, my use case is that I'm trying to implement something similar to nvm, but for Java: I have 2 projects that require distinct version of OpenJDK due to a breaking change between 11 and 17 that targeting different language versions doesn't fix. I am swapping out both the OpenJDK bin directory in my PATH variable along with the JAVA_HOME variable, so that when I run:
Set-JVM 11
# or
Set-JVM 17

it sets the appropriate paths in the PATH and JAVA_HOME variables permanently. Are you saying that it would be better to add something like %JAVA_HOME%/bin to my PATH as a REG_EXPAND_SZ?

it would be better to add something like %JAVA_HOME%/bin to my PATH as a REG_EXPAND_SZ

In principle, yes: this would allow you to effect a switch between the two Java versions by updating the JAVA_HOME environment variable alone.
Pragmatically speaking, there is real risk of other code accidentally converting Path definitions to REG_SZ, which would break this approach.
Well-behaved applications / installers should definitely not do that, but the fact that there's no simple way to do this properly - you need to manipulate the registry directly - exacerbates the problem, because the only simple solutions - [Environment]::SetEnvironmentVariable() and setx.exe do cause the problem.
A correct PowerShell solution, along with additional background information, can be found in this Stack Overflow answer.

it would be better to add something like %JAVA_HOME%/bin to my PATH as a REG_EXPAND_SZ

In principle, yes: this would allow you to effect a switch between the two Java versions by updating the JAVA_HOME environment variable alone.
Pragmatically speaking, there is real risk of other code accidentally converting Path definitions to REG_SZ, which would break this approach.
Well-behaved applications / installers should definitely not do that, but the fact that there's no simple way to do this properly - you need to manipulate the registry directly - exacerbates the problem, because the only simple solutions - [Environment]::SetEnvironmentVariable() and setx.exe - do cause the problem.
A correct PowerShell solution, along with additional background information, can be found in this Stack Overflow answer.

Thank you for your help, I'll follow that guide. However, it does seem like powershell core should additionally be doing a runtime check for $PSHome before setting it upon startup to avoid issues like this, though I know microsoft has a storied relationship and nuanced philosophy with trying to control for bad user behavior such as my own 😅

Glad to hear it, helped @ShortRoundDev.
As for checking for $PSHOME:
I can't speak to the real design intent - I hope someone from the team can chime in, but two possible motivations have been presented so far:

(a) As suggested by @237dmitry, it may be to ensure that pwsh can be used even if $PSHOME isn't present in $env:PATH at all.

(b) As suggested by me, it may additionally be to ensure that the same installation that's running the current session is targeted, in case of side-by-side installations.

If only (a) is the goal, finding $PSHOME in $env:PATH is sufficient, but that assumes that no other installation's $PSHOME comes earlier in $env:PATH, as that other installation would then take precedence.
If (b) is the goal (which is a stricter version of (a)), you would additionally have to rule out that no other installation's $PSHOME comes earlier in $env:PATH, but doing so robustly would require checking for pwsh executables in all $env:PATH entries, which is expensive.
If the fundamental intent is to make pwsh work even if $PSHOME is not in $env:PATH, to me the only sensible, non-obscure way to do so is to implement (b), which is the de-facto current behavior. And given the cost of the alternative implementation discussed, I think the current implementation is reasonable too.
However, a different implementation that would categorically avoid modifying $env:PATH would be to introduce an all-scopes alias named pwsh with an effective definition of: Set-Alias pwsh $PSHOME/pwsh and - on Windows only - additionally Set-Alias pwsh.exe $PSHOME/pwsh.exe
The alternative would be to not modify $env:PATH at all, which would require users to use & $PSHOME\pwsh ... calls to reliably call the CLI of the installation underlying the current session.
However, it's fair to assume that users have come to rely on just using pwsh, so I don't think such a change would be acceptable.

If I recall correctly, the intent of prefixing PATH with current $PSHOME is that pwsh used within a pwsh always refers to itself first (the (b) case).  As @mklement0 noted, it would be surprising to users to call pwsh and not have it be the current running version.  It looks like leaving dupes is by-design to avoid impacting startup perf https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs#L129-L138

authors: ShortRoundDev SteveL-MSFT mklement0


text:
Scoop Autocomplete does not work on pwsh 7.4

Prerequisites

[X] Write a descriptive title.
[X] Make sure you are able to repro it on the latest released version
[X] Search the existing issues.
[X] Refer to the FAQ.
[X] Refer to Differences between Windows PowerShell 5.1 and PowerShell.

Steps to reproduce
install pwsh 7.4 and scoop autocomplete tab completion stops working
Expected behavior
when typing scoop install and typing some keywords and clicking tab or ctrl and space it should autocomplete or give a suggestion

Actual behavior
its not doing anything after  installing pwsh 7.4

Error details
No response
Environment data
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals
No response

Did you install a tab completer for scoop prior to 7.4? I cannot get any sort of tab completion on <7.4. This may be a problem with scoop, I suggest also submitting an issue to their repo: https://github.com/ScoopInstaller/Scoop/issues. (assuming this is the same scoop you are talking about)


text:
Feature Request: powershell native  su and sudo

Summary of the new feature / enhancement
although  su and sudo  available on linux natively , but it only allow for application command,  the powershell CmdLet won't work !
this issue is about impelment a powershell native su/sudo  CmdLet  for both windows and linux

sudo  -Script {  get-content  /otheruser/o.txt }

Proposed technical implementation details (optional)
No response

This is already possible, on non-Windows at least, by doing
sudo pwsh { get-content /otheruser/o.txt }

Anything else is going to essentially do the equivalent to that as it will require starting a new process and serializing the data back and forth. At least with the above syntax it is clear you are running another processes whereas people using a builtin cmdlet might expect something like the below to work:
$proc = sudo-cmdlet { Get-Process -Id 1234 }
$proc.WaitForExit()

This won't ever be possible because you cannot transfer "live" objects between processes. Getting it to work on Windows is a whole other story as typically you cannot share the same console between and non-elevated and elevated process. There are third party tools like gsudo which are quite popular who work around these limitations in interesting ways.

I use gsudo on Windows. It can elevate script-blocks, create gsudo cache to avoid pressing button in UAC dialog.

the problem of sudo pwsh  is that it lose status/variables,
on windows ,there is a WindowsIdentity.RunImpersonated  , and it seems can change user
on linux, maybe powershell can use multiple process model ,  a main powershell process , and a set of user identity sub process,  and use someof RPC to transifer the  variable/env.

$a = "a.txt"   // runs on main process
su-admin  {  Get-Content $a }   //  transfer all variables/env  and start a   [sudo-subprocess]  and execute the script and transfer back the result

su-user -user 'user2'   //    transfer all variables/env  and start a   [user(user2)-subprocess]

get-content $a    //  run script on [user(user2)-subprocess]  and transfer back the result

the problem of sudo pwsh is that it lose status/variables

In UNIX the user-id and group-id are associated with the process. Although UNIX has setegid and seteuid these can only really be used by a root process, and really for restricting access, not expanding it.
There is also the security risk of having a single process gaining privileged access in some threads and not in others while sharing the same memory. Having the process boundaries enforces security and prevents information being accessed by less privileged code.

on linux

One way or another, under the hood there will still be the same sudo|doas, and they only understand executable files.

We've discussed this in the past and the main problem is the OS really needs to support sudo concept.  There has been some discussion in the Windows/Terminal repo on this topic https://github.com/microsoft/terminal/issues/146

FYI there is now an official sudo from Microsoft available, see https://github.com/microsoft/sudo


text:
Start-Job -Scriptblock ignores closure

I suspect changing this behavior now would be a breaking change.  I'm mainly opening this because I'm wondering how Start-Job -Scriptblock is meant to be used in scenarios where the concrete data used in the scriptblock has be factored-out.  This is a common scenario when system-specific configuration data is separated from the more general automation procedures used to enact the configuration.
Steps to reproduce
New-Module m {
    $v = 'm value'
    function f {
        param($sb)
        Start-Job $sb | Receive-Job -Wait
    }
} | Import-Module

$v = 'outer value'

& {
    $v = 'local value'
    f -sb { $using:v }.GetNewClosure()
}

Expected behavior
Output: local value
Actual behavior
Output:  m value
Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta.9
PSEdition                      Core
GitCommitId                    v6.0.0-beta.9
OS                             Microsoft Windows 6.3.9600
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I'm wondering how Start-Job -Scriptblock is meant to be used in scenarios where the concrete data used in the scriptblock has be factored-out.

You can use -ArgumentList parameter:
$sb = { param($arg) $arg }
1..10 | % { Start-Job -ScriptBlock $sb -ArgumentList $_ } | Receive-Job -Wait -AutoRemoveJob

I just spent hours figuring out that the above mentioned behaviour is screwing with my code.
This is, at least to me, clearly a BUG! The -ScriptBlock parameter behaves differently for for different commands. If I use Invoke-Command -ScriptBlock with my closure it works just fine. If I use it with Start-Job it does not. Neither the help nor any other place for powershell documentation mentions any of that.
Thank god I found this issue finally, I was beginning to think I was just too stupid to get my code to work.


text:
SPSelfServiceSiteCreation: Added self-service site creation resource

Pull Request (PR) description
New resource to manage a web application self-service site creation.
I've implemented a requirement so that if Enabled is set to false also ShowStartASiteMenuItem must be set to false. SharePoint does not strictly enforce this requirement, but if ShowStartASiteMenuItem is set to true when Enabled is false a link will be displayed to create a new site which will not work. When clicking this link a dialog will open and display an endless "Working on it..." message. Also the SSC configuration page enforces this, but due to a bug it is not fully working as intended.
I've not tested the hybrid self-service site creation.
This Pull Request (PR) fixes the following issues
Fixes #879
Task list

[x] Added an entry under the Unreleased section of the change log in the CHANGELOG.md.
Entry should say what was changed, and how that affects users (if applicable).
[x] Resource documentation added/updated in README.md in the resource folder.
[x] Resource parameter descriptions added/updated in schema.mof
and comment-based help.
[x] Comment-based help added/updated.
[ ] Localization strings added/updated in all localization files as appropriate.
[x] Examples appropriately added/updated.
[x] Unit tests added/updated. See DSC Resource Testing Guidelines.
[ ] Integration tests added/updated (where possible). See DSC Resource Testing Guidelines.
[x] New/changed code adheres to DSC Resource Style Guidelines and Best Practices.

This change is

@ykuijs Seems like there is a problem with AppVeyor. Do you know what the problem is?

Closing and reopening PR to kick off AppVeyor run

Codecov Report

Merging #911 into dev will increase coverage by <1%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##             dev    #911    +/-   ##
======================================
+ Coverage     92%     92%   +<1%
======================================
  Files        115     116     +1
  Lines      11454   11550    +96
  Branches       1       1
======================================
+ Hits       10623   10719    +96
  Misses       830     830
  Partials       1       1

source: gharchive/pull-request

authors: codecov-io jensotto ykuijs

repo: PowerShell/SharePointDsc


text:
SqlDatabaseRecoveryModel: Database name can now be a pattern

[x] Change details added to Unreleased section of CHANGELOG.md?
[ ] Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
[x] Examples appropriately updated?
[x] New/changed code adheres to Style Guidelines?
[x] Unit and (optional) Integration tests created/updated where possible?

This change is

Codecov Report

Merging #1052 into dev will decrease coverage by <1%.
The diff coverage is 38%.

@@         Coverage Diff          @@
##            dev   #1052   +/-   ##
====================================
- Coverage    97%     97%   -1%
====================================
  Files        32      32
  Lines      3930    3937    +7
====================================
- Hits       3844    3828   -16
- Misses       86     109   +23

@dcrreynolds thanks for sending in this PR! I think this has potential, but I have some thoughts around this change. Do you have a thought on how to solve the below?
Since the parameter Name is a Key. Then if I add two resources like below that would be allowed (configuration would compile), but this would yield a ping-pong behavior where both will always be false.
Configuration Example
{
    Import-DscResource -ModuleName SqlServerDsc

    node localhost
    {
        SqlDatabaseRecoveryModel MyDbWildcardToFull
        {
            Name                 = 'MyDb*'
            RecoveryModel        = 'Full'
            ServerName           = 'sqltest.company.local'
            InstanceName         = 'DSC'
        }

        SqlDatabaseRecoveryModel MyDbTestToSimple
        {
            Name                 = 'MyDbTest'
            RecoveryModel        = 'Simple'
            ServerName           = 'sqltest.company.local'
            InstanceName         = 'DSC'
        }
    }
}

I feel like that is a systemic issue of DSC, lots of DSC resources can ping pong in between themselves. We also see the same behavior with DSC and GPO or other methods of configuration.
We could have the resource log somewhere which recovery models have been configured, but something about that ideas feels like it could be problematic.
I have never seen codecov before. What is the failure trying to tell me?

@randomnote1 and others in the community, please can I get your input on this one? How do you see this change in relation to SqlAGDatabase?
Since SqlAGDatabase uses wildcards for the database names added to the AG I'm thinking that this change would help a lot. But at the same time I don't like the idea of introducing a potential ping-pong behavior. But maybe the pros are higher than the cons?
@dcrreynolds I think we cannot take in account changes made by other tools (like GPO), we have to see such change as a manual change, if the configuration is not in desired state then the configuration will be updated to be in desired state. But we can try make sure the configurations will not contradict each other.
Using a log as you say don't seem to be the best approach.

@dcrreynolds Codecov is complaining because there are not high enough code coverage with this change. Project has 97% coverage, this PR has 38% coverage of the code. You see in the https://github.com/PowerShell/SqlServerDsc/pull/1052#issuecomment-369122954 that 16 rows less are hit and missed rows increased with 23 rows. Also, the tests are failing which might result in some of these hits and misses.
To solve this you need to make sure the tests passes and add unit tests to cover this change. I did not mention that before because I wanted to discuss the design first. 😄

I think that the SqlDatabaseRecoveryModel resource differs fundamentally from SqlAGDatabase because it defines the database(s) that are to be a member of a specified Availability Group. SqlDatabaseRecoveryModel is defining a property on a database.
I do see @johlju's point about ping-pong behavior. But, this behavior could potentially be seen in a resource like SqlDatabaseRecoveryModel because of the wildcards used in defining the database membership. If a database matches a wildcard in two or more resources, it will throw an error at runtime when attempting to add the database to the second AG.
With all that said, I do like the idea of being able to specify a property on a database via wildcards or RegEx as I see it being immensely valuable in my own work. I think the risk of the potential ping-pong behaviour is acceptable, however we need to ensure the feedback to the end user is extremely clear. Otherwise troubleshooting the ping-pong behavior will be a nightmare.
Could we possible surface an informational message in the SQL log when the change is made? Maybe something like The recovery model on database '<database name>' has been changed from '<old recovery model>' to '<new recovery model>' by DSC based on the pattern '<pattern>'.. This would add some work, but might make it much more friendly to troubleshoot.

@randomnote1 Thank you for that insight!
I agree logging this would be the best. Maybe we could log an event using xp_logevent? Is there another (better) way?
Using xp_logevent would probably require a certain permission level on the account running the resource, that permission must be documented. Also, if the required permission is high, then maybe we should only log to SQL Server log when a wildcard/regex is assigned to Name, making it possible to use lower permission when not using wildcard/regex (permission to make changes to only the particular database).
So far pros over weigh the cons - so unless someone else objects we can continue doing this change, with the suggested changes.

Maybe we should add a optional parameter UseWildcard or UseRegularExpression that we use to switch the behavior of the resource?

We had discussed adding flags to the SqlAgDatabase resource and decided that it was unnecessary to add the overhead of the additional parameters. Theoretically it is possible to analyze the string coming in to determine if it is a wildcard or regex pattern. I'll have to defer to folks smarter than myself to discuss the merits of that.

For logging, xp_logevent may require too high of a permissions level. However, it is highly likely that the PsDscRunAsCredential is already a member of sysadmin.
Maybe we could utilize RAISEERROR to work around the permissions requirement.

Great conversation. I'll work to roll in the discussed changes and fix the codecov/test issues. Thanks!

RAISEERROR will update both SQL Server log and the Event Log, so I think we should only use RAISEERROR if it does not generate an Error entry in the Event Log. I see that we should preferably generate an information entry in the Event Log. A warning entry might work to, but en error entry could kick of errors in monitoring tools, and we don't want that.
If RAISEERROR can generate information or warning entries then I agree to use RAISEERROR.
@dcrreynolds I agree, great conversation! When we in the community work together we get the best result! All opinions matter, wish more people had time to comment on stuff.

@dcrreynolds the method that you will use to write to the SQL Server log, please add that as an helper function in the helper module SqlServerDscHelper. I see that this could potentially be used more widely to write log information by other resources too.

After some testing, it seems that RAISEERROR can generate information log entries, but does require the user to be a member of the sysadmin fixed server role or a user with ALTER TRACE permissions.
I also learned that the SQL is generating a similar message in the SQL and app longs when it makes the change. "Setting database option RECOVERY to FULL for database 'SP_Search'." The only difference is it doesn't say why the change was made.
Does the built in logging provide enough info? Are we ok with the requirements for RAISEERROR?

@dcrreynolds What happens if the user does not have that permission? No information log entry in the Application Event Log, but in the SQL Server log? Or no log information at all in either Application Event Log or the SQL Server log?
The point that @randomnote1 made was that it do write why it changed or whom changed it, so it would be easier to determine what causing the change.
Depending on the answer to the questions above, I would be OK with the permission requirement for the RAISEERROR, if that is a requirement only when using the resource with a wildcard. When not using a wildcard I don't see the need for logging, since the resource could be run with a user with less privileges. I can be swayed to write a log even without a wildcard, but that would mean a breaking change.

Labeling this PR as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on the PR is taken up again.

Reopening this PR as it was wrongly closed by GitHub All Stale due to miss configuration. It still labeled as abandoned. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on the PR is taken up again.

Hi there! Sorry for sitting on this for so long. I've made a small update that shows one way using RaiseError could look like for logging the change. Once we get to a method that we like, I will fix up the test. I've attached what the SQL logs and application logs show when DSC makes a change.

Relabeled this as 'needs investigating' (by community).

It looks to me like what was asked for.
The messages text does in the screen dumps does not contain 'PowerShell Desired State Configuration Updated...'. See the text in the code. I assume you took the screen dumps before making the final message text?
Nobody have objected, so go with his.

good to go!

@dcrreynolds just pinging to see if you have time to work on this?

Hi! Yes I can finish this up. I didn't realize this had gotten to be over a year old!

@dcrreynolds Time flies when one are having fun 😄 Would be great to get this merged. I hope it is easy to rebase this one after this long.

Hi! I haven't forgotten about this, spent some time merging everything in tonight. For the review above, I have made most changes.
I do think keeping the logic using the like competitor is better than using match. Using match will break a lot of backwards compatibility since it will likely accidentally start applying to a lot of new DBs.
I've added a read-only property named DatabaseInfo that is a Hashtable of DBName and RecoveryMode. This is currently configured to only include matching DB names to avoid confusion. The RecoveryModel parameter was left unchanged since returning the desired model as opposed to the actual would lead to some confusion. A comma separated list is informative without dropping data, allows for a quick status comparison, and the new hashtable supports better access programatically.
Let me know if all of this works for you.

@dcrreynolds will be great to get this to the finish line. I read you comments. Since it was a while ago, would you mind go into Reviewable and write 'Done' on the review comments that is fixed, and add the respective comments you made in the previous comment inside the Reviewable so I understand the context. 🙂
Also, You said you merged changes into your working branch, but I don't see any new commits here yet. Did you (force) push the changes?  I guess that you also resolved the conflicts since you merged the recent changes.

Closing this PR due to inactivity. If there are someone who wants to work on this issue or PR please open a new PR.

authors: codecov-io dcrreynolds johlju randomnote1

repo: PowerShell/SqlServerDsc


text:
Add UpdateInputOutput parameter to Update-MarkdownHelp and Update-MarkdownHelpModule

Added UpdateInputObject parameter which will allow user to update the input and output for their existing markdown files.  Also updated the parser to correctly parse input and output from the get-help call.  Previously it would treat all types as a single string, now it will treat each type on a new line as a separate type.
Previously, parsed as:
"
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultKey
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificate
"
Now parsed as:
"Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultKey"
"Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret"
"Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificate"
This means that the output looks like:
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultKey
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificate
Instead of:
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultKey
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret
Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificate

I noticed that your have multiply commits from other PRs mixed in this PR

Would you mind to cherry-pick the commits for this PR into a separate branch and user git rebase instead of git merge to get it to the latest master? That would simplify the review a ton.

authors: maddieclayton vors

repo: PowerShell/platyPS

license: mit

license_source: bigquery


text:
Delete a Ride

User can delete a ride if he/she has cancelled the plan.

Implemented and tested.


text:
🛑 Open API is down

In 4d04ec9, Open API (https://opensourceapi.vercel.app) was down:

HTTP code: 500
Response time: 6297 ms

Resolved: Open API is back up in ca7d705.

repo: Pradumnasaraf/Monitoring


text:
Don't finished the deliver - when it's not succesful

...happened to @anetacamo when password was mistyped.
This should not have an effect on the workon state - since she didn't successfully deliver - yet

The mistyped password was for the https git url., When changing the remote to a git url using ssh it uses the key in stead, which seems to work. Then she does a workon and a deliver. I cannot see the issue.

authors: groenborg lakruzz

repo: Praqma/git-phlow


text:
Feature: PTooltip component

Description
Adds a new PTooltip component. Supports tooltip text as a prop as well as two slots to customize the tooltip itself.

Thanks @stackoverfloweth!

@brandonreid and @stackoverfloweth I added a couple more commits to this after looking at ARIA: tooltip role from MDN.

Added a 500ms delay on opening
Added the ability to press escape to close the tooltip
Added the ability to open the tooltip on focus (keyboard navigation)
Added role and aria-describedby attributes to appropriate elements.

repo: PrefectHQ/prefect-design


text:
Support for docker build path

Describe the current behavior
Currently the build_docker_image step overrides the build path to always be the one of the command line and thus the path of prefect.yaml (as the cli does not support refering to prefect.yaml files in other directories).
Describe the proposed behavior
Like for other build_kwargs, let's have the current path as a default but still allow to have the possibility to override it.
Example Use
I have a single repository with multiple flows having different requirements.
Each flow has its own folder and there is also a shared module for them all of them. To get the shared module in the docker image I need to be able to run the build from the root of the repository.
Additional context
I will open a PR in the day
Have a nice day!

Sorry I just saw that there was already a PR for that, will close the issue in favor of #80

repo: PrefectHQ/prefect-docker


text:
After registering blocks in CLI, link to blocks catalog is broken

Maybe because blocks catalog for the repo isn't in the docs yet. :)
Output:
┃ Registered Blocks  ┃
┡━━━━━━━━━━━━━━━━━━━━┩
│ GitHub Credentials │
│ GitHub Repository  │
└────────────────────┘

 To configure the newly
registered blocks, go to
the Blocks page in the
Prefect UI:
None/blocks/catalog

I think it's because you haven't logged onto Cloud or set the PREFECT_API_URL yet.

When using PREFECT_UI_URL, we should handle the null case.

authors: ahuang11 discdiver madkinsz

repo: PrefectHQ/prefect-github


text:
How pulling works

I can't find any documentation on how gitfs pulls are working. You say that you make commit on every file change and resolve conflicts by prefering local versions. But what happens if somebody commits to remote git repo while it's mounted in gitfs. There's no way remote server can let gitfs know about this commit, so you have to pull very often (ie. before every read/write to gitfs). How is this handled? can you please write it in README file? Thanks.

Oh, sorry, i've found the docs. It's updated periodicaly each 30 seconds (by default).

repo: PressLabs/gitfs


text:
As a data user, I want to see multiple source types and source citations when an event is documented in multiple sources, so that I can understand and access the sources for the data.

testing notes
Check the provided test exports (both csv and json) for items with multiple sources. In the JSON, there should be a list of sources with available information included for each relevant source. In the CSV, if there are multiple values the information in each of the source fields should be delimited by semicolon, and they should correspond.

Some events will now have multiple footnotes (e.g. when the same subscription is documented in both the logbooks and on a lending library card). The events export needs to handle this and include all footnotes for any event.

I noticed that 29 subscription events do not have any source. Do you know why @rlskoeser -- I'll post a list to Slack.

I noticed that 29 subscription events do not have any source. Do you know why @rlskoeser -- I'll post a list to Slack.

Everything else checks out from my point of view.  This is ready to close. All the missing events might be from the cards -- Camey is investigating.

Everything else checks out from my point of view.  This is ready to close. All the missing events might be from the cards -- Camey is investigating.

Missing sources -> human error. Ready to close.

Missing sources -> human error. Ready to close.

authors: jkotin rlskoeser

repo: Princeton-CDH/mep-django


text:
rust keyword/string precedence issue

Migrated from rust-lang/crates.io#1468.
This code is incorrectly highlighted:
    ```rust
    let repo = github.repo("user", "repo");
    ```

There should be two strings, but somehow the use keyword gets picked out (?).

Cannot reproduce using Test drive.

The rust language definition your using seems to be outdated (or modified).

@durka Can you double check if this issue is still valid?

It is indeed fixed in the latest release.

authors: RunDevelopment durka mAAdhaTTah

repo: PrismJS/prism


text:
consle log

whats a consle log pls tell me

Hello! This doesn't seem to be an issue with prismarine-web-client. If this pertains to another issue, please post in the relevant issue.

repo: PrismarineJS/prismarine-web-client


text:
Clicking the button "Remove All Processed Items" look like rollback

When you click the button "Remove All Processed Items" the progressbars starts to animate to 0% percent and look like they are rolling back?
Furthermore for each click it trigger the notification:
"Media saved: Media saved without any errors"
Maybe "just" remove the processed items or if it needs to display message, customize the message to a more specific message?

Hahaha :D would be fun to rollback the upload.
All of this is a bug! So I'll see when I could fix it ;)

Well the rollback seems to be something weird in the combination of angular and the bootstrap animation. I've removed the animation to prevent this behavior. But I still don't know why :(
Anyway, try it out!

authors: ProfessorFarnsworth bjarnef


text:
[GAME] AnimationsComponent refactors

          Hmmm, ich tue mich schwer mit dem Zuschnitt der Component: Warum muss mein Gesundheitssystem und/oder meine Gesundheitskomponente wissen, was ich anhabe und mich passend animieren? Wäre das nicht eher in der AnimationComponent anzusiedeln? Damit würde dann auch der häufige Zugriff "nimm Animation X aus Component Y und schiebe sie in die AnimationComponent" weg. Natürlich bräuchte eine Entität dann verschiedene Zustände (lebt, stirbt, tot, steht still, bewegt sich, greift an, duckt sich, Schlag abbekommen) und die Components können dazu passend Gesundheitssachen speichern oder Animationen speichern.

Originally posted by @cagix in https://github.com/Programmiermethoden/Dungeon/pull/245#discussion_r1106896186

Das hat auch den Nachteil, dass die Animationen über viele Components verstreut werden und die AnimationComponent ihrem Namen eigentlich nicht gerecht wird. Das ist nämlich eigentlich nur eine IdleAnimationComponent.
Aus Systemsicht sehe ich die Trennung der Zuständigkeiten verletzt bzw. schlecht modelliert.

Ich mach mal einen Vorschlag:

das AnimationComponent wird in DrawComponent umbenannt, das reduziert die Verwirrung durch den Namen und zieht auch eine bessere Verbindung zwischen dem Component und dem DrawSystem
Das Component speichert weiter die Idle und die currentAnimation, welche dann vom DrawSystem gezeichnet wird.
Das Konzept, dass andere Components auch Animationen speichern und andere Systeme die currentAnimation setzten, würde ich beibehalten.

Von einer weiteren Trennung in IdleComponent und DrawComponent zum "auslagern" der Idle-Animation würde ich absehen. Die Idle-Animation ist die default-Animation einer Entität und irgendwas muss ja gezeichnet werden, wenn die Entität nichts macht.

Ein zweiter Vorschlag, wäre das verteile speichern der Animationen beizubehalten, aber ein zentrales System zum setzten der Animationen hat.
Das AnimationSystem müsste dann durch jedes Component einer Entität itterieren und prüfen ob es eine Animation hat. Dann muss geprüft werden, ob diese Animation denn auch gesetzt werden muss.
Vorteil:

Klarer Zuständigkeitsbereich auf System ebene
einfacheres Ranking der Animationen, also welche Animation eher abgespielt werden soll (dieAnimation > runAnimation)

Nachteil:

damit das  AnimationSystem bestimmen kann, ob die Animation des betrachteten Components verwendet werden soll, müsste das AnimationSystem quasi den selben check machen, wie das eigentliche System des Components.

Da das schwammig formuliert ist: Das VelocitySystem prüft, ob sich die Entität bewegen soll und in welche Richtung. Anhand dieser Informationen bestimmt das System, welche Animation ausgeführt werden muss und setzt die neue Position der Entität.
Das AnimationSystem müsste daher die selbe Prüfung machen, würde nur nicht die neue Position setzten.

das AnimationSystem müssten mit jedem neu implementieren System erweitert werden. Grade als Framework irgendwie doof.

@cagix
Das sind m.M nach die beiden sinnvollsten Möglichkeiten.
Ich wäre für https://github.com/Programmiermethoden/Dungeon/issues/348#issuecomment-1537149304
Wir sollten hier eine Entscheidung treffen und umsetzen.

@AMatutat Ich bin noch unschlüssig, ob es wirklich einfacher ist, die Animationen verteilt zu bearbeiten. Klar, ich muss im verteilten Fall beim Erstellen einer neuen "Fähigkeit" nur das entsprechende neue System plus die neuen Components basteln und das neue System würde dann die aktive Animation "setzen" - im anderen Fall müsste ich die AnimationComponent mit erweitern und hier diesen neuen möglichen Zustand bekannt machen, was auch irgendwie hässlich ist. Ich kann nicht den Finger so richtig drauf legen, aber irgendwie machen mich beide Varianten noch nicht richtig "glücklich".
Zu Deinen Vorschlägen: Ich finde eine IdleAnimation erstmal gut - wir müssten aber nochmal darüber nachdenken, ob man wirklich "nach links idled" und nach "rechts idled" oder nicht einfach nur "idled". Sonst müsste man nämlich auch nach "oben" und nach "unten" herumidlen können.
Wenn wir mangels besserer Ideen beim verteilten Szenario bleiben: Die Systeme, die gearbeitet haben (auf einer Entität aktiv waren), könnten ja irgendwo ein "Häkchen" setzen, und das DrawSystem kann das dann nutzen. Aber wenn ich das jetzt weiterdenke, ist das eigentlich nix anderes, als wenn ein aktiviertes System in der DrawComponent der Entität eben die aktive Animation setzt und das DrawSystem das dann anzeigt.
Wer setzt die Animation eigentlich von "run" auf "idle" zurück? Und wann?
Was wäre, wenn es eine IdleComponent und eine DrawComponent geben würde und passend dazu ein IdleSystem, welches den Zustand einer Entität aktiv auf "Idle" setzt? Die DrawComponent hätte dann nur noch die aktive Animation? Klingt aber auch ein wenig nach Overkill.

Einerseits finde ich es nicht günstig, die Animationen über so viele Components und Systeme zu streuen. Irgendwie gehört das in eine gemeinsame Struktur.
Andererseits repräsentiert das einen Zustand einer Entität, und der kommt ja über die verschiedenen Components.
Ins Unreine gedacht: Die Animationen sind doch Strings (eigentlich Pfade), die alle irgendwie so aufgebaut sind: "pfad/pfad/<entität>/<zustand>/*.png" (wobei der *.png-Teil nicht Teil des jeweiligen Strings ist). Eine AnimationComponent könnte also alle diese Pfade einer Entität in einer Map halten: "<zustand>":["1.png", "2.png", ...]. Zusätzlich könnte es in der AnimationComponent ein Feld active: String geben, welches dann von außen von den Systemen gesetzt wird. Statt der Strings könnte man vielleicht auch ein Enum definieren? Dann hätte man die Animationen in einer Component gekapselt und die Systeme könnten den aktiven Zustand von außen setzen, ohne konkret die Animation kennen zu müssen.

Puh.. das war ein ganz schönes geprickelt aber ich hab jetzt ein minimal working example gebastelt.
Jetzt muss ich das nur in unser Dungeon integrieren (habe zum testen quasi alles rausgeworfen, da das umbauen echt viel aufwand ist).
Was ich mir noch überlegen muss, ist wie man die Animation-Konfigurieren kann.
Bei einer Animation kann man theoretisch den zeitlichen Abstand zwischen den Frames (also im Grude wie schnell die Animation abspielt) bestimmen und sagen ob die Animation loopen soll oder nicht.
In 9 von 10 Fällen wird die Default-Einstellung reichen.
Vielleicht spendier ich der Animation Klasse setter Methoden. Dann erstellt man sich erst das DrawComponent mit den default Animationen und holt sich dann mit getAnimation(String name) die Animation und konfiguriert sie um.
public final class DrawComponent extends Component {

    public static final String IDLE_RIGHT = "idleRight";
    public static final String IDLE_LEFT = "idleLeft";
    public static final String MOVE_RIGHT = "runRight";
    public static final String MOVE_LEFT = "runLeft";
    public static final String HIT = "hit";
    public static final String DIE = "die";
    public static final String ATTACK = "attack";
    private final Logger LOGGER = Logger.getLogger(this.getClass().getName());
    private final Map<String, Animation> animationMap;
    private Animation currentAnimation;

    public DrawComponent(Entity entity, String path) {
        super(entity);
        animationMap = new HashMap<>();
        loadAnimationsFromPath(path);
        animationMap.forEach((x, y) -> java.lang.System.out.println(x));
    }

    public void loadAnimationsFromPath(String path) {

        ClassLoader classLoader = getClass().getClassLoader();
        File directory = new File(classLoader.getResource(path).getFile());
        String motherDir = directory.getPath();

        if (!directory.exists() || !directory.isDirectory()) {
            return;
        }

        File[] subDirs = directory.listFiles(File::isDirectory);

        if (subDirs == null || subDirs.length == 0) {
            return;
        }

        for (File subDir : subDirs) {
            String subDirName = subDir.getName();
            File[] files = subDir.listFiles();

            if (files == null || files.length == 0) {
                continue;
            }

            Set<String> fileNames = new HashSet<>();
            for (File file : files) {
                if (file.isFile()) {
                    fileNames.add(file.getPath());
                }
            }
            Animation animation = new Animation(fileNames, 3, true);
            animationMap.put(subDirName, animation);
        }
    }

    /**
     * Set the current animation displayed on the entity.
     *
     * <p>If the animation passed is not displayed on the entity, there may be another point in the
     * code where the animation is overwritten on the same tick. (e.g. in {@link VelocitySystem
     * VelocitySystem}).
     *
     * @param animationName Name of the new current animation (this is the name of the directory).
     */
    public void setCurrentAnimation(String animationName) {
        Animation animation = animationMap.get(animationName);
        if (animation != null) this.currentAnimation = animation;
    }
    /**
     * Get the current animation being displayed on entity.
     *
     * @return current animation of the entity
     */
    public Optional<Animation> getCurrentAnimation() {
        return Optional.ofNullable(currentAnimation);
    }

    public Optional<Animation> getAnimation(String name) {
        return Optional.ofNullable(animationMap.get(name));
    }
}

@malt-r das muss natürlich auch auf DSL ebene mitgedacht werden.
Kannst du dafür eine grobe Einschätzung geben?

@cagix entspricht das grob deiner Vorstellung?

@AMatutat Das klingt gut! Ich würde den inneren Teil noch nach Animation reinziehen - Eine Animation sollte selbst wissen, dass sie aus den Dateien in einem Ordner besteht:
public final class DrawComponent extends Component {

    ...

    /**
     *
     * @param path to animation, needs to be something like "character/hero"
     */
    public void loadAnimationsFromPath(String path) throws IOException {
        ClassLoader classLoader = getClass().getClassLoader();

        File directory = new File(classLoader.getResource(path).getFile());
        if (!directory.exists() || !directory.isDirectory()) {
            throw new FileNotFoundException("Path "+path+" not found.");
        }

        Arrays.stream(directory.listFiles())
                .filter(File::isDirectory)
                .collect(
                        Collectors.toMap(
                                subDir -> subDir.getName(),
                                subDir -> Animation.of(subDir, 3, true)));

    ...
}

public class Animation {
    ...

    public static Animation of(File subDir, int frameTime, boolean looping) {
        Set<String> fileNames = Arrays.stream(subDir.listFiles()).
            map(File::getPath).
            collect(Collectors.toSet());
        return new Animation(fileNames, frameTime, looping);
    }

    ...
}

Und dann könnte man noch hingehen und per Singleton-Pattern sicherstellen, dass die Animationen zu einem Pfad immer nur einmal geladen wird. Analog zum java.util.logging.Logger müsste Animation#of() in einer internen Map nachschauen, ob zum subDir schon was geladen wurde und das dann bei Bedarf laden und in der internen Map ablegen und dann zurückliefern.

Und dann könnte sollte man noch hingehen und per Singleton-Pattern sicherstellen, dass die Animationen zu einem Pfad immer nur einmal geladen wird.

Ne das darfst du nicht machen. Die Animation selbst speichert auch den Status der Animation (also in welchen Frame befindet sich die Animation grade/ welches Bild ist das aktive Bild) und zwei Monster die auf File-Ebene die gleiche Animation haben, haben aber einen unterschiedlichen Animationsstatus.
Man könnte darum jetzt natürlich noch einen Wrapper basteln.....
Dann könnte man die "Animations-Logik" also das wie schnell ist die Animation, welches Bild ist das nächste Bild in der Animation und loopt sich der kram etc von der eigentlichen Animation trennen.
Dann könntest du auch noch einen Schritt weiter gehen und zu beginn des Spiels, alle Animationen die es gibt einladen und in einer Map speichern.
public final class Animation {
private static HashMap Animations <String, List<String> ALL_ANIMATIONS; //eine Animation ist nur eine Liste an Pfaden
protected final List<String> animationFrames;
...

public static loadAnimations(){//s.o } //müsste dann im Game#setup aufgerufen werden

public Animation (String key, int frameTime, boolean looping) (
...
}

...

Da sprichst Du einen Punkt an.
Ich habe oben Animation == AnimationComponent gesehen. Aber das ist vermutlich falsch, und es gibt (sollte geben):

eine Animation (kennt den Pfad plus die Texturen), und
eine AnimationComponent (kennt eine aktuelle Animation sowie eine Default-Animation ("Idle-Animation").

Für Animation könnte die "Optimierung" mit Singleton analog zum Logger Sinn machen - letztlich macht unser aktueller TextureHandler auch nix anderes (vom Gedanken her).

Viele Sachen die ich mir angucken muss, aber zu:

Allerdings haben wir (egal, welche Variante) immer noch das ursprüngliche Problem, dass quer durch die Systeme Animationen erzeugt werden und in der DrawComponent gesetzt werden

Also erstellt werden Animationen dann nur noch im DrawComponent bzw in Animation.
Gesetzt werden die über die Systeme verteilt, das stimmt, aber das geht in meinen Augen auch nicht anders. Nur die konkreten Systeme wissen, ob eine bestimmte Aktion dazu führen soll, das eine bestimmte Animation gespielt werden muss.

und zum Erzeugen braucht man den passenden String/Pfad. D.h. diese Pfade werden über alle möglichen Klassen verstreut und sind nur schwer zu finden und zu korrigieren.

Auch dieses Problem seh ich als unlösbar. Irgendwo musst du halt sagen, ein Hero sieht aus wie ein Hero.
Man könnte die Pfade irgendwo zentral Sammeln (evtl auch in einer config datei).
Das Problem welches wir lösen, ist die verteilte Erstellung und Speicherung von Animationen. Und zusätzlich machen wir das System flexibler, da Texturen dynamisch eingelesen und angesprochen werden können. Ich (als Studi) kann im assert Ordner im Hero-Verzeichnis einfach ein neuen unterordner mit Bildern erstellen und hab direkt eine verwendbare Animation im Code.
Es fordert natürlich vom Entwickler, seine Pfade beisammen zu halten und seinen "shit together" zu halten.

Allerdings haben wir (egal, welche Variante) immer noch das ursprüngliche Problem, dass quer durch die Systeme Animationen erzeugt werden und in der DrawComponent gesetzt werden

Also erstellt werden Animationen dann nur noch im DrawComponent bzw in Animation.

Ganz genau. Was ich meinte: Die Systeme geben das "in Auftrag" und müssen dazu die Pfade kennen. Wir verstreuen also die Pfade als (magic) Strings quer über die Architektur, was ein späteres Refactoring der Asset-Strukturen quasi unmöglich macht bzw. viel Arbeit verursacht.
Eine fertige Lösung habe ich leider (noch) nicht.
Der aktuelle Ansatz ist nett dynamisch, d.h. die Animationen laden sich selbst aus den passenden Unterordnern und es braucht keine zentrale Konfig oder Datenstruktur. Aber es bringt eben auch die typischen Nachteile mit sich: Alle Beteiligten müssen die passenden Keys (Strings) kennen und es kracht erst zur Laufzeit.
Eine Alternative wäre, Animationen zu "typisieren" - vielleicht über verschachtelte Enums (Typ+Pfad) (das wäre der Type-Object-Ansatz). Damit müsste man zwar immer das/die Enum/s erweitern, wenn es neue Animationen gibt, aber die beteiligten Klassen würden nicht mehr den Pfad kennen müssen (der aktuell als Magic String in den System-Klassen definiert ist), sondern würden direkt die Enum-Konstanten nutzen. Schöner Nebeneffekt: Man merkt bereits zur Compile-Time, ob es passt (bzw. die IDE meckert sofort).

Ganz genau. Was ich meinte: Die Systeme geben das Erstellen von neuen Animationen "in Auftrag" und müssen dazu die Pfade kennen. Wir verstreuen also die Pfade als (magic) Strings quer über die Architektur, was ein späteres Refactoring der Asset-Strukturen quasi unmöglich macht bzw. viel Arbeit verursacht.

Das beschreibt den IST zustand. Nach der Änderung wäre es:
Das erstellen geben die Systeme nicht in Aufrag. Das passiert ja beim erstellen des DrawComonent.
new DrawComonent(hero, "character/hero"); erzeugt gleich alle Animationen die im asset Pfad character/hero liegen.
Dieses character/hero muss halt irgendwo liegen (ich denke mal in der EntityFactory)

Eine Alternative wäre, Animationen zu "typisieren" - vielleicht über verschachtelte Enums (Typ+Pfad) (das wäre der Type-Object-Ansatz). Damit müsste man zwar immer das/die Enum/s erweitern, wenn es neue Animationen gibt, aber die beteiligten Klassen würden nicht mehr den Pfad kennen müssen (der aktuell als Magic String in den System-Klassen definiert ist), sondern würden direkt die Enum-Konstanten nutzen. Schöner Nebeneffekt: Man merkt bereits zur Compile-Time, ob es passt (bzw. die IDE meckert sofort).

Hmm ja, man müsste jetzt noch schauen wie man das Enum mit dem Framework in verbindung bringt. Wie füge ich (als Studi) denn einen neuen Enum-Wert hinzu, ohne die Code des Enums anzufassen?
Ich glaube wir nähern uns langsam einem sinnigen Gesamtkonzept.

Ganz genau. Was ich meinte: Die Systeme geben das Erstellen von neuen Animationen "in Auftrag" und müssen dazu die Pfade kennen. Wir verstreuen also die Pfade als (magic) Strings quer über die Architektur, was ein späteres Refactoring der Asset-Strukturen quasi unmöglich macht bzw. viel Arbeit verursacht.

Das beschreibt den IST zustand. Nach der Änderung wäre es: Das erstellen geben die Systeme nicht in Aufrag. Das passiert ja beim erstellen des DrawComonent. new DrawComonent(hero, "character/hero"); erzeugt gleich alle Animationen die im asset Pfad character/hero liegen. Dieses character/hero muss halt irgendwo liegen (ich denke mal in der EntityFactory)

Ja, aber was ist mit anderen Systemen, die noch anderen Animationen kennen, zum Beispiel die "Sterbe-Animation" und so? Das Konzept sieht doch vor, dass die Systeme Animationen in DrawComponent reinschieben dürfen als aktuelle Animation. Na gut, vermutlich kennen nicht die Systeme diese anderen Animation, aber dann die entsprechenden Components. Aber das Problem bleibt: Wir reden über Strings, die einzeln in den entsprechenden Klassen hinterlegt sind und die synchron zum Dateisystem gehalten werden müssen.

Eine Alternative wäre, Animationen zu "typisieren" - vielleicht über verschachtelte Enums (Typ+Pfad) (das wäre der Type-Object-Ansatz). Damit müsste man zwar immer das/die Enum/s erweitern, wenn es neue Animationen gibt, aber die beteiligten Klassen würden nicht mehr den Pfad kennen müssen (der aktuell als Magic String in den System-Klassen definiert ist), sondern würden direkt die Enum-Konstanten nutzen. Schöner Nebeneffekt: Man merkt bereits zur Compile-Time, ob es passt (bzw. die IDE meckert sofort).

Hmm ja, dann wäre das Enum der Key. Man müsste jetzt noch schauen wie man das Enum mit dem Framework in Verbindung bringt. Wie füge ich (als Studi) denn einen neuen Enum-Wert hinzu, ohne die Code des Enums anzufassen?
Ich glaube wir nähern uns langsam einem sinnigen Gesamtkonzept.

Framework ist ein Problem dabei. Das andere: Wir bräuchten irgendwas "verschachteltes", d.h. es gibt was für den Hero ("character/") und darunter dann für Idle-Links, Idle-Rechts, Move-Links, Move-Rechts, Sterbe, ... Dito für die anderen. D.h. wir sprechen über eine Art Animations-Baum, wo man sich die passenden Blätter rauspickt.

Ok, ich glaube wir sind noch nicht auf einen nenner, welche "Strings" bzw elchen String-Teil wir als problematisch ansehen.
Für das einladen brauch ich z.B "cheracter/hero" Die Systeme die Animationen setzten wollen, brauchen den Teil dahinter.
Also z.B "/run_left".
Ersteres ("cheracter/hero") brauch ich nur beim erstellen des DrawComponents und ist für jeden Entitäts-Typen anders (monster, schatzkisten etc.)
Letzteres ("/run_left") ist für die Systeme wichtig, um die exakte Animation  anzusprechen. Mir als System ist ja egal ob ich grade den Helden oder ein Monter angucke, hauptsache das Ding läuft nach rechts.
Den zweiten Teil könnte ich mir als Enum-Vorstellen. Der erste Teil wäre in meinen Augen eher eine Konstante in der EntityFactory

Ok, ich glaube wir sind noch nicht auf einen nenner, welche "Strings" bzw elchen String-Teil wir als problematisch ansehen.

🤣 ich finde alle teile des strings problematisch - wenn ich die dinger frei über irgendwelche klassen (ob nun system oder component oder was anderes) verteile.

Für das einladen brauch ich z.B "cheracter/hero" Die Systeme die Animationen setzten wollen, brauchen den Teil dahinter. Also z.B "/run_right".
Ersteres ("cheracter/hero") brauch ich nur beim erstellen des DrawComponents und ist für jeden Entitäts-Typen anders (monster, schatzkisten etc.) Letzteres ("/run_right") ist für die Systeme wichtig, um die exakte Animation anzusprechen. Mir als System ist ja egal ob ich grade den Helden oder ein Monter angucke, hauptsache das Ding läuft nach rechts. Ich würde also dem DrawComponent der grade betrachteten Entität also sagen setCurrentAnimation("run_right") oder als Enum setCurrentAnimation(AnimationTyp.RUN_RIGHT)

genau. das löst den einen teil für den untertyp der animation (ich hatte das oben "verschachtelt" genannt). der andere teil, nämlich dass beim erstellen der drawcomponents für die einzelnen monster und kisten und heros noch das "character/hero" gebraucht wird, der müsste auch entsprechend irgendwo fixiert werden.

Den zweiten Teil könnte ich mir als Enum-Vorstellen. Der erste Teil wäre in meinen Augen eher eine Konstante in der EntityFactory

also "run_right" über eine enum und "character/hero" über konstanten in EntityFactory?
der vorteil wäre, dass man in EntityFactory ja sowieso für jeden neuen monster-typ (oder kisten ...) was anpassen muss. dann könnte man da den pfad auch setzen und man hätte das alles an einer stelle. die EntityFactory würde diesen pfad dann der jeweils erzeugten DrawComponent mitgeben. diese müsste dann mit den relevanten konstanten aus dem enum versuchen, die animationen zu erzeugen, wobei diese den pfad komplett zusammenbasteln (also aus der enum-konstanten den string nutzen, um die texturen zu finden). die systeme würden nur noch das enum kennen müssen und könnten damit "typsicher" auf die konkreten animationen zugreifen.
könnte so gehen.
für mich als user bedeutet das aber, dass ich mental zwei stellen beachten muss: das enum und die factory - beides zusammen definiert zusammen mit der gradle-konfiguration, wo ich die pfade für die texturen anlegen muss. das finde ich grad noch schwierig/unübersichtlich.

für mich als user bedeutet das aber, dass ich mental zwei stellen beachten muss: das enum und die factory - beides zusammen definiert zusammen mit der gradle-konfiguration, wo ich die pfade für die texturen anlegen muss. das finde ich grad noch schwierig/unübersichtlich.

Vielleicht bin ich zu nah dran, aber ich find das grade irgendwie recht schlank und intuitiv. Grade auf File-Ebene. Ich hab mein Ordner, dort für jede Konstante ein Sub-Folder und für jeden Enum-Wert ein sub-sub-Folder.
Die Frage wie ich das Enum erweitere bleibt natürlich. Es in contrib zu legen ist eigentlich falsch, da ich von core darauf zugreifen werde.
Vielleicht anstelle eines eums eine Map? Aber die müsste ich auch irgendwo füllen.

für mich als user bedeutet das aber, dass ich mental zwei stellen beachten muss: das enum und die factory - beides zusammen definiert zusammen mit der gradle-konfiguration, wo ich die pfade für die texturen anlegen muss. das finde ich grad noch schwierig/unübersichtlich.

Vielleicht bin ich zu nah dran, aber ich find das grade irgendwie recht schlank und intuitiv. Grade auf File-Ebene. Ich hab mein Ordner, dort für jede Konstante ein Sub-Folder und für jeden Enum-Wert ein sub-sub-Folder.

hihi - ich hab da meine studis vor augen.

Die Frage wie ich das Enum erweitere bleibt natürlich. Es in contrib zu legen ist eigentlich falsch, da ich von core darauf zugreifen werde. Vielleicht anstelle eines eums eine Map? Aber die müsste ich auch irgendwo füllen.

eine map (in Game oder statisch irgendwo in config) würde es den usern erlauben, zu einem festen key den konkreten pfad selbst einzustellen und auch neue key/path-paare anzulegen. aber die keys müssten trotzdem fest definiert sein (enum o.ä.), damit wir "typsicherheit" bekommen - sonst reden wir ja wieder über strings.

Vermutlich ist das jetzt etwas wirr, aber was wäre wenn wir kein Enum verwenden, sondern ein Interface?
public final interface IAnimationTyp{
String getAnimationTyp();
}

....

public final RunLeftAnimationTyp implementsI AnimationTyp{
public String getAnimationTyp() {return "runLeft"};
}

Im DrawComponent
...
public void setCurrentAnimation(IAnimationTyp animation){
currentAnimation = animations.get(animation.getAnimationTyp); //stark vereinfacht
}
...

Im VelocitySystem(){
..
drawComponent.setCurrentAnimation( new RunLeftAnimationTyp() );
...
}

Vorteil:
- Typsicher
- Einfach erweiterbar

Nachteil
- unintuitiv
- Strings werden wieder auf Verteilt (auch wenn sie leichter zu finden sind)

Jetzt wo ich es aufgeschrieben habe, find ich das nicht mehr so gut.

Interfaces klingen interessant. Aber Du brauchst ja viele davon - während in einem Enum alles in einem Ding definiert werden kann.
Vielleicht hilft hier eine EnumMap? Siehe https://www.baeldung.com/java-enum-map

Richtig sexy wäre halt Enum extends Enum aber java ist doof....

Darüber hatte ich auch nachgedacht: Damit hätten wir einen gemeinsamen Typen, und die Studis könnten davon ihre eigenen Enums ableiten. Aber: Wir brauchen ja vor allem die Enum-Konstanten - und wenn wir ein Interface als Typ nehmen, ist das erstmal wieder weg bzw. müsste beim Benutzen erst wieder mit instance_of abgefragt werden, oder? Also wenn Du in Deinem Beispiel in void test() mal versuchst: System.out.println(test == TestEnum.A);? Das geht doch schief, weil test eben nur ITest ist und erst noch gecastet werden müsste, oder?

Also wenn Du in Deinem Beispiel in void test() mal versuchst: System.out.println(test == TestEnum.A);? Das geht doch schief, weil test eben nur ITest ist und erst noch gecastet werden müsste, oder?

Das geht. Das gibt mir ein schönes true.
ich bin jetzt mal einen Schritt weiter gegeangen
public enum TestEnum implements ITest {
    VALUE_1("First Value"),
    VALUE_2("Second Value"),
    VALUE_3("Third Value");

    private final String value;

    private TestEnum(String value) {
        this.value = value;
    }

}

und
    public static void  test (ITest test){
        System.out.println(test);
    }
    public static void main(String[] args) throws IOException {
      test(TestEnum.VALUE_2);
    }

Gibt mir "Second Value".
Damit sollte alles gehen was wir wollen, oder?

stimmt - man braucht ja nur die zugehörige stringrepräsentation. ich war auf dem trichter, dass ich die konstante selbst irgendwie zugreifen muss. sollte also gehen.

Wenn du das Interface jetzt in einer anderen Klasse implementierst die kein String-Enum ist, wird die Logik dahinter natürlich explodieren (bzw die toString Methode keinen gültigen Pfad zurückgibt). Aber das kann man ja catchen.

man könnte im interface die public String toString() aus dem enum vorgeben, d.h. wer das irgendwie anders beim überschreiben/implementieren nutzt, muss zumindest toString() implementieren?
das mit dem gültigen pfad bleibt ein laufzeitproblem, aber da kann man ja ne exception auslösen bzw. hochreichen.

Ich würde mal sagen Konzept steht, jetzt machen :/

Ich würde mal sagen Konzept steht, jetzt machen :/

"engage" (frei nach cpt. picard)

authors: AMatutat cagix

repo: Programmiermethoden/Dungeon


text:
AttentionBlock gives warning of "Grad strides do not match bucket view strides" when using DDP

AttentionBlock gives warning of "Grad strides do not match bucket view strides" when using DistributedDataParallel.
It might be solved if adding .contiguous() inside AttentionBlock.

Sorry. I did not try it. Just saw some solution online saying adding it after .transpose can solve the issue

repo: Project-MONAI/GenerativeModels


text:
Where to find medical segmentation decathlon 10 datasets' scaleintensity range?

This ➡ _ScaleIntensityRanged(keys=["image"], a_min=-87.0, a_max=199.0, b_min=0.0, b_max=1.0, clip=True) is for task07 where to find other 9 dataset intensity range?
train_transforms = Compose(
[
LoadImaged(keys=["image", "label"]),
EnsureChannelFirstd(keys=["image", "label"]),
Orientationd(keys=["image", "label"], axcodes="RAS"),
Spacingd(keys=["image", "label"], pixdim=spacing, mode=("bilinear", "nearest"), align_corners=(True, True)),
CastToTyped(keys=["image"], dtype=(torch.float32)),
ScaleIntensityRanged(keys=["image"], a_min=-87.0, a_max=199.0, b_min=0.0, b_max=1.0, clip=True),
CastToTyped(keys=["image", "label"], dtype=(np.float16, np.uint8)),
CopyItemsd(keys=["label"], times=1, names=["label4crop"]),
Lambdad(
keys=["label4crop"],
func=lambda x: np.concatenate(tuple([ndimage.binary_dilation((x==_k).astype(x.dtype), iterations=48).astype(float) for _k in range(output_classes)]), axis=0),
overwrite=True,
),
EnsureTyped(keys=["image", "label"]),
CastToTyped(keys=["image"], dtype=(torch.float32)),
SpatialPadd(keys=["image", "label", "label4crop"], spatial_size=patch_size, mode=["reflect", "constant", "constant"]),
RandCropByLabelClassesd(
keys=["image", "label"],
label_key="label4crop",
num_classes=output_classes,
ratios=[1,] * output_classes,
spatial_size=patch_size,
num_samples=num_patches_per_image
),
Lambdad(keys=["label4crop"], func=lambda x: 0),
RandRotated(keys=["image", "label"], range_x=0.3, range_y=0.3, range_z=0.3, mode=["bilinear", "nearest"], prob=0.2),
RandZoomd(keys=["image", "label"], min_zoom=0.8, max_zoom=1.2, mode=["trilinear", "nearest"], align_corners=[True, None], prob=0.16),
RandGaussianSmoothd(keys=["image"], sigma_x=(0.5,1.15), sigma_y=(0.5,1.15), sigma_z=(0.5,1.15), prob=0.15),
RandScaleIntensityd(keys=["image"], factors=0.3, prob=0.5),
RandShiftIntensityd(keys=["image"], offsets=0.1, prob=0.5),
RandGaussianNoised(keys=["image"], std=0.01, prob=0.15),
RandFlipd(keys=["image", "label"], spatial_axis=0, prob=0.5),
RandFlipd(keys=["image", "label"], spatial_axis=1, prob=0.5),
RandFlipd(keys=["image", "label"], spatial_axis=2, prob=0.5),
CastToTyped(keys=["image", "label"], dtype=(torch.float32, torch.uint8)),
ToTensord(keys=["image", "label"]),
]
)
val_transforms = Compose(
    [
        LoadImaged(keys=["image", "label"]),
        EnsureChannelFirstd(keys=["image", "label"]),
        Orientationd(keys=["image", "label"], axcodes="RAS"),
        Spacingd(keys=["image", "label"], pixdim=spacing, mode=("bilinear", "nearest"), align_corners=(True, True)),
        CastToTyped(keys=["image"], dtype=(torch.float32)),
        **_ScaleIntensityRanged(keys=["image"], a_min=-87.0, a_max=199.0, b_min=0.0, b_max=1.0, clip=True),_**
        CastToTyped(keys=["image", "label"], dtype=(np.float32, np.uint8)),
        EnsureTyped(keys=["image", "label"]),
        ToTensord(keys=["image", "label"])
    ]
)

I use
analyser = DataAnalyzer(sim_datalist, dataroot)
datastat = analyser.get_all_case_stats()
print(datastat.keys())
pprint(datastat["stats_summary"]["image_stats"])

to get
{channels: {'max': 1,
'mean': 1.0,
'median': 1.0,
'min': 1,
'percentile': [1, 1, 1, 1],
'percentile_00_5': 1,
'percentile_10_0': 1,
'percentile_90_0': 1,
'percentile_99_5': 1,
'stdev': 0.0},
cropped_shape: {'max': [43, 59, 47],
'mean': [35.37692307692308,
49.98076923076923,
35.65384615384615],
'median': [35.0, 50.0, 36.0],
'min': [31, 40, 24],
'percentile': [[31, 40, 26],
[33, 46, 30],
[38, 54, 41],
[41, 58, 45]],
'percentile_00_5': [31, 40, 26],
'percentile_10_0': [33, 46, 30],
'percentile_90_0': [38, 54, 41],
'percentile_99_5': [41, 58, 45],
'stdev': [1.979764494989571,
3.2539348051207666,
4.210264998898141]},
intensity: {'max': 1704295.25,
'mean': 29411.816703869747,
'median': 29634.744104356032,
'min': 0.0,
'percentile_00_5': 1499.0803447980147,
'percentile_10_0': 10888.021187620896,
'percentile_90_0': 46410.96342914288,
'percentile_99_5': 54237.95997103178,
'stdev': 13406.155988869301},
shape: {'max': [43, 59, 47],
'mean': [35.37692307692308, 49.98076923076923, 35.65384615384615],
'median': [35.0, 50.0, 36.0],
'min': [31, 40, 24],
'percentile': [[31, 40, 26], [33, 46, 30], [38, 54, 41], [41, 58, 45]],
'percentile_00_5': [31, 40, 26],
'percentile_10_0': [33, 46, 30],
'percentile_90_0': [38, 54, 41],
'percentile_99_5': [41, 58, 45],
'stdev': [1.979764494989571, 3.2539348051207666, 4.210264998898141]},
spacing: {'max': [1.0, 1.0, 1.0],
'mean': [1.0, 1.0, 1.0],
'median': [1.0, 1.0, 1.0],
'min': [1.0, 1.0, 1.0],
'percentile': [[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]],
'percentile_00_5': [1.0, 1.0, 1.0],
'percentile_10_0': [1.0, 1.0, 1.0],
'percentile_90_0': [1.0, 1.0, 1.0],
'percentile_99_5': [1.0, 1.0, 1.0],
'stdev': [0.0, 0.0, 0.0]}}

intensity: {'max': 1704295.25,
'mean': 29411.816703869747,
'median': 29634.744104356032,
'min': 0.0,

'max': 1704295.25 is too high

Hi @dirtycomputer, you can use DataAnalyzer  to analyze given medical image dataset which can return a json include intensity range.
https://github.com/Project-MONAI/MONAI/blob/9689abf834f004f49ca59c7fe931caf258da0af7/monai/apps/auto3dseg/data_analyzer.py#L57
from monai.apps.auto3dseg.data_analyzer import DataAnalyzer
datalist = {
    "testing": [{"image": "image_003.nii.gz"}],
    "training": [
        {"fold": 0, "image": "image_001.nii.gz", "label": "label_001.nii.gz"},
        {"fold": 0, "image": "image_002.nii.gz", "label": "label_002.nii.gz"},
        {"fold": 1, "image": "image_001.nii.gz", "label": "label_001.nii.gz"},
        {"fold": 1, "image": "image_004.nii.gz", "label": "label_004.nii.gz"},
    ],
}
dataroot = '/datasets' # the directory where you have the image files (nii.gz)
da = DataAnalyzer(datalist, dataroot, output_path=output_yaml)
da.get_all_case_stats()

Hope it can help you!
Thanks!

Hi @dirtycomputer , I am not sure if your question was resolved.
I found a relevant discussion here:
https://github.com/Project-MONAI/MONAI/discussions/2583

Hi @dirtycomputer , I will be closing this issue if there is no other follow-up, and please feel free to reopen it if the issue is still bothering you. Thanks!

authors: KumoLiu dirtycomputer mingxin-zheng

repo: Project-MONAI/tutorials


text:
Patch inference multithread buffer

Description
This PR added a section to modular patch inference notebook to demonstrate the multithread buffer for batch sampling.
Checks

[x] Avoid including large-size files in the PR.
[x] Clean up long text outputs from code cells in the notebook.
[x] For security purposes, please check the contents and remove any sensitive info such as user names and private key.
[x] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the ./figure folder
[x] Notebook runs automatically ./runner.sh -t <path to .ipynb file>

Requires https://github.com/Project-MONAI/MONAI/pull/6139 to be merged first.

Hi @KumoLiu, can you take a look here? Thanks


text:
Reduce col_wrap in ecs-cmip6.ipynb

The ECS notebook currently uses 7 models, and with col_wrap=5, the plots are smaller than they need to be.

Done in #36


text:
panic: runtime error: invalid memory address or nil pointer dereference

run my project after several hours, i get the error,
i think is the func which is "Find" and "Each" , beacuse at first time , i use Each(f func(int, *Selection)) ,i get the error : panic: runtime error: invalid memory address or nil pointer dereference, then i search the question from the internet, i think maybe the problem is ":=", so that  i  correct
-->
func (s *Selection) Each(f func(int, *Selection)) *Selection {
	var i int
	var n *html.Node
	for i, n = range s.Nodes {
		f(i, newSingleSelection(n, s.document))
	}
	return s
}

but after some hours, occured a new problem
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ea0ef]

from
doc,_ := goquery.NewDocument(movie.Url)
text:=doc.Find(".vodInfo").First().Find("span").First().Text()

can you help me?

Hello,
The problem is that you ignore the error. If NewDocument fails, doc is nil
and the call to doc.Find panics.
Martin
On Fri, Mar 16, 2018 at 10:26 qiusunshine notifications@github.com wrote:

run my project after several hours, i get the error,
i think is the func which is "Find" and "Each" , beacuse at first time , i
use Each(f func(int, *Selection)) ,i get the error : panic: runtime error:
invalid memory address or nil pointer dereference, then i search the
question from the internet, i think maybe the problem is ":=", so that i
correct
-->
func (s *Selection) Each(f func(int, *Selection)) *Selection {
var i int
var n *html.Node
for i, n = range s.Nodes {
f(i, newSingleSelection(n, s.document))
}
return s
}
but after some hours, occured a new problem
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ea0ef]
from
doc,_ := goquery.NewDocument(movie.Url)
text:=doc.Find(".vodInfo").First().Find("span").First().Text()
can you help me?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/PuerkitoBio/goquery/issues/245, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAqQoO-UuCQgeTRwF0PLIK73tUdUX8P2ks5te8uNgaJpZM4St4CC
.

sorry, the error occured ad this line
text:=doc.Find(".vodInfo").First().Find("span").First().Text()
not NewDocument

I understand, but it occurs there because the error is not checked
before.
On Fri, Mar 16, 2018 at 11:09 qiusunshine notifications@github.com wrote:

sorry, the error occured ad this line
text:=doc.Find(".vodInfo").First().Find("span").First().Text()
not NewDocument
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/PuerkitoBio/goquery/issues/245#issuecomment-373742987,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAqQoK0oPDA38f4wygPSi755tjCMkLr9ks5te9WigaJpZM4St4CC
.

Ok I'm now on my laptop (was on my phone before), so what I mean is those two lines:
doc,_ := goquery.NewDocument(movie.Url) // here you ignore the error
text:=doc.Find(".vodInfo").First().Find("span").First().Text()

Should be replaced by:
doc, err := goquery.NewDocument(movie.Url)
if err != nil {
   log.Fatal(err) // or whatever, but do not continue using doc - it is nil!
}
text:=doc.Find(".vodInfo").First().Find("span").First().Text() // note that the second call to `First()` is not necessary

Also, if this is for anything more critical than an experiment or a personal project for fun, I strongly advise you make the requestl to the movie.Url using Go's net/http package, and then, once you've validated the results, use goquery.NewDocumentFromReader(response.Body) instead.
Hope this helps,
Martin

i get it.
thanks a lot!

authors: mna qiusunshine

repo: PuerkitoBio/goquery


text:
Proposal for Text(): make  as newlines

It's useful for my project, maybe it will be useful for other users of this lib.

Hello,
I can see how it makes sense to want that behaviour, but I try as much as possible to keep things consistent with jquery behaviour-wise, and text() really just returns the text content of elements, with no special processing regarding tags. If you start inserting newlines for <br>, then what should you do for <p> and, to some extent, for any block-style element. Also, that would be a breaking change in behaviour.
For those reasons, I'm gonna pass on this PR. Thanks for your interest, though, and have fun using the package!
Martin


text:
Add shader generation code to Indigo Plugin

The shader library generation code used in Indigo was recently reused and improved in the roguelike starter kit.
If its generally useful (solves the "define" problem for example) maybe it should be a standard feature of the plugin?

In light of the Ultraviolet work, I won't be doing this,

repo: PurpleKingdomGames/indigo


text:
Coloured text not working on signs

Spark link
https://spark.lucko.me/jo037OD0oA
Expected behavior
When using colour codes on a sign, I would expect the colour of the text to be a colour. For example: “&6Test” would be “Test” in gold.
Observed/Actual behavior
After typing my text and colour code, the sign will update and the text remains the default black.
Steps/models to reproduce
Write on a regular sign (any type): “&6Test”
Purpur version
18.07 01:00:06 [Server] INFO Checking version, please wait...
18.07 01:00:06 [Server] INFO Current: git-Purpur-2016 (MC: 1.20.1)*
18.07 01:00:06 [Server] INFO Previous: git-Purpur-2015 (MC: 1.20.1)
18.07 01:00:06 [Server] INFO * You are running the latest version
Agreements

[X] I am running the latest version of Purpur available from https://purpurmc.org/downloads.
[X] I have searched for and ensured there isn't already an open issue regarding this.
[ ] I ticked all the boxes without actually reading them
[X] My version of Minecraft is supported by Purpur.

Other
All relevant permissions have been used and it has been enabled in the purpur.yml file.

+1 same issue here, same perms etc. Only happened after updating to 1.20.1 from 1.19.4

Maybe someone WHEN it will be fixed?

authors: NoobcoreNetwork itsBeaco kalakituks

repo: PurpurMC/Purpur


text:
Code simulation of rocket

Create sim to calculate the distance of the rocket when launched without dragg based on $\theta$ of the tube and rocket motor power

Created 1 basic pygame sim basicly no use should be found in Main


text:
Return the Last Element in an Array

Before jumping into Pr first comment for assign.
Problem statement : Create a function that accepts an array of numbers and returns the last number in the array.
Probelm Link : https://edabit.com/challenge/4GZcWTiv2GPA9NfcP
Choose one Cateorgy - Very Easy
question category : Array

Before submitting a PR please Check some details.

[ ] fileName formet should be in camelcase
example- returnTheNextNumber.py
[ ]  Choose label for Problem , example- "good first issue", "easy"
[ ]  In file there should be problem statement and link to problem

/* Problem-Task : This program will add two numbers
 * Problem Link : https://edabit.com/challenge/SFzHtm63XT6EYNHWY
*/
int main() {
    int bla;
    return 0;
}

This repository is vaild for HacktoberFest2020
Read before making PR - How to contribute on Github
Good Luck,

I'd like to contribute to this

[ ] Assigning Task to @Yash-g17

Go Ahead, Best of Luck

Assign it to me,I can Do.

repo: Py-Droid/Edabit-Solutions


text:
Add fstring check and error code

Thanks for submitting a PR!
Please make sure to check for the following items:

[x] Add unit tests and integration tests where applicable.
If you've added an error code or changed an error code behavior,
you should probably add or change a test case file under tests/test_cases/ and add
it to the list under tests/test_definitions.py.
If you've added or changed a command line option,
you should probably add or change a test in tests/test_integration.py.
[x] Add a line to the release notes (docs/release_notes.rst) under "Current Development Version".
Make sure to include the PR number after you open and get one.

Please don't get discouraged as it may take a while to get a review.

Bump. @yoseft any updates?

Closing this as it has been inactive for a while. Please feel free to re-open if this is still relevant.

repo: PyCQA/pydocstyle


text:
Oprava velkeho pismena v odkazu?

nelicuje tam to velke pismeno jen mne?

možná bych to dal jako odkaz, ať to je výraznější?

sem to doladila tedy

authors: encukou lspdv


text:
word-count example doesn't compile on manylinux

Repository with code: https://github.com/gukoff/PyO3-manylinux-bug
One can clone it and run a one-liner to reproduce the issue.
Error:
  error: failed to run custom build command for `pyo3 v0.2.5`
  process didn't exit successfully: `/tmp/pip-sHw2jX-build/build/temp.linux-x86_64-2.7/word-count/release/build/pyo3-aea46c0f50a8070f/build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "python script failed with stderr:\n\nTraceback (most recent call last):\n  File \"<string>\", line 1, in ?\nImportError: No module named sysconfig\n"', libcore/result.rs:945:5

Full build log: https://pastebin.com/RRFAMTga
The error does reproduce on Mac/Ubuntu Docker, pyo3 v0.2.4 and older nightly versions of rustc.
And it was working just fine a couple of weeks ago.

@fafhrd91 aren't you by chance familiar with this issue?

looks like a problem with python paths. are you able to build project outside of docker?

Yes, it builds perfectly outside of docker.

are you able to build any c-extension inside docker?

Yep. I managed to compile https://github.com/closeio/ciso8601 using the same build_wheels.sh script. So, the problem is neither in manylinux1 nor in installing rustc via rustup.sh.

I am busy with other projects at the moment, but I’ll try to check this problem

Hi, @gukoff I had a similar problem. The problem was solved by adding a variable PYTHON_SYS_EXECUTABLE. See Look how I did it https://github.com/PushAMP/pamagent/blob/master/build-wheels.sh#L6

Interesting. PYTHON_SYS_EXECUTABLE fixes the problem, but still doesn't make pyo3 compile.
New build log: https://pastebin.com/z4YHBbdq

This problem is now relevant for the latest nightly assemblies. As a temporary solution, you can use the last working build from March 26
rustup toolchain install nightly-2018-03-26
rustup default nightly-2018-03-26

New version is released

authors: fafhrd91 gukoff zaabjuda


text:
newsfragments: remove incorrect fragment

Accidentally left this entry in #2826 after splitting out #2827.

bors r+


text:
PIPS-IPM++ support [DRAFT]

Adds a new pips solver module for writing a model into several blocks that can be read by the PIPS-IPM++ solver interface.
This is a non-functional draft PR to collaboratively improve the code as discussed bilaterally earlier today.
@FabianHofmann

Have a test with the following code
from linopy import Model
import numpy as np
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt
m = Model(chunk="auto")
time = pd.Index(range(100), name="time")
plant = pd.Index(range(40), name="plant")
demand = pd.Series(3 + np.sin(np.pi / 24 * time), index=time)
x = m.add_variables(lower=0, coords=[time, plant], name="x",)
y = m.add_variables(lower=0, coords=[plant], name="y")
capacity = m.add_constraints(y - 1 * x, ">=", 0, name="capacity")
demand = m.add_constraints(x.sum("plant"), "=", demand, name="demand")
ramp = (x - x.shift(time=1)).isel(time=slice(1, None), plant=slice(0, 5))
ramplimit = m.add_constraints(ramp, "<=", 10, name="ramplimit")
co2limit = m.add_constraints((1 * x).sum(), "<=", 50, name="co2limit")
m.add_objective((2 * x).sum() + y.sum())
block_size = 5
blocks = np.repeat(np.arange(1, block_size + 1), len(time) / block_size)
m.blocks = xr.DataArray(blocks, [time])
m.to_block_files("linopy-blocks")

Codecov Report

Merging #4 (89515e6) into master (8ac34d9) will decrease coverage by 12.89%.
The diff coverage is 29.69%.

@@             Coverage Diff             @@
##           master       #4       +/-   ##
===========================================
- Coverage   95.16%   82.27%   -12.90%
===========================================
  Files           9        9
  Lines         910     1117      +207
  Branches      166      203       +37
===========================================
+ Hits          866      919       +53
- Misses         31      182      +151
- Partials       13       16        +3

Impacted Files
Coverage Δ

linopy/io.py
65.64% <9.67%> (-34.36%)
:arrow_down:

linopy/constraints.py
69.93% <27.11%> (-25.68%)
:arrow_down:

linopy/variables.py
76.51% <31.81%> (-22.37%)
:arrow_down:

linopy/solvers.py
85.20% <40.00%> (+0.11%)
:arrow_up:

linopy/model.py
90.11% <46.66%> (-9.01%)
:arrow_down:

linopy/common.py
64.28% <50.00%> (-35.72%)
:arrow_down:

linopy/expressions.py
100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ac34d9...89515e6. Read the comment docs.

authors: FabianHofmann codecov-commenter coroa

repo: PyPSA/linopy


text:
PR #337

trigger Travis CI to run tests for the PR #337

Hello @artificiala! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

In the file pythainlp/tokenize/__init__.py:

Line 187:80: E501 line too long (86 > 79 characters)
Line 228:80: E501 line too long (100 > 79 characters)
Line 234:80: E501 line too long (103 > 79 characters)

In the file pythainlp/tokenize/crfcut.py:

Line 3:80: E501 line too long (98 > 79 characters)
Line 4:80: E501 line too long (125 > 79 characters)
Line 23:1: E302 expected 2 blank lines, found 1
Line 31:80: E501 line too long (92 > 79 characters)
Line 33:80: E501 line too long (89 > 79 characters)
Line 34:80: E501 line too long (81 > 79 characters)
Line 39:80: E501 line too long (84 > 79 characters)
Line 55:80: E501 line too long (102 > 79 characters)
Line 59:80: E501 line too long (94 > 79 characters)

In the file tests/test_tokenize.py:

Line 237:80: E501 line too long (96 > 79 characters)
Line 240:80: E501 line too long (108 > 79 characters)
Line 243:80: E501 line too long (107 > 79 characters)
Line 243:90: E231 missing whitespace after ','
Line 246:80: E501 line too long (91 > 79 characters)
Line 249:73: E231 missing whitespace after ','
Line 249:80: E501 line too long (90 > 79 characters)

repo: PyThaiNLP/pythainlp