feat(healthchecks) add active and passive health checks

Summary
Adds support for health checks in Kong.
Health checkers can perform active health checks, periodically pinging a configurable upstream URL and checking for the HTTP status code, TCP errors and timeouts, and also passive health checks, checking these same signals on ongoing traffic, allowing for circuit breaker functionality.
Major kudos to @Tieske for his work on lua-resty-dns-client and our joint work on lua-resty-healthcheck (on which this is based), and to @thibaultcha for his reviews while this PR was in the making.
Full changelog

Overhaul of the update flow for ring-balancer objects of upstream entities: instead of checking and updating balancer objects on-demand based on client requests, the module now keeps these objects updated based on CRUD updates of the underlying entities
Attaches a health checker object to each balancer object
Adds the healthchecks configuration field for the upstreams entity
Adds support for active health checks
Adds support for passive health checks
Adds endpoints for manually setting the health status: /upstream/:id/targets/:target/healthy and /upstream/:id/targets/:target/unhealthy
Adds a dependency on lua-resty-healthcheck, which provides the backend functionality for health checks
Bumps the dependency versions for lua-resty-worker-events and lua-resty-worker-events
Adds related unit and integration tests for all functionality listed above

Issues resolved
Fix Kong/kong#112
Fix Kong/kong#154

About to push the following patch to this branch:
diff --git a/kong/core/balancer.lua b/kong/core/balancer.lua
index 664c0e55..d45cc027 100644
--- a/kong/core/balancer.lua
+++ b/kong/core/balancer.lua
@@ -604,7 +604,7 @@ end
 local function init()
   local upstreams, err = get_all_upstreams()
   if not upstreams then
-    log(ERR, "failed loading initial list of upstreams: ", err)
+    log(ngx.STDERR, "failed loading initial list of upstreams: ", err)
     return
   end

@@ -615,7 +615,7 @@ local function init()
     if ok ~= nil then
       oks = oks + 1
     else
-      log(ERR, "error creating balancer for ", name, ": ", err)
+      log(ngx.STDERR, "failed creating balancer for ", name, ": ", err)
       errs = errs + 1
     end
   end
diff --git a/kong/dao/schemas/upstreams.lua b/kong/dao/schemas/upstreams.lua
index de3444e8..cf409850 100644
--- a/kong/dao/schemas/upstreams.lua
+++ b/kong/dao/schemas/upstreams.lua
@@ -41,6 +41,10 @@ local function check_http_statuses(arg)
       return false, "array element is not a number"
     end

+    if math.floor(s) ~= s then
+      return false, "must be an integer"
+    end
+
     -- Accept any three-digit status code,
     -- applying Postel's law in case of nonstandard HTTP codes
     if s < 100 or s > 999 then
diff --git a/spec/01-unit/007-entities_schemas_spec.lua b/spec/01-unit/007-entities_schemas_spec.lua
index ebc9f32a..05881ede 100644
--- a/spec/01-unit/007-entities_schemas_spec.lua
+++ b/spec/01-unit/007-entities_schemas_spec.lua
@@ -763,6 +763,7 @@ describe("Entities Schemas", function()
         {{ active = { healthy = { http_statuses = { -1 }}}}, "status code" },
         {{ active = { healthy = { http_statuses = { 99 }}}}, "status code" },
         {{ active = { healthy = { http_statuses = { 1000 }}}}, "status code" },
+        {{ active = { healthy = { http_statuses = { 111.314 }}}}, "must be an integer" },
         {{ active = { healthy = { successes = 0.5 }}}, "must be an integer" },
         {{ active = { healthy = { successes = 0 }}}, "must be an integer" },
         {{ active = { healthy = { successes = -1 }}}, "an integer between" },

After install the version 0.12, how can I set the upstream to use the active health check?

Kong Community Edition (CE) 0.12 is currently available only in a Release
Candidate form, which means that our documentation site GetKong.org hasn't
yet been updated for CE 0.12 features like health checks.
This pull request https://github.com/Kong/getkong.org/pull/566 includes
documentation of health checks - hopefully that'll suffice until we get
GetKong.org updated.
On Sun, Dec 24, 2017 at 11:34 PM, xiaolongiii<EMAIL_ADDRESS>wrote:

After install the version 0.12, how can I set the upstream to use the
active health check?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Kong/kong/pull/3096#issuecomment-353842414, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAFyuMGDU2SrPSy-973c8ZExD3jb8pwhks5tD1AhgaJpZM4RCwrG
.

I can't work out how to set the array of status for healthchecks.active.healthy.http_statuses.  Could you provide an example curl command?  No matter what i try, i just get "array element is not a number" in response.

Sorted - requires JSON input.  Doesn't seem to work with "key=var" input format.
curl -X PATCH \   http://localhost:8001/upstreams/my.new.upstream \   -H 'content-type: application/json' \   -d '{"healthchecks.active.healthy.http_statuses":[200, 302, 401]}'

@craig-mld Thanks, I have the same problem with you，I try -d "healthchecks.active.healthy.http_statuses[]=200"   "healthchecks.active.healthy.http_statuses=200" , etc , all get wrong messages. -d '{"healthchecks.active.healthy.http_statuses":[200]}'  is  ok


System.FormatException.Unrecognized Guid format

[] iOS
[x] Android
[] UWP
[] tvOS
[] macOS
[] PCL

Version of OS(s) listed above with issue
6.0.1
Version of Library
2.0.3
Expected Behaviour
Getting from scan result object the advertisement data.
Actual Behavior
What I'm getting back:
-objScanResonse
--AdvertisementData
---IsConnectable: System.FormatException.Unrecognized Guid format.
---LocalName: System.FormatException.Unrecognized Guid format.
---ManufacturerData:System.FormatException.Unrecognized Guid format.
..
--Device: {Device: 00000000-0000-0000-0000-d03972c4b51a}
---Rssi: -49
..
Thanks in advance for help.

Please include the advertised service UUIDs of the device

Thats the point. I can't read the AdvertisementData object.
If I do s.th. like:
..
.Scan()
.Subscribe(objScanResponse =>{
foreach (Guid objGuid in objScanResponse.AdvertisementData.ServiceUuids)
{
	 Debug.WriteLine(objGuid.ToString());
}

The Error is then for the Line "objScanResponse.AdvertisementData.ServiceUuids":
System.FormatException has been thrown.
Unrecognized Guid format.

I get that.  Please retrieve them using another app.  I haven't observed this on the devices I have so I need a reproducible sample of some sort.  I do seem to be accounting for the different types of UUIDs that should be seen.

With another App I get:
Raw AD Records:
#1 Flags:
As Array: '[05]'
#2 More 16-bit UUIDs available
As Array: '[03, 18, 02, 18, 04, 18]'
#3 Name (Complete)
As Array: '[xx, xx, xx, xx........]'

I can't see why this is a problem and it is passing my tests.  I have added a way to at least prevent it from throwing an error, but when the condition is detected, I return a "dummy" GUID.
Please try the v3.0 branch and run a scan to see if it alleviates this issue.

I haven't heard back, so I'm going to assume this is closed.


Roles and RolesBinding cannot be visualized when only NS RBACs are available

Describe the bug
In environments where only namespace access is granted to users, lens cannot display Roles and RolesBindings
in a namespace.

Click on '....'
Scroll down to '....'
See error

Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):

Lens Version:
OS: [e.g. OSX]
Installation method (e.g. snap or AppImage in Linux):

Is this that you try and view them and they don't appear or that the sidebar menu item isn't present?

The former - when I click RoleBinding no resource is displayed.
Splitting Role/Rb from ClusterRole/ClusterRB would probably help?

Ah I see, related to #2199

Let's get #2199 addressed and go from there

Is this still an issue? And if it is what version of Lens are you using?

Closing as we have split those dialogs and have made other improvements.


Message:Attachment - No URL styles

Message:Attachment - No URL styles

This update enhances the Message.Attachment component to render a muted
style if a url prop is not provided.

Coverage remained the same at 100.0% when pulling d253a6c0af28a2a17442cc0692617b177f3f599f on message-attachments-no-url into 077c268a08a62ae4a54e65ebc3ee8da7795dc69b on master.


{DJAN-23} Setup external SMTP service

Documentation to accompany https://github.com/caktus/django-project-template/pull/245

This is the easiest way to setup SMTP. Personally I like using the local postfix as a relay. Most of these providers contain docs on how to set up the necessary postfix configuration to do that. Might be worth at least noting that as an option.

Ahh... I've never done that before, but I'll definitely look it up and include it.

Thanks, this is updated. Looks like changes to Margarita would be needed to really support Postfix configuration. I can add a ticket for that, if desired.

:+1:


The chrome extension link doesn't work

Where I can download the extension?
https://chrome.google.com/webstore/detail/awesome-autocomplete-for/djkfdjpoelphhdclfjhnffmnlnoknfnd?hl=uk

hey @vadykoo, the chrome extension has been recently removed from the chromestore because we didn't take the time to update a few new requirements they ask all their extensions to follow.
Until we fix this (not in the near future unfortunately), I would recommend you build the sources and add the extension from the chrome folder it will generate.

@redox ok, thank you


Add .config to Server API (shared mirage config addon)

Mirage configures itself in its constructor. Let's extract this logic to a config method. The constructor will call it with the config that's passed in (let's rename options to config), but exposing this method will allow developers to augment their server's config after construction time. This will enable developers to piece together a Mirage server's config from multiple places, e.g. in-addon config.
Once extracted the .config method should be made idempotent, so it can be called again and again safely.

There's some code that sets initial values (timing, namespace etc). This code should only run if the given variables are undefined.
The db and schema are set up. schema has a public registerModels method that takes a hash of models - this should already be idempotent and can be called again with new models. It also creates the db collection if it doesn't exist. So this shouldn't be too difficult.
The pretender server instance should only be instantiated once
We should probably throw an error if the environment is explicitly changed (i.e. if it was explicitly set to dev in one run but then test the next)
for loadFactories, the factoryMap should augmented (not replaced). Creating a db collection for each factory is a backwards-compatibility thing. db.createCollection should already be idempotent

The rest looks pretty straightforward (e.g. loadConfig should be run each time, etc).

I would love for someone to take this one!

@samselikoff looking

@samselikoff Is this resolved at this point?

Yep thanks. Tracking next step in #899


⚠ Ixtanet SAT has degraded performance

In bd2f37b, Ixtanet SAT ($MEDIA_SAT) experienced degraded performance:

HTTP code: 200
Response time: 20696 ms

Resolved: Ixtanet SAT performance has improved in 3edf539.


[BEAM-4449] Replace project and filter with calc

Do not review. Opening for self-review.

Follow this checklist to help us incorporate your contribution quickly and easily:

[x] Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
[x] If this contribution is large, please file an Apache Individual Contributor License Agreement.

It will help us expedite review of your Pull Request if you tag someone (e.g. @username) to look at it.

R: @apilloud @akedin
I currently have an assertion error that looks similar to one we had before. I took a look at #5318 but didn't figure it out.
java.lang.AssertionError
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.plan.volcano.VolcanoPlanner.changeTraits(VolcanoPlanner.java:546)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.plan.RelOptRule.convert(RelOptRule.java:540)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.rel.rules.CalcRemoveRule.onMatch(CalcRemoveRule.java:65)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:212)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.tools.Programs$5.run(Programs.java:326)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:387)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.Prepare.optimize(Prepare.java:188)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:319)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:781)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
	at org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
	at org.apache.beam.sdk.extensions.sql.impl.JdbcDriverTest.testInternalConnect_boundedTable(JdbcDriverTest.java:107)
        ...

The assertion in question is the one here that asserts all traits simple:
  public RelNode changeTraits(final RelNode rel, RelTraitSet toTraits) {
    assert !rel.getTraitSet().equals(toTraits);
    assert toTraits.allSimple();

    RelSubset rel2 = ensureRegistered(rel, null);
    if (rel2.getTraitSet().equals(toTraits)) {
      return rel2;
    }

    return rel2.set.getOrCreateSubset(rel.getCluster(), toTraits.simplify());
  }

The assertion is happening because we are missing a call to getTraitSet().simplify() somewhere.

Well, with the new environment I managed to break the world :-)

Fixed that. From what I can tell, the trait simplification issue lies entirely within bits we didn't author. The CalcRemoveRule tries to convert to getTraits() of a LogicalCalc node.

Also noting: CalcRemoveRule was not in the rule sets added here. It is a sibling class but something in the JDBC codepath caused it to be added. Browsing the rules that are nearby in that package, it looks like really there are a huge variety and you are intended to use a whole Program.

How do we manage the rulesets that go through JDBC? Adding that particular rule to our rule sets causes the failure to occur in ~50 more places. So at least a quick fix is to not use the rule...

The JDBC path sets up the planner here: https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L520 It doesn't match the non-JDBC path, probably worth fixing.

I think the rule is legit, so I've added it to the non-JDBC path. Now I have plenty of errors to work with.

Execution failed for task ':beam-sdks-java-extensions-sql:compileJava'.

postcommit fails at  org.apache.beam.runners.direct.portable.ReferenceRunnerTest.pipelineExecution

Hmm, yea, I couldn't repro or find the log lines for the error.


Automate versioning

Hello,
This PR aims to (semi) automate the process of versioning by changing version in version.py as opposed to setup.py.
Please review and let me know what you think.
Keep Building,
Nelson

Sure.


Unable to load extension on Ubuntu 16.04

I have a fresh install of Ubuntu 16.04, nginx 1.1, php7-fpm. Added the extension for my distro but php-fpm was unable to load. systemctl status php7.0-fpm.service give me this out put:
php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code)
Docs: man:php-fpm7.0(8)
Process: 1785 ExecStart=/usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf (code=exited, status=127) Main PID: 1785 (code=exited, status=127)
jul 01 08:30:09 : Starting The PHP 7.0 FastCGI Process Manager...
jul 01 08:30:09 : /usr/sbin/php-fpm7.0: symbol lookup error: /usr/lib/php/php_pdo_sqlsrv_7_ts.so: undefined symbol: SQLAllocHandle
jul 01 08:30:09 : php7.0-fpm.service: Main process exited, code=exited, status=127/n/a
jul 01 08:30:09 : Failed to start The PHP 7.0 FastCGI Process Manager.
jul 01 08:30:09 : php7.0-fpm.service: Unit entered failed state.
jul 01 08:30:09 : php7.0-fpm.service: Failed with result 'exit-code'.
getting rid of the extension fix the fpm loading problem, but i need to connect with sqlserver. Any suggestions?

Hello @Angel-Gonzalez Just checking it to make sure you are good to go with this issue as you have closed it. Do you still need any assistance?

@Angel-Gonzalez Glad to hear. Any reason why you had to install the Sybase extension? Did the Microsoft PHP Driver extension on Linux not work for you?

It works partially, i'm getting this error Invalid sql_display_size when i try to fetch the results of some queries, until now i'm unable to fix this error.
query example:
 SELECT  CodigoArticulo,DescripcionArticulo AS LineTitle, DescripcionLinea AS Descripcion,
CabeceraDeGrupoImp AS Tipo,NumGrupoImpresionSH AS Grupo,cast([%Descuento] AS DECIMAL(18,2)) AS Descuento,
cast(UnidadesPedidas AS INT) AS Unidades, cast(Precio AS DECIMAL(18,2)) AS Precio,
GrupoIva, cast([%Iva] AS DECIMAL(18,2)) AS PIva,
cast(ImporteNeto AS DECIMAL(18,2)) AS Importe, cast(TotalIva AS DECIMAL(18,2)) AS Iva
FROM LineasOfertaCliente
WHERE NumeroOferta = ? ORDER BY orden

Sybase also has plenty bugs with nvarchar type, procedures, and others... so i'm trying to fix the sql_display_size error  to use Microsoft PHP Driver extension since it's more stable than Sybase.
Note: The queries works perfect in MS SQL Server manager, also to this pdo extension under windows, wich works out of the box just fine.

I figure out a work around the sql_display_size, the columns type text triggers the error, so i cast a varchar on each column of this type. Here is an example
cast(MyTextColumn as varchar(max))


Method Single::reduce() added

New method is fully covered by tests.
It seemed to me that this method would be suitable for your beautiful repository.
I hope you will agree with me.
Thanks for this great package!

Pull Request Test Coverage Report for Build<PHONE_NUMBER>

3 of 3 (100.0%)  changed or added relevant lines in 1 file are covered.
No unchanged relevant lines lost coverage.
Overall coverage increased (+0.02%) to 99.194%

Totals

Change from base Build<PHONE_NUMBER>:
0.02%

Covered Lines:
123

Relevant Lines:
124

💛  - Coveralls

Hi @Smoren,
Thank you for your interest in IterTools and your kind words.
Up until now, all of the methods are providing functionality to iterate, so the call to a function returns something that itself can be iterated.
Reduce is interesting, because the result is a single value, so the call to the function doesn't return an iterator, but the result of iteration and reduction.
I think it makes sense to create a new namespace class for this, since it is different than current iteration categories. How about a class IterTools\Reduce and the method that you are submitting can be Reduce::toValue(...).
There are other reductions I am considering, such as Reduce::toLength, Reduce::toMin/Max, Reduce::isSorted, Reduce::exactlyN etc., so I think having it's own namespace class is the right place to put this functionality since it is different from other namespaces that provide iteration rather than single values.
Some tips for the unit tests: Structure the tests in the Given/When/Then format using those comments. Take a look at how other tests are formatted. Also, when asserting an expected value, have the result be precomputed. Do not use code in a unit test. We write unit tests to validate our code. We don't want to use code to validate code--we want to use specific answers to validate code. Again, take a look at other tests in this library to see how results are precomputed by hand and fed into assertions as expected answers. Also, try to think of edge/boundary cases: empty list, list of single value, carry not provided, (should carry be required?).
Thanks again for your pull request and introducing some new functionality.
Mark

Thank you for your feedback!
Hope it's done right now.

Method Single::reduce() removed
Class Reduce created with methods:

toValue
toMin
toMax
toCount
toSum
toProduct
toAverage

Tests added for all new methods (coverage 100%).
README.md updated with description of new methods.
Bug fixed in ArrayIteratorFixture at line 50. See comment there.

I think you will need to add a new Reduce test directory to the PHPUnit XML configuration for tests and code coverage to run on the new code. See: https://github.com/markrogoyski/itertools-php/blob/main/tests/phpunit.xml

Done. I'm sorry, I'm used to the codeception, so I didn't figure it out right away.

Hi!
I've optimized method Reduce::toCount() for arrays and Countible instances.
Now this method uses count() function for them, so complexity reduced from O(N) to O(1) if we get array or Countable as input.

Also I've added method Single::eachPair() for iterating pair of elements in collection.
I need this method to implement Reduce::isSorted().

A few more methods added:

Reduce::isSortedDirectly(),
Reduce::isSortedReversely(),
Single::filterUnique().

I hope you think I'm still on the right way :)

@markrogoyski
Hi!
I'm sorry, I've made a lot of commits, so I decided to make a short report so as not to waste a lot of your time.
There will be no more commits to this branch until your comments are received. Ideas for new methods will be worked out separately.

Here are all the methods that have been added:

Reduce::toValue();
Reduce::toMin();
Reduce::toMax();
Reduce::toCount();
Reduce::toSum();
Reduce::toProduct();
Reduce::toAverage();
Reduce::isSortedDirectly();
Reduce::isSortedReversely();
Single::filterUnique();
Single::eachPair().

All methods have been documented (in PHPdoc and README.md) and tested similarly to yours.

During testing, it was necessary to introduce a new fixture — CountableIteratorAggregateFixture, because the Reduce::toCount() method works in a special way with Countable entities (in order to optimize).

A bug was found and fixed in ArrayIteratorFixture::valid().

You used the isset() function there, which led to the premature termination of the iteration process, when the iterable array contained null (if $a[0] === null then isset($a[0]) === false).
I replaced isset() with array_key_exists() to fix this bug.
There is a comment in that method (file ArrayIteratorFixture.php, line 50) that needs to be removed before accepting this pull request.

A couple of questions:

What do you think about renaming: Single::eachPair() to Single::pairs()?
What do you think about renaming: Single::toCount() to Single::toLength()?

I will be very happy about feedback. I hope that my pull request will be accepted and the new methods will be useful to the community.
I am ready for any comments and I will make any necessary changes to the code according to your wishes.
Thank you for your time!

Hi @Smoren,
Thank you for implementing additional methods to fill out the new Reduce iter tools, and thanks for the summary of changes. I will review the code and leave any feedback I have.
One high-level comment. First off, thank you for adding unit tests. For tests that reduce to a boolean, such as the isSorted methods, I think the tests will be easier to follow and allow for simpler data provider methods if the "true" and "false" test cases are separated into separate test methods with their own data providers. Doing this, the data provider is only the values, and the test can simply assertTrue or assertFalse. For example, separate IsSortedDirectlyTest testArray into two test case methods: testArrayTrue and testArrayFalse. No expected parameter would be required as the expectation is always the same and tested directly with the assertTrue/assertFalse methods.
Thanks again for adding additional functionality and following the coding standards.
Mark

@markrogoyski
Hi! Thank you for your feedback!
I've made all the suggested changes. Here is the summary:

Single::eachPair() renamed to Single::pairwise();
Reduce::isSortedDirectly() renamed to Reduce::isSorted();
Reduce::isSortedReversely() renamed to Reduce::isReversed();
Reduce::toCount(): used function is_countable();
Tests refactored with assertTrue() and assertFalse() for Reduce::isSorted() and Reduce::isReverted();
Single::filterUnique() removed;
Tests refactored with assertEqualsWithDelta(): ToAverageTest, ToSumTest, ToProductTest.

Hi @Smoren,
Thanks again for the pull request. I've merged it and will include it in the next release of IterTools.
Thanks again!
Mark

@markrogoyski thank you very much!
I will continue thinking about new methods :)


Failed when use pkgs_to_install argument!

i run a simple examples with no pkgs_to_install argument, it successed!
but i run the same simple examples with pkgs_to_install , i got this error!
BuildError: The command '/bin/sh -c apt-get -y install build-essential && pip install  random' returned a non-zero code: 1
this is my code:
from clipper_admin import ClipperConnection, KubernetesContainerManager
clipper_conn = ClipperConnection(KubernetesContainerManager(useInternalIP=True))
clipper_conn.connect()
clipper_conn.register_application(name="test-1", input_type="doubles", default_output="-1.0", slo_micros=100000)
def feature_sum(xs):
return [str(sum(x)) for x in xs]
from clipper_admin.deployers import python as python_deployer
python_deployer.deploy_python_closure(clipper_conn, name="model-1", version=1, input_type="doubles", func=feature_sum,pkgs_to_install=['random'])
clipper_conn.link_model_to_app(app_name="test-1", model_name="model_1")
when i don't have the pkgs_to_install arguments , it success!
but when i have the pkgs_to_install argument, the error appeared!
not only the "random" package, the other packages also get error!
can anyone give me a suggestion?

I met this problem too, how do you fix it?


Update s3, sdk-core, sqs to 2.20.135

About this PR
📦 Updates

software.amazon.awssdk:s3
software.amazon.awssdk:sdk-core
software.amazon.awssdk:sqs

from 2.20.129 to 2.20.135
Usage
✅ Please merge!
I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
If you'd like to skip this version, you can just close this PR. If you have any feedback, just mention me in the comments below.
Configure Scala Steward for your repository with a .scala-steward.conf file.
Have a fantastic day writing Scala!

⚙ Adjust future updates
Add this to your .scala-steward.conf file to ignore future updates of this dependency:
updates.ignore = [ { groupId = "software.amazon.awssdk" } ]

Or, add this to slow down future updates of this dependency:
dependencyOverrides = [{
  pullRequests = { frequency = "30 days" },
  dependency = { groupId = "software.amazon.awssdk" }
}]

labels: library-update, early-semver-patch, semver-spec-patch, commit-count:1

Superseded by #659.


:memo: Added chat to docs

Added links to chat in all the docs, and added a permanent link to the discord channel

Issues resolved. This is ready for commit. Thanks @nemerle


test

What :computer:

First thing updated with this PR
Second thing updated with this PR
Third thing updated with this PR

Why :hand:

Reason why first thing was added to PR
Reason why second thing was added to PR
Reason why third thing was added to PR

Evidence :camera:
Include screenshots, screen recordings, or console output here demonstrating that your changes work as intended

PR Summary

Lines of Code (LOC) added this PR: +0
New Cumulative LOC Difference: +0
Dependencies added: +0

Total LOC difference is updated with each PR.

PR Summary

Lines of Code (LOC) added this PR: +0
New Cumulative LOC Difference: +0
Dependencies added: +0

Total LOC difference is updated with each PR.

PR Summary

Lines of Code (LOC) added this PR: +0
New Cumulative LOC Difference: +0
Dependencies added: +0

Total LOC difference is updated with each PR.


Add DumpCompactionLog tool and other minor change

This PR adds a DumpCompactionLog tool to parse binary compaction log file.
It also adds some minor change to blob store.

Looks like some tests failing.

Codecov Report

Merging #1617 into master will decrease coverage by 0.03%.
The diff coverage is 53.12%.

@@             Coverage Diff              @@
##             master    #1617      +/-   ##
============================================
- Coverage     73.60%   73.56%   -0.04%
- Complexity     8682     8706      +24
============================================
  Files           611      615       +4
  Lines         47336    47489     +153
  Branches       5984     5994      +10
============================================
+ Hits          34843    34937      +94
- Misses        10698    10755      +57
- Partials       1795     1797       +2

Impacted Files
Coverage Δ
Complexity Δ

...thub/ambry/quota/JSONStringStorageQuotaSource.java
0.00% <0.00%> (ø)
0.00 <0.00> (?)

...java/com/github/ambry/store/DumpCompactionLog.java
0.00% <0.00%> (ø)
0.00 <0.00> (?)

...ain/java/com/github/ambry/store/CompactionLog.java
74.34% <14.89%> (-15.55%)
38.00 <1.00> (+1.00)
:arrow_down:

...github/ambry/quota/HelixStorageUsageRefresher.java
90.41% <90.41%> (ø)
14.00 <14.00> (?)

...va/com/github/ambry/config/StorageQuotaConfig.java
100.00% <100.00%> (ø)
1.00 <1.00> (?)

...rc/main/java/com/github/ambry/store/BlobStore.java
88.15% <100.00%> (+0.01%)
147.00 <0.00> (ø)

...ava/com/github/ambry/store/BlobStoreCompactor.java
89.85% <100.00%> (+0.02%)
121.00 <0.00> (+1.00)

...hub/ambry/protocol/CatchupStatusAdminResponse.java
75.00% <0.00%> (-6.25%)
6.00% <0.00%> (-1.00%)

...java/com/github/ambry/store/CompactionManager.java
89.94% <0.00%> (-2.37%)
27.00% <0.00%> (ø%)

.../com/github/ambry/network/BlockingChannelInfo.java
80.15% <0.00%> (-0.80%)
15.00% <0.00%> (-1.00%)

... and 13 more

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 3572b02...619d573. Read the comment docs.


does not generate files

Hello
I am trying to provide a repo with all interesting Roslyn Source Code Generators examples
I found your very interesting and I have tried to make an example
Unfortunately, it does not generate any files.
Could you see why  ?
The example is at https://github.com/ignatandrei/RSCG_Examples/tree/main/Later_DuckTyping/src/DucKing

Looks like, fail is related to the fact that you split the declarations between multiple projects. I will look at it.

@ignatandrei Seems like I modern C# it is not possible to make it work between multiple projects at the same time. The partial class has to be defined in one assembly, the inheritance will not do a trick because the implicit operator works only for the type where it is declared. So, you can try to define everything in one assembly. In this case, it will definitely work.

Let's suppose I want to make an interface for FileSystem ( defined by Microsoft). I define an interface, IFileSystem. Could I use your nuget for duck typing FileSystem to IFileSystem?

Yes, you can but with some limitations. Here is an example:
[Duckable]
interface IStream
{
    int ReadByte();
}

public class Program
{
    public static void Main()
    {
        var stream = new MemoryStream();
        Do(stream);
    }

    static void Do(DIStream stream)
    {

    }
}

Such source code will work but only within one assembly. This limitation exists because partial classes can't be implemented in different assemblies.
P.S. I fixed a bunch of bugs and published a new NuGet. So, use DuckInterface 0.1.5

I have updated and still does not generate code. I understand ( partially) the idea of same assembly.
Could you look at https://github.com/ignatandrei/RSCG_Examples/tree/main/Later_DuckTyping/src/DucKing and suggest how to modify code that works  ? ( However, I do not want ALL in one project - the console app should be separated from the BL )

@ignatandrei As I said, the duckable interface has to be defined in the same assembly where it is used.
Here is fixed exmplae: https://github.com/byme8/RSCG_Examples/commit/956976180e218698c11c72c8cd94a962af614878

In my example, the BL project is separate from the console project, but the interfaces project has to go away. It is close to the golang mindset I would say. Where the interfaces are defined in the place where you expect to use them. It implies the there would be multiple small interfaces that doing the same thing.

Also, I want to clarify one thing. It is a 'just for fun' project and it has some limitations that just make it impossible to use it in production in current form.

Thanks.

I do agree with you . I will mention , however, here: https://github.com/ignatandrei/RSCG_Examples.
This code is number 39

@ignatandrei If you are looking for stuff that can be used in production you can have a look at https://github.com/byme8/ZeroIoC. It is an IoC container that generates mappings between the interface and implementation at compile-time via SourceGenerator.
Also, I am working on https://github.com/byme8/Apparatus.AOT.Reflection. It is a fast reflection via source generators. it is still in active development, but there is some stuff that you can have a look at.

Thank you very much. I will look at it.


【代码迁移】任务46：Model Conversion via Differentially Private Data-Free Distillation

运行结果截图

 Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.zxlzd seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.You have signed the CLA already but the status is still pending? Let us recheck it.


Add the compatibility with CUDA 11.x and newer versions of cuDNN and TensorRT

I cannot manage AQZ 4.0.0 to work under my RTX 3060 Ti GPU with CUDA 11.2.1, cuDNN 11.2 and TensorRT <IP_ADDRESS>.
I guess AQZ is not compatible with these newer hardware & software.
Could you please add such a compatibility to your AI to make it run under the RTX 30 series GPUs with 3rd generation of Tensor cores?

------------------ 原始邮件 ------------------
发件人:                                                                                "ymgaq/AQ"                                                                                @.>;
发送时间: 2021年3月2日(星期二) 下午5:26
@.>;
@.***>;
主题: [ymgaq/AQ] Add the compatibility with CUDA 11.x and newer versions of cuDNN and TensorRT (#118)
I cannot manage AQZ 4.0.0 to work under my RTX 3060 Ti GPU with CUDA 11.2.1, cuDNN 11.2 and TensorRT <IP_ADDRESS>.
I guess AQZ is not compatible with these newer hardware & software.
Could you please add such a compatibility to your AI to make it run under the RTX 30 series GPUs with 3rd generation of Tensor cores?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Ubuntu 20.04 only supports CUDA 11.x
Perhaps it can be run in a docker.


"unknown" section in generated docs

Search terms
unknown
Expected Behavior
Do not generate "unknown" section.
Actual Behavior
Somewhere between 0.23.x and 0.24.x TypeDoc started generating an "unknown" section in the index containing all types referenced from external modules:

This generates an enormous amount of duplicated type definitions, particularly in monorepos and prevents us from having a canonical documentation URL for a given type.
In our projects we handle cross linking between module API docs with an unknown symbol resolver but this appears to have been broken by the upgrade, now all the unknown symbols are lumped into this "unknown" section?
Is there any way to disable this and go back to the previous behaviour?
Environment

Typedoc version: 0.24.x
TypeScript version: 5.x
Node.js version: 18.x
OS: Mac OS X

Weirdly also if you configure a app.converter.addUnknownSymbolResolver(...) I don't think it gets called for these unknown symbols any more?

Going to need a minimal reproduction for this, certainly looks wrong, but I have no idea what would have caused this. I also do not support old versions of TypeDoc, so unless this is still broken in 0.25, will be a wontfix.

All good I think - looks like this was being caused by typedoc-plugin-missing-exports - everything works as expected without it.


What is this supposed to demo?

I see the ball rolling around in the browser.
I see my own video feed when I run ./webrtc-sendrecv --peer-id <id given in https://webrtc.nirbheek.in/>.

What I expect to see is (1) a program to stream up your own video/audio device or a test source encoded in webRTC, telling where to stream-to (2) a program to pull down the video/audio webRTC source and render it. But seems like I get one tool, webrtc-sendrecv that does both?
Seems to me that webrtc-sendrecv.c implements the

Handshake (proposed in signalling/Protocol.md)
Starts the video capture from device.
Streams it up to the server? Or maybe locally?
Opens a GUI window and I can see my camera feed, with a bit of latency delay.

I am confused why this is one program, I expect two. Also unclear from reading the readme, so I read through the code. It seems like it implements steps 1-4 in one program.

From your blog http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html it seems the goal is to capture video from V4L2, stream it to a webrtc peer, and receive video back from it. So to clarify this issue, I was expecting this to be two separate programs because then I can run it on different machines and under different network conditions to test performance.

It's supposed to demo the use of webrtcbin as akin to the PeerConnection API in that a single PeerConnection can send and receive (possibly) multiple streams.  If you want something different (like different streams, only send, only receive), you have to write your own signalling/implementation.
There are also simple examples in https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/tests/examples/webrtc that do one-way streaming.


Distributions Gallery: Normal

Add these distributions to "see also".

TruncatedNormal
VoMises (because is like a normal but on the circle)
Logistic (because it "looks like a normal" and is sometimes used as a robust alternative)

What about these two? They are related to the normal, but not that close in the "prior-space"

HalfNormal
LogNormal

We could have different sections/boxes instead of only a "see also". For example: "common alternatives", where we list a distribution with a link to the corresponding preliz page and then a single line with the main difference, and "related distributions"/keep the see also, with a more flexible format.


Update version to 1.0.8

Update the recipe to bring it closer to the current standard layout.
This should also fix the bot automatically detecting new updates.

Checklist

[ ] Used a personal fork of the feedstock to propose changes
[ ] Reset the build number to 0 (if the version changed)
[ ] Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
[ ] Ensured the license file is being packaged.

Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.
I do have some suggestions for making it better though...
For recipe:

License is not an SPDX identifier (or a custom LicenseRef) nor an SPDX license expression.

Documentation on acceptable licenses can be found here.

@conda-forge-admin, please rerender

Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.


Fix gocover.io

https://gocover.io/github.com/fclairamb/ftpserverlib
It seems to lack support for IPv6.

This was fixed with #226 .


[Hangouts] Add interactive cards support

Hello,
This adds support for google hangouts interactive cards.
Enjoy

Thanks as always, @ouadie-lahdioui

@ouadie-lahdioui could you make a PR on the botkit-docs repo to include this in the event list, and maybe add a section about using it?

DANG @ouadie-lahdioui, you HAD ALREADY submitted the docs update. You are awesome.


Getting an error while trying to create post with desmjs library.

So basically while going through the desmjs docs, i found that i have to create subspaceId,
creating subspaceId
useEffect(() => {
const initializeClient = async () => {
const mnemonic = ""
const rpcEndpoint = "http://<IP_ADDRESS>:26657";
const gasPrice = GasPrice.fromString("0.025stake");
const signer = await OfflineSignerAdapter.fromMnemonic(SigningMode.DIRECT, mnemonic);
const [account] = await signer.getAccounts();
  console.log("Account fetched:", account);
  if (!account.address.startsWith("desmos")) {
    throw new Error("Invalid account address format");
  }

  setAccount(account);
  const desmosClient = await DesmosClient.connectWithSigner(rpcEndpoint, signer, { gasPrice });

  console.log("DesmosClient initialized", desmosClient);
  console.log("Account data:", account);

  setClient(desmosClient);

  // Attempt to create a subspace
  const createSubspaceMsg: MsgCreateSubspaceEncodeObject = {
    typeUrl: "/desmos.subspaces.v3.MsgCreateSubspace",
    value: MsgCreateSubspace.fromPartial({
      creator: account.address,
      name: "Test Subspace",
      description: "This is a test subspace",
    }),
  };

  console.log("Create subspace message:", createSubspaceMsg);

    const userAddress = account.address
    console.log(userAddress)
  try {
    const subspaceResult = await desmosClient.signAndBroadcast(userAddress, [createSubspaceMsg], "auto");
    console.log("Subspace creation result:", subspaceResult);
    // assertIsDeliverTxSuccess(subspaceResult);

    // // Extract subspace ID from the raw log events
    // const events = subspaceResult.events || [];
    // const subspaceIdEvent = events.find(
    //   (event) =>
    //     event.type === "created_subspace" &&
    //     event.attributes.some((attr) => attr.key === "subspace_id")
    // );

    // if (subspaceIdEvent) {
    //   const subspaceIdAttr = subspaceIdEvent.attributes.find((attr) => attr.key === "subspace_id");
    //   if (subspaceIdAttr) {
    //     setSubspaceId(Long.fromString(subspaceIdAttr.value)); // Convert string to Long type
    //     console.log(`Subspace ID: ${subspaceIdAttr.value}`);
    //   } else {
    //     console.error("Subspace ID attribute not found in event");
    //   }
    // } else {
    //   console.error("Created subspace event not found");
    // }
  } catch (error) {
    console.error("Failed to create subspace:", error);
  }
};

initializeClient();

}, []);
the error i have been getting
VM41549 page.tsx:206 Failed to create subspace: Error: Query failed with (6): rpc error: code = Unknown desc = invalid owner address: invalid address [desmos-labs/desmos/v7/x/subspaces/types/msgs.go:95] With gas wanted: '0' and gas used: '1168' : unknown request
at QueryClient.queryAbci (queryclient.js:118:19)
at async Object.request (utils.js:35:30)
at async Object.simulate (queries.js:50:34)
at async DesmosClient.simulate (signingcosmwasmclient.js:90:29)
at async DesmosClient.signAndBroadcast (desmosclient.js:74:35)
at async initializeClient (VM41549 page.tsx:182:40)
The function below is for creating post
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();
// Ensure client and subspaceId are ready
if (!client || !subspaceId) {
  alert("Client not initialized or subspace not selected");
  return;
}

console.log({client, subspaceId})

try {
  const msg: MsgCreatePostEncodeObject = {
    typeUrl: "/desmos.posts.v3.MsgCreatePost",
    value: MsgCreatePost.fromPartial({
      subspaceId, // Use state variable here
      sectionId: 0,
      text: postText,
      author: account?.address,
      replySettings: ReplySetting.REPLY_SETTING_EVERYONE,
    })
  };

  const result = await client.signAndBroadcast(account?.address || "", [msg], "auto");
  assertIsDeliverTxSuccess(result);

  alert("Post created successfully!");
} catch (error) {
  console.error("Failed to create post:", error);
  alert("Failed to create post. See console for details.");
}

};

Hey, the owner field is missing in your code for MsgCreateSubspace:
const createSubspaceMsg: MsgCreateSubspaceEncodeObject = {
    typeUrl: "/desmos.subspaces.v3.MsgCreateSubspace",
    value: MsgCreateSubspace.fromPartial({
      creator: account.address,
      name: "Test Subspace",
      description: "This is a test subspace",
+    owner: account.address,
    }),
  };

owner: account.address,

@dadamu  thank you very much, i have successfully create post.
it works

owner: account.address,

@dadamu thank you very much, i have successfully create post. it works

since you are here i would like to share this,
trying to connectWallet, after clicking the conectWallet button the qrcode pop-up i scanned it with trust wallet mobile app
i got  this pop-up on my mobile
Dapp uses unSupported version of(1) walletConnect
below is the snippet code
`"use client";
import { useCallback, useEffect, useState } from "react";
import { AppBar, Button, Toolbar, Typography } from "@mui/material";
import { SignerStatus } from "@desmoslabs/desmjs";
import { useDesmosContext } from "../context/desmos";
import { useWalletConnectContext } from "../context/walletconnect";
import useSignerStatus from "../hooks/useSignerStatus";
import { WalletConnectConnector } from "@web3-react/walletconnect-connector";
export default function Header() {
const [address, setAddress] = useState("");
const { connect, disconnect, signer } = useDesmosContext();
const { signClient } = useWalletConnectContext();
const signerStatus = useSignerStatus();
useEffect(() => {
if (signer !== undefined && signerStatus === SignerStatus.Connected) {
signer.getAccounts().then((accounts) => {
setAddress(accounts[0].address);
});
} else {
setAddress("");
}
}, [signer, signerStatus]);
const connectDisabled =
signClient === undefined ||
(signerStatus !== SignerStatus.Connected &&
signerStatus !== SignerStatus.NotConnected);
  // Configure WalletConnect connector

const walletConnect = new WalletConnectConnector({
rpc: { 1: "https://mainnet.infura.io/v3/........" },
bridge: "https://bridge.walletconnect.org",
qrcode: true,
// pollingInterval: 12000,
});
// Function to connect to MetaMask
async function connectWallet() {
try {
// Attempt to activate the WalletConnect connector
await walletConnect.activate();
console.log("Connected to MetaMask");
} catch (error) {
console.error("Failed to connect to MetaMask", error);
}
}`
Thanks

@sundayonah Please use walletconnectv2 please. https://github.com/desmos-labs/desmjs/tree/main/packages/walletconnect-v2

Thanks

I am running desmos node locally, and i have been able to create several posts successfully.
is their way i can display all the posts.
during my research i found this
desmos query posts post [subspace-id] [post-id] [flags]
i run it in terminal, it successfully display the post, how do i do the same UI, so i can see the posts created.
Thanks @dadamu

You can use desmos query posts posts [subspace-id] --limit [total-count]

Thanks @dadamu


Add documentation for Kotlin DSL assignment

We need some documentation in user manual.

Let's mention the new option on https://docs.gradle.org/current/userguide/lazy_configuration.html

We should also mention that enabling the assignment can cause build failures with allWarningsAsErrors, check here:
https://github.com/gradle/gradle/pull/23547#discussion_r1085340416

Merged to release branch.


Create a new pull request by comparing changes

Pull Request Test Coverage Report for Build<PHONE_NUMBER>

2 of 2 (100.0%)  changed or added relevant lines in 1 file are covered.
1 unchanged line in 1 file lost coverage.
Overall coverage increased (+0.06%) to 95.863%

Files with Coverage Reduction
New Missed Lines
%

js/src/modal.js
1
92.58%

Totals

Change from base Build<PHONE_NUMBER>:
0.06%

Covered Lines:
2030

Relevant Lines:
2081

💛  - Coveralls


Sparse tensor input

Hello,
I'm trying to replace the tf.losses.SparseCategoricalCrossentropy with your loss, but i think it doesn't accept sparse inputs.
The model is a simple U-Net segmentation with a softmax end.
Can you point me in the right direction on how to solve this?
Thank you

BinaryFocalLoss is for binary tasks only, whereas tf.losses.SparseCategoricalCrossentropy is for multiclass tasks. They have different assumptions about the structure of the labels and predictions.
If you want to adapt focal loss to the multiclass setting, you can start with something like the following (not tested, and not including features like label smoothing or class weighting):
class SparseCategoricalFocalLoss(tf.keras.losses.Loss):
    def __init__(self, gamma: float, from_logits: bool = False, **kwargs):
        super().__init__(**kwargs)
        self.gamma = gamma
        self.from_logits = from_logits

    def get_config(self):
        config = super().get_config()
        config.update(gamma=self.gamma, from_logits=self.from_logits)
        return config

    def call(self, y_true, y_pred):
        y_pred = tf.convert_to_tensor(y_pred)
        y_true = tf.dtypes.cast(y_true, dtype=tf.dtypes.int32)
        base_loss = tf.keras.backend.sparse_categorical_crossentropy(
            target=y_true, output=y_pred, from_logits=self.from_logits)

        if self.from_logits:
            probs = tf.nn.softmax(y_pred, axis=-1)
        else:
            probs = y_pred
        batch_size = tf.shape(y_true)[0]
        indices = tf.stack([tf.range(batch_size), y_true], axis=1)
        probs = tf.gather_nd(probs, indices)
        focal_modulation = (1 - probs) ** self.gamma

        return focal_modulation * base_loss

This should be interchangeable with tf.keras.losses.SparseCategoricalCrossentropy (up to bugs!). While I didn't test it extensively, it looks like it might work:
>>> # From probabilities (e.g., softmax output)
>>> loss = SparseCategoricalFocalLoss(gamma=2)
>>> y_true = [0, 1, 2]
>>> y_pred = [[0.8, 0.1, 0.1], [0.1, 0.8, 0.1], [0.1, 0.1, 0.8]]
>>> loss(y_true, y_pred)
<tf.Tensor: shape=(), dtype=float32, numpy=0.008925741>
>>> # From logits
>>> loss = SparseCategoricalFocalLoss(gamma=2, from_logits=True)
>>> y_true = [0, 1, 2]
>>> y_pred = [[1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [-1.0, -1.0, 1.0]]
>>> loss(y_true, y_pred)
<tf.Tensor: shape=(), dtype=float32, numpy=0.010869335>

focal_loss.SparseCategoricalFocalLoss is now available. It should work as a replacement for tf.keras.losses.SparseCategoricalCrossentropy.

Thank you. I'll look into it.


Parallel downloads of block lists

Hey! Are you planning to implement parallel loading of block lists?

It's a nice idea but not a priority at the moment. I'm going to leave this issue open to implement it at some point.

Today I had the time to implement this feature in the parallel-downloads branch.
It's experimental, not optimal and probably has bugs. I'll need a few more iterations until I feel comfortable enough to promote it to a stable release.
With the -p option you can set the maximum concurrency, at the moment the default value is 1.

Implemented in v3.3.0.
Happy holidays!