Cannot validate JSON numbers as Decimals with Pydantic 2.0

Initial Checks

[X] I have searched Google & GitHub for similar requests and couldn't find anything
[X] I have read and followed the docs and still think this feature is missing

Description
I have a Pydantic model that includes an arbitrary dict type. This dict might hold financial data, so I have to be extra careful to not lose any precision due to float types. For example, suppose we have the following JSON.
{
     "value": {"decimal": 1.39084209843098430984598453098430}
}

This should serialize into the following:
Model(value={'decimal': Decimal('1.39084209843098430984598453098430')})

This can be achieved in Pydantic 1.0 by using json_dumps, json_loads and the simplejson library.
import pydantic

class Model(pydantic.BaseModel):
    class Config:
        json_dumps = lambda *args, **kwargs: simplejson.dumps(*args, **kwargs, use_decimal=True)
        json_loads = lambda *args, **kwargs: simplejson.loads(*args, **kwargs, use_decimal=True)

    value: dict

However, json_dumps and json_loads are deprecated in Pydantic 2.0. I can't figure out an alternate way to get this to work. I tried using model_validator and field_validator to do this, but both parse the JSON into a dict before I have a chance to do it myself.
import pydantic

class Model(pydantic.BaseModel):
    value: dict

    @pydantic.model_validator(mode="before")
    def validate_model(cls, data):
        print("Validate Model Data:", repr(data))
        return data

    @pydantic.field_validator("value", mode="before")
    def validate_field(cls, data):
        print("Validate Field Data:", repr(data))
        return data

This prints out the following:
Validate Model Data: {'value': {'decimal': 1.3908420984309844}}
Validate Field Data: {'decimal': 1.3908420984309844}

Is there any way to achieve this with the new Pydantic 2.0?
Affected Components

[X] Compatibility between releases
[X] Data validation/parsing
[ ] Data serialization - .model_dump() and .model_dump_json()
[ ] JSON Schema
[ ] Dataclasses
[X] Model Config
[ ] Field Types - adding or changing a particular data type
[ ] Function validation decorator
[ ] Generic Models
[ ] Other Model behaviour - model_construct(), pickling, private attributes, ORM mode
[ ] Plugins and integration with other tools - mypy, FastAPI, python-devtools, Hypothesis, VS Code, PyCharm, etc.

Selected Assignee: @Kludex

I'm not sure this is the best solution but you can try:
from decimal import Decimal
import json
from typing import Union, List, Dict

from typing_extensions import TypeAliasType
import pydantic

FancyJson = TypeAliasType('FancyJson', Union[List['FancyJson'], Dict[str, 'FancyJson'], Decimal, int, str, bool, int, None])

class Model(pydantic.BaseModel):
    value: FancyJson

print(Model.model_validate_json(json.dumps({'value': {'decimal': 1.3908420984309844}})))
#> value={'decimal': Decimal('1.39084209843098438597053245757706463336944580078125')}

This still doesn't solve the problem of loss of precision. I can create a JSON string with arbitrary precision, but when it's loaded into pydantic it's converted into a float before getting converted into a Decimal so precision is lost. I guess this isn't unique to dict types.
import decimal
import pydantic

class Model(pydantic.BaseModel):
    decimal:  decimal.Decimal

number = decimal.Decimal("1.39084209843098430984598453098430")
data = f'{{"decimal": {number}}}'
model = Model.model_validate_json(data)

print(data)
#> value={"decimal": 1.39084209843098430984598453098430}

print(model.decimal)
#> value=1.39084209843098438597053245757706463336944580078125')

print(model.decimal == number)
#> value=False

Yes we fixed the actual issue now 😀

Just tried with the latest 2.1.0 and it still doesn't fix the issue on model validation. Decimal precision is kept on serialization but lost during validation. I can work around this by doing Model.model_validate(simplejson.loads(data, use_decimal=True) instead of Model.model_validate_json(data) but it's just a bit clunky and error prone. It also makes it difficult to integrate models with decimals into fastapi which heavily uses pydantic.
Appreciate all the work you're doing though and understand if performance is more important than being strict about the precision 😄

Can you give an example? We added a test that should be equivalent to the bug report in your first post: https://github.com/pydantic/pydantic/blob/3284a249794efc30ec1935a0095671263a175c4e/tests/test_types.py#L5625-L5633. Did we miss something?

Ahhh I see this is actually less of an issue for me than I thought. It's only an issue for numbers too big to be held in a double (I think 15 digits). Decimals can hold up to 28 digits. Not the end of the world though. It would be nice to have but I'm happy with how things work now :).
from pydantic import TypeAdapter
from decimal import Decimal

ta = TypeAdapter(Decimal)
assert ta.validate_json('1.1234567890123456') == Decimal('1.1234567890123456')

Oh I actually found another difficulty with the current approach. Trailing zeros are lost on validation. This can be an issue if the decimal represents money and they are printed without fixed precision. For example, the following assertion will fail.
from pydantic import TypeAdapter
from decimal import Decimal

ta = TypeAdapter(Decimal)
value = ta.validate_json('1.10')
assert value == "1.10", value
# Traceback (most recent call last):
#   File "example.py", line 6, in <module>
#     assert value == "1.10", value
# AssertionError: 1.1

What about value == Decimal(“1.1”)?

Mhm, that works because Decimal("1.1") == Decimal("1.10") even though str(Decimal("1.1")) != str(Decimal("1.10")). It can be worked around by explicitly setting the decimal places, eg. str(TypeAdapter(Decimal).validate_json('1.10').quantize(Decimal("1.00"))) == "1.10". Wanted to share difficulties I've been having with the migration though.

I'm not sure what you want us to do. That's not a Pydantic problem:
>>> Decimal('1.10') == '1.10'
False

We're basically just calling Decimal(str(<input>)).

@larashores I think this behaves the same in Pydantic v1:
from pydantic import parse_raw_as
from decimal import Decimal

value = parse_raw_as(Decimal, '1.10')
print(value)
#> 1.1

value = parse_raw_as(Decimal, '"1.10"')
print(value)
#> 1.10

In v2, if you pass a JSON string, it does do what I think you want it to:
from pydantic import TypeAdapter
from decimal import Decimal

ta = TypeAdapter(Decimal)
value = ta.validate_json('"1.10"')
assert str(value) == "1.10"

I'll note that in principle we may even be able to get value = ta.validate_json('1.10') to work properly with this by being more sophisticated with our JSON deserialization into a Decimal, but as far as I'm aware that never worked in pydantic v1 and is a non-trivial feature request.
(@davidhewitt for context as I think you were looking at changes to JSON deserialization in the context of Decimal)

Also, @larashores, even though my attempt to reproduce a difference in behavior between v1 and v2 actually convinced me we do the same thing between the two versions, if you can show us an example of code that does behave differently in v1 and v2 (and is better in v1), that would be helpful/a high priority to resolve.


Feature Request: Channel Sample Selection

Currently Visualizer data is only grabbed from the left channel.
This is apparent when playing back a channel test track, for example: http://www.careysound.com/oldsite/downloads/audiofiles/files/Track 1.aiff
It makes sense for performance reasons to not just automatically average data from the left and right channel, but it would be potentially useful to allow users to see which channel is selected and the ability to switch between left, right and both (averaged).
A Visualizer Channel Source setting should be added with options:

Left (Default)
Right
Average

This setting should be visible in the 'Debug' UI as well as any visualizers where it makes sense, such as any that are intended for audio analysis.
A key for cycling channel source mode would also be useful. audio analysis visualizers would display text such as "Channel displayed: Left   | Press Z to cycle"

Resolved with new stereo visualization style in v0.3.1!


Support generated user credentials

http://credhub-api.cfapps.io/#type-user28

Fixed via a8b9d8bd06289e1a862cf1edf1dbb99cfb3e6697


hident requires robot

https://github.com/turbomam/hident

for converting ontologies into subClassOf and label files

I believe hident has been superseded by code in the submission-schema repo that uses OAK instead of ROBOT.


input-group-btn add on gets wrong height for icon, correct height if text value instead.

Im trying to add an input with multiple add ons as shown here. The issue is when I try to use an icon, even just copying the code directly from the docs, the icon is always has the wrong height / padding unless there is some kind of text value inside. To demonstrate, here is the code from the docs I'm using and a screenshot for what gets rendered (className because react):

and for comparison, here is what happens when I add an   inside the button with the icon:

I don't think anything else is affecting the elements because looking in the console, the only styles I see being applied to any of the related elements are bootstrap css and normalize css. Also, this seems to happen when I use any icon whether its glyphicon or font awesome.

Please post a JS Bin or JS Fiddle that demonstrates the problem and doesn't involve React.
Also, what OS and browser are you using?

I could not replicate via JSFiddle, it works as expected there. However, I still get the same result even after making an MVP html file that only sources Bootstrap and Font-Awesome. The full contents of the MVP file are as follows:

and in my browser this is what it renders:

chrome

firefox

safari

Note that this happens whether I use glyphicon or fontawesome, either way the top and bottom margin are always misaligned unless I add some kind of text value such as   on either side of the icon element.
Im running OSX 10.11.3
Also worth noting is that the Bootstrap documentation renders fine in my browsers, and I've used bootstrap in a number of projects before with no issue, so I'm a bit confused where the disconnect is here.

Please post your MVP HTML file as text instead of a screenshot of text.

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">

          <input type="search" class="form-control" placeholder="" aria-controls="DataTables_Table_0">
          <button class="btn btn-default" type="button"></button>

JS Bin of the MVP: http://jsbin.com/hopale/edit?html,output

Hi @cvrebert!
You appear to have posted a live example (http://jsbin.com/hopale/edit), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:

W002:  is missing X-UA-Compatible <meta> tag that disables old IE compatibility modes

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!
(Please note that this is a fully automated comment.)

The Bin renders correctly for me in Safari, Firefox, and Chrome on OS X El Capitan.
Closing as not reproducible.

your are missing the <!DOCTYPE html>
here the JS BIN with the bug :
http://jsbin.com/riledimule/edit?html,output

Hi @guillaumevincent!
You appear to have posted a live example (http://jsbin.com/riledimule/edit), which is always a good first step. However, according to the HTML5 validator, your example has some validation errors, which might potentially be causing your issue:

line 1, column 1 thru column 6: Start tag seen without seeing a doctype first. Expected <!DOCTYPE html>.
line 25, column 3 thru column 9: End tag for  body seen, but there were unclosed elements.
line 9, column 5 thru column 27: Unclosed element div.

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!
(Please note that this is a fully automated comment.)


feat(card): add new datetimepicker to card as option

Closes #2454
Summary

Adds a new option to the Card availableActions that will render the custom range picker

Change List (commits, features, bugs, etc)

feat(Card): allow non-boolean values in the available actions
feat(CardToolbar): add new timepicker if a availableActions.range is of type string and take additional time range options
feat(cardToolbar): smaller font inside cards
feat(CardPropTypes): extend the existing props for timeRange and timeRangeOptions and availableActions.range
fix(TimeSeriesCard): was generating sample values even in the case where we weren't in editable mode

Acceptance Test (how to verify the PR)

Verify new card range picker stories send the action correctly

Regression Test (how to make sure this PR doesn't break old functionality)

Verify old card range picker still works in the story.

Things to look for during review

[ ] Make sure all references to iot or bx class prefix is using the prefix variable
[ ] (React) All major areas have a data-testid attribute. New test ids should have test written to ensure they are not changed or removed.
[ ] UI should be checked in RTL mode to ensure the proper handling of layout and text.
[ ] All strings should be translatable.
[ ] The code should pass a11y scans (The storybook a11y knob should show no violations). New components should have a11y test written.
[ ] Unit test should be written and should have a coverage of 90% or higher in all areas.
[ ] All components should be passing visual regression test. For new styles or components either a visual regression test should be written for all permutations or the base image updated.
[ ] Changes or new components should either write new or update existing documentation.
[ ] PR should link and close out an existing issue

Now that I see the implementation I am remembering that Diana was saying the date needs to be in the subtitle with the icons remaining icon only. From discussion thread in the other PR.
Which would require you to consume the changes from this PR to implement.

#2630 has been created to align this feature with desired spec.


Fix reference to Update (Folder) element

The UpdateFolder operation referenced the Updates (Item) element instead of the Updates (Folder) element.

:white_check_mark: Validation status: passed

File
Status
Preview URL
Details

docs/web-service-reference/updatefolder-operation.md
:white_check_mark:Succeeded

For more details, please refer to the build report.
Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.


Inquiry about the Frontend Technologies Used in Dataset Viewer

Hi team,
I'm currently researching the Dataset Viewer project and would like to understand more about the frontend technologies used. Specifically, I'm interested in knowing:

Which frontend framework is being utilized (e.g., React, Vue, etc.)?
Are there any specific libraries or components being used for UI (e.g., Material-UI, Ant Design)?
Any other notable frontend tools or technologies that are part of this project?

Your assistance in providing these details would be greatly appreciated. Thank you for your time and effort!
Best regards

svelte, and tailwindcss.

svelte, and tailwindcss.

Thank you very much for your prompt and detailed response!


How can I write to disk from a file stream?

I currently handle uploading images with:
filestream.pipe(fs.createWriteStream(filepath));

Which will save to disk.
How do I replace this with sharp? I tried:
var transformer = sharp()
    .rotate()
    .resize(500,500);

var writeToDisk = sharp()
    .toFile(filepath);

filestream.pipe(transformer).pipe(writeToDisk);

But this gives:
_stream_readable.js:476
  dest.on('unpipe', onunpipe);
       ^
TypeError: Object [object Promise] has no method 'on'

Hi, try something like the following to achieve this:
filestream.pipe(transformer).pipe(fs.createWriteStream(filepath));

I wanted to use toFile because this ticket suggested some headaches can be avoided if we let libvps  handle the writing.
https://github.com/lovell/sharp/issues/138
Is this no longer true?

The following is an example of Stream in, file out:
var transformer = sharp()
    .rotate()
    .resize(500,500)
    .toFile(filepath, function(err) {
      // error handling
    });

filestream.pipe(transformer);

Whether filesystem vs Buffer vs Stream is best depends on environmental things such as IO and memory. I recommend you stress/performance test your code and systems to find out which is best for you - good luck!
If you're able to share details publicly, it's always interesting to learn what people are using sharp for over at the survey #35.

Ah okay, maybe I am just pre-optimizing too much. Thanks!


support user specified language only installation

split the dependices into several optional dependencies accroding to which language use it.
now user can install like
pip install langcheck #equals to install [en]
pip install langcheck[en]
pip install langcheck[ja]
pip install langcheck[all]
...

TODOs (added by Kenny):

[ ] Decide on lazy loading or not
[ ] Decide what to do about [optional]
[ ] Decide what to do about optional pytests
[ ] Update installation documentation and README

#88
@kennysong please check if this update align with the requirements and update the GH Action.

It seems we need to refactor init in metrics first.

Okay, I've implemented lazy loading of language-specific packages in langcheck.augment and langcheck.metrics.
Without lazy loading, the user is required to explicitly load each language, such as import langcheck.metrics.ja. Otherwise, they'll see this error which IMO is a bit mysterious:
>>> import langcheck
>>> langcheck.metrics.ja
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'langcheck.metrics' has no attribute 'ja'

With lazy loading, the user will see the exact same behavior as current LangCheck:
>>> import langcheck
>>> langcheck.metrics.ja
<module 'langcheck.metrics.ja' from '/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/__init__.py'>

If the user didn't install Japanese dependencies with pip install langcheck[ja], then they'll see:
>>> import langcheck  # The import error doesn't happen here due to lazy loading!
>>> langcheck.metrics.ja
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 271, in _module_repr
  File "/usr/local/lib/python3.8/importlib/util.py", line 245, in __getattribute__
    self.__spec__.loader.exec_module(self)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/__init__.py", line 1, in <module>
    from langcheck.metrics.ja._tokenizers import JanomeTokenizer, MeCabTokenizer
  File "/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/_tokenizers.py", line 6, in <module>
    from janome.tokenizer import Tokenizer
ModuleNotFoundError: No module named 'janome'

I think this is the best UX, but it also adds some complexity to metrics/__init__.py and augment/__init__.py. I've never used lazy loading before so I don't know if it'll cause unexpected problems.
Also, since this is a non-trivial change, I think we should merge this PR after cutting the 0.5.0 release so we have extra time to test it.
Would appreciate your thoughts @Vela-zz  and @liwii!

Okay, I've implemented lazy loading of language-specific packages in langcheck.augment and langcheck.metrics.
Without lazy loading, the user is required to explicitly load each language, such as import langcheck.metrics.ja. Otherwise, they'll see this error which IMO is a bit mysterious:
>>> import langcheck
>>> langcheck.metrics.ja
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'langcheck.metrics' has no attribute 'ja'

With lazy loading, the user will see the exact same behavior as current LangCheck:
>>> import langcheck
>>> langcheck.metrics.ja
<module 'langcheck.metrics.ja' from '/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/__init__.py'>

If the user didn't install Japanese dependencies with pip install langcheck[ja], then they'll see:
>>> import langcheck  # The import error doesn't happen here due to lazy loading!
>>> langcheck.metrics.ja
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 271, in _module_repr
  File "/usr/local/lib/python3.8/importlib/util.py", line 245, in __getattribute__
    self.__spec__.loader.exec_module(self)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/__init__.py", line 1, in <module>
    from langcheck.metrics.ja._tokenizers import JanomeTokenizer, MeCabTokenizer
  File "/usr/local/lib/python3.8/site-packages/langcheck/metrics/ja/_tokenizers.py", line 6, in <module>
    from janome.tokenizer import Tokenizer
ModuleNotFoundError: No module named 'janome'

I think this is the best UX, but it also adds some complexity to metrics/__init__.py and augment/__init__.py. I've never used lazy loading before so I don't know if it'll cause unexpected problems.
Also, since this is a non-trivial change, I think we should merge this PR after cutting the 0.5.0 release so we have extra time to test it.
Would appreciate your thoughts @Vela-zz and @liwii!

FYI @kennysong  PEP690 and SPEC1 mentioned about lazy loading and the latent risk. I follow the instruction in SPEC1 and apply lazy loading to all attrs under metrics for learning purpose, if we need this features in the future, I can commit changes.

FYI @kennysong SPEC1 mentioned about lazy loading and the latent risk by using lazy_loader library.
I followed the instructions in SPEC1 and change all attrs in metrics into lazy loading mode, but loading time saved is not noticable.

Ah nice find, I hadn't heard of SPEC1 before!
The SPEC1 lazy_loader highlights an important difference with the standard library's LazyLoader (which I used).
The stdlib LazyLoader doesn't import the actual contents of the package, so while langcheck.metrics.ja is visible, langcheck.metrics.ja.factual_consistency() is not visible.
This means that code completion doesn't work:

And more importantly, type checking doesn't work:

Note that type checks do work if you import the full path:

Given this, I think that the current implementation with LazyLoader isn't a good solution. We have two alternatives:

Don't import language-specific packages in langcheck.metrics and langcheck.augment
Use a more sophisticated and complex option like SPEC1's lazy_loader

However, option 2 is fairly complex, not under active development (only 96 stars, last release in July 2023), and IMO beyond our team's current bandwidth to properly understand and maintain.
I think we should proceed with option 1. This will require users to explicitly import the full path like import langcheck.metrics.ja, which is annoying and a breaking change, but I think it's the only reasonable option right now.

FYI @kennysong SPEC1 mentioned about lazy loading and the latent risk by using lazy_loader library.
I followed the instructions in SPEC1 and change all attrs in metrics into lazy loading mode, but loading time saved is not noticable.

Ah nice find, I hadn't heard of SPEC1 before!
The SPEC1 lazy_loader highlights an important difference with the standard library's LazyLoader (which I used).
The stdlib LazyLoader doesn't import the actual contents of the package, so while langcheck.metrics.ja is visible, langcheck.metrics.ja.factual_consistency() is not visible.
This means that code completion doesn't work:

And more importantly, type checking doesn't work:

Note that type checks do work if you import the full path:

Given this, I think that the current implementation with LazyLoader isn't a good solution. We have two alternatives:

Don't import language-specific packages in langcheck.metrics and langcheck.augment
Use a more sophisticated and complex option like SPEC1's lazy_loader

However, option 2 is fairly complex, not under active development (only 96 stars, last release in July 2023), and IMO beyond our team's current bandwidth to properly understand and maintain.
I think we should proceed with option 1. This will require users to explicitly import the full path like import langcheck.metrics.ja, which is annoying and a breaking change, but I think it's the only reasonable option right now.
Let me know what you think!

I upload my experiment (it  can support type checking/ static check). I think through the example below, it can show that the lazy loader used in SPEC1 is quite flexible. they can mix eager import with lazy import, just eager import the ja subpackage but make func under ja package lazy import...so if abused, when times goes on... no one would know which one is lazy import and which one is eager.
so I make a slight change to two options,

Don't import language-specific packages in langcheck.metrics and langcheck.augment
Apply lazy import to all func under language package.

As PEP690  was rejected, it seems python would not have a standard way to do lazy import in recent future.
So, I think option 1 seems more reasonable, it only requires the user import language package explicitly, may influence backward compatibility (would not be a problem as the version is only 0.4.0 ?).

Thanks @Vela-zz! I think this PR is good to go. I was playing around with a bunch of tweaks, and was able to get import langcheck working the same as before by wrapping the language imports in a try/except. This way users don't need to import langcheck.metrics.ja anymore.

@yosukehigashi or @liwii – Since this is a big change, could one of you could test this PR before merging?
The key workflow should look like:
# Open a clean Python environment
docker run -it -v "$(pwd)":/langcheck python:3.8 bash -c "cd /langcheck && bash"

# Install english support
pip install .

# Test LangCheck
python
>>> import langcheck
>>> langcheck.metrics.toxicity()  # Works
>>> langcheck.metrics.en.toxicity()  # Works
>>> langcheck.metrics.ja.toxicity()  # Doesn't work
>>> import langcheck.metrics  # Works
>>> import langcheck.metrics.en  # Works
>>> import langcheck.metrics.ja  # Doesn't work

# Install Japanese support
pip install .[ja]

# Test LangCheck
python
>>> import langcheck
>>> langcheck.metrics.toxicity()  # Works
>>> langcheck.metrics.en.toxicity()  # Works
>>> langcheck.metrics.ja.toxicity()  # Works
>>> import langcheck.metrics  # Works
>>> import langcheck.metrics.en  # Works
>>> import langcheck.metrics.ja  # Works

Also, test in VSCode. Install only one language in a venv. Then make sure that VSCode's static analysis features still work for the entire package.

Thanks @Vela-zz! I think this PR is good to go. I was playing around with a bunch of tweaks, and was able to get import langcheck working the same as before by wrapping the language imports in a try/except. This way users don't need to import langcheck.metrics.ja anymore.

Thanks, learn a lot.

Confirmed that

In a clean docker environment, import langcheck.metrics.ja works if and only if langcheck[ja] is installed
In a venv without langcheck[ja] installed, VSCode extensions properly recognizes the langcheck.metrics.ja module.

Thanks for testing! I'll merge this now. The only test that's failing is because the HanLP server is down and is unrelated.


Feat: added custom paddings

Couple of points after checking out the story:

I don't really like the color choices - imo yellow is good for attention grabbing, but very poor at conveying information
the color theme does not work on light background
You can try using the prefers-color-scheme query or just checking the .light/.dark class the Storybook plugin adds to the body in the story style file to change to text color conditionally


Encapulation

https://github.com/7odaifa-ab/TaskTimer/blob/e07a4754f7a5a77a29de02c941b77642fa2c2f7d/src/main/java/HuimangTech/TimerController.java#L28
Why isn't this field private?

it's Private by Default, I don't really need to write it


[SPARK-47979][SQL][TESTS] Use Hive tables explicitly for Hive table capability tests

What changes were proposed in this pull request?
This PR aims to use Hive tables explicitly for Hive table capability tests in hive and hive-thriftserver module.
Why are the changes needed?
To make Hive test coverage robust by making it independent from Apache Spark configuration changes.
Does this PR introduce any user-facing change?
No, this is a test only change.
How was this patch tested?
Pass the CIs.
Was this patch authored or co-authored using generative AI tooling?
No.

Could you review this PR, @viirya ?

Pending CI

Thank you so much, @viirya !

Merged to master for Apache Spark 4.0.0.

Late +1


Power Automate functions are very complex.

Writing workflows using the data past from one step to the next is not intuitive.  Being too laze to write a page that explains how it works in power automate is just a horrible experience.

Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

ID: 03aa9e88-7fa0-56ab-f794-58f0c37b6d7a
Version Independent ID: 25c5ef5c-6ba4-f5ff-f94b-8f2818ec2feb
Content: Reference guide for expression functions - Azure Logic Apps
Content Source: articles/logic-apps/workflow-definition-language-functions-reference.md
Service: logic-apps
GitHub Login: @ecfan
Microsoft Alias: estfan

Hi @JeffreyWolford,
Thanks for providing feedback. For Power Automate, you can find more info about using outputs from previous steps in the following doc:

Understand the cloud flows designer - Parameters

This doc is just reference guide to the different functions available in Azure Logic Apps and Power Automate.

@JeffreyWolford, if you have more feedback or improvements to suggest for the Power Automate docs, you can use the feedback tool at the bottom of the doc page that I previously included:


Include http headers for the url request

Would it be possible to include http headers to the url request.
Use case: There are some protected websites that cannot be shown because they require the basic authentication header. With this feature, the basic authentication header could be set, and thus enable accessing a password-protected site.

Possibly connected with issue #31

v2.3+ adds support for previewing and interacting with websites during configuration.
Cookies and storage is shared in the context of the screensaver.
It's not exactly as requested, but should allow authentication.
If you wanted to fork and provide your own configuration you could call - loadRequest: on the webView and pass in a request with - setValue:forHTTPHeaderField:.
We aim to keep the project simple and can't see an UX that fits at this time.


Enable declaration of localeTextFunc in gridOptions

It is currently not possible to integrate a translation service with
the ag-grid because the ag-grid assumes a translation table in the
form of a key/value map. A component like the angular-translate
provides a function that will allow a key to be translated but it
does not expose its internal map.
This commit makes it possible to declare a localeTextFunc function
in the gridOptions. When declared, this function will be returned
by the GridOptionsWrapper.getLocaleFunc() method.

makes sense. thanks :)


Create CircuitSecret

Fixes: #13012
This change introduces CircuitSecret as the concept that's used when
doing handshaking between the client and the server, and makes CircuitId
(visible to user-code) a separate concept (not a secret, can't be used
to open a connection).
The scope of this grew once I realized that we probably shouldn't be
logging Circuit Secret in so many places, we should be logging CircuitId
as the piece of data we use for correlation, and try to keep the secret
out of logs except where really necessary (and with trace level).
I ended up creating a new type to represent the secret and prevent
accidental misuse, and then chased down all of the build errors.

Agree with @javiercn on most of these points. Logging circuit secret seems wrong, and it makes intuitive sense if the display name was derived from the secret. Makes it much more malleable to quickly display it, but not useful for any other actual utility. If you think it's worthwhile, we should change CircuitId -> DisplayName. I'm ok leaving it CircuitSecret, it's not user visible and it'll make us be conscious of handling it any time we see it.

Had a discussion with @GrabYourPitchforks today - we're going to do something similar to what we're doing with SignalR. We'll generate 64 bytes of data, and then use the last 32 as the public part. This way we can recover the public part of the ID by unprotecting the data.

About to push an update, I look basically all of the suggestions here.

@javiercn - any feedback?

We talked offline about how circuit ids comparisons work, and it's not clear that there's any advantage to using the id as the basis of comparison (though it's likely safe). I'm going to leave this as-is.


About Evaluation Metrics

Hi, I have tried to run cocoEvalCapDemo.ipynb file for evaluation of COCO images but stuck in this error

Commented all these assertion statements also but not working.

HI @AmnaSaghi, based on your sceenshot, it seems that hypo is not a list. However, I don't think cocoEvalCapDemo.ipynb was used in my codebase. If you are evaluating our model on COCO datasets, please refer to the evaluation instructions in README.

Thanks @YiwuZhong  I have solved this issue.


Add foreground service for Push

More work towards IMAP IDLE support.

I see it's a one man show without feedback if this is the right way.
But I know (and I hope you too) when you know all better, you have to do all alone


Feature: Set output file

@mybuddymichael, @splodingsocks do you think a way to set --output should be a feature of this package?  Right now, we have --output=/dev/null.  If I want to output to a .js file, I will run elm-make in the command line with --output set to the output file.
Cc: @rofrol

@halohalospecial  I also saw this in the source code, but for me linter-elm-make creates dist/elm.js

I do not think it should be a feature. I think this should continue to simply be (more or less) a linter. The fact that we use elm-make behind the scenes is an implementation detail, to my mind, and should remain so. I don't think this package should be an interface to the full compiler.

That's a pitty. Right now I've modfiied linter-elm-make so it outputs to dist/elm.js. I also have browsersync set and I'm compiling always Main.
With that I don't have to set any watchers if for '*.elm', also I don't have to compile project twice.
With simple save I can see linter output and also browser is refreshed with new changes.

Ideally linter should communicate with something like https://github.com/jonathandturner/rls
and should run elm-make by itself, so there is no double compilation.

@rofrol it sounds like you have a pretty neat setup going there, but even so I agree with @mybuddymichael. I think this package should stay a linter, and the fact that the compiler is what's used for linting should stay (as much as possible) and implementation detail.
Just my 2 cents.

@splodingsocks And the reality is you have to compile twice. In ideal world, linter would send compilation request to sth like rls. Since linter runs compiler directly, let people use the fruits of this labor.
elm compiler is slow on big projects, we don't have incremental compilation, we don't have rls. That's what we have.
Like I said I can modify linter locally, but that might not ideal situation if we want to promote Elm as a nice platform for using.

Relevant disscussion:

Part of my wish list would be a protocol editors could use to subscribe to information on builds that were kicked off by other tools.
Right now I have Atom configured to elm-make the current file on save so I can see errors in the editor. I also have Webpack watching my local filesystem for changes, and rebuilding the appropriate Main file as necessary.
This means when I hit save I'm getting two elm-make processes doing the same work. (Also I'm getting elm-format re-running the parsing step in order to preserve e.g. comment positions, but that's out of scope here.)
It would be great if both of those tools could talk to elm develop instead of elm make, so instead of having Atom say "run elm-make on save" it could just subscribe to elm develop for live updates on builds that were kicked off elsewhere (e.g. by webpack).
This would prevent duplicated build effort while still giving me the "recompile on save" experience in my editor. Atom wouldn't actually be requesting new builds on save anymore, but I wouldn't know or care. Whenever I'd save, Webpack would detect the filesystem change, ask elm develop for a rebuild, and then elm develop would tell Atom about the result. It would feel the same as "compile on save" to me as a user, except it would finish in something like half the time it currently does.

https://groups.google.com/d/msg/elm-dev/aDWFBg72Wt4/5Lg_8p21BAAJ

Of course, what Richard says makes sense, but we're a long way from getting there. I think adding an output file option would be a pragmatic solution for now -- Elm compile times are really not the best at the moment, and compiling twice just makes it so much worse.


[BUGFIX] Fix dtype mismatch for NaN check

Description
Fixes https://github.com/dmlc/gluon-nlp/issues/1034
Checklist
Essentials

[x] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
[x] Changes are complete (i.e. I finished coding on this PR)
[ ] All changes have test coverage
[ ] Code is well-documented

Changes

[ ] Feature1, tests, (and when applicable, API doc)
[ ] Feature2, tests, (and when applicable, API doc)

Comments

If this change is a backward incompatible change, why must this change be made.
Interesting edge cases to note here

cc @dmlc/gluon-nlp-team

Job PR-1037/1 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-1037/1/index.html


Add functionality to save progress and load from there.

The score is saved to the backend on each game won.

Fixed.


Please set a license

Hi,
Thanks for sharing your code. Could you please associate a license to it? Without any license, nobody has the right to reuse your code, even for other research.
If you don't know which license to chose, I would suggest MIT which gives the most liberty to people or GPL which ensures the copies of your code will stay free.
Best regards,

Done

Done

Thanks a lot!

Thanks a lot!


[web] cursor blinking with ListView

Cursor blinking when list view scrolling in Crome.
CODE:
import 'package:flutter/rendering.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      padding: const EdgeInsets.all(8),
      scrollDirection: Axis.horizontal,
      children: <Widget>[
        for (num i in Iterable.generate(100, (i) => i))
          Padding(
            padding: const EdgeInsets.all(50),
            child: MouseRegion(
              cursor: SystemMouseCursors.click,
              child: Container(
                height: 100,
                width: 100,
                color: Colors.amber[600],
                child: Center(child: Text('Entry $i')),
              ),
            ),
          ),
      ],
    );
  }
}

ENV:
Crome: 87.0.4280.141, (x86_64)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.25.0-8.2.pre, on Mac OS X 10.15.7 19H15 darwin-x64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.1)
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)

• No issues found!

VIDEO:
https://user-images.githubusercontent.com/14288495/104224034-38b95700-5466-11eb-9953-dea2da6c1248.mov

Issue is reproducible only on beta.
https://user-images.githubusercontent.com/67046386/104291633-c5edc180-54e1-11eb-9b58-73f830029291.mov

beta flutter doctor -v
[✓] Flutter (Channel beta, 1.25.0-8.2.pre, on Mac OS X 10.15.4 19E2269
    darwin-x64, locale en-IN)
    • Flutter version 1.25.0-8.2.pre at /Users/dhs/documents/Fluttersdk/flutter
    • Framework revision b0a2299859 (7 days ago), 2021-01-05 12:34:13 -0800
    • Engine revision 92ae191c17
    • Dart version 2.12.0 (build 2.12.0-133.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (4 available)
    • SM A260G (mobile)                   • 5200763ebcfa861f
      • android-arm    • Android 8.1.0 (API 27)
    • AOSP on IA Emulator (mobile)        • emulator-5556
      • android-x86    • Android 9 (API 28) (emulator)
    • iPhone SE (2nd generation) (mobile) • 6C85835D-FBFD-4AB3-8DE8-B4FAD35E5367
      • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • Chrome (web)                        • chrome
      • web-javascript • Google Chrome 87.0.4280.141

• No issues found!

On latest master, the cursor doesn't blink.
https://user-images.githubusercontent.com/67046386/104291691-d9009180-54e1-11eb-9bad-3f083cbf619a.mov

master flutter doctor -v
[✓] Flutter (Channel master, 1.26.0-2.0.pre.295, on Mac OS X 10.15.4 19E2269
    darwin-x64, locale en-IN)
    • Flutter version 1.26.0-2.0.pre.295 at
      /Users/dhs/documents/Fluttersdk/flutter
    • Framework revision c19fdad097 (6 hours ago), 2021-01-11 22:19:02 -0500
    • Engine revision 0ed964d6b7
    • Dart version 2.12.0 (build 2.12.0-212.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (5 available)
    • SM A260G (mobile)                   • 5200763ebcfa861f
      • android-arm    • Android 8.1.0 (API 27)
    • AOSP on IA Emulator (mobile)        • emulator-5556
      • android-x86    • Android 9 (API 28) (emulator)
    • iPhone SE (2nd generation) (mobile) • 6C85835D-FBFD-4AB3-8DE8-B4FAD35E5367
      • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • macOS (desktop)                     • macos
      • darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)                        • chrome
      • web-javascript • Google Chrome 87.0.4280.141

! Doctor found issues in 1 category.

Issue is reproducible only on beta.
https://user-images.githubusercontent.com/67046386/104291633-c5edc180-54e1-11eb-9b58-73f830029291.mov

beta flutter doctor -v
[✓] Flutter (Channel beta, 1.25.0-8.2.pre, on Mac OS X 10.15.4 19E2269
    darwin-x64, locale en-IN)
    • Flutter version 1.25.0-8.2.pre at /Users/dhs/documents/Fluttersdk/flutter
    • Framework revision b0a2299859 (7 days ago), 2021-01-05 12:34:13 -0800
    • Engine revision 92ae191c17
    • Dart version 2.12.0 (build 2.12.0-133.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (4 available)
    • SM A260G (mobile)                   • 5200763ebcfa861f
      • android-arm    • Android 8.1.0 (API 27)
    • AOSP on IA Emulator (mobile)        • emulator-5556
      • android-x86    • Android 9 (API 28) (emulator)
    • iPhone SE (2nd generation) (mobile) • 6C85835D-FBFD-4AB3-8DE8-B4FAD35E5367
      • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • Chrome (web)                        • chrome
      • web-javascript • Google Chrome 87.0.4280.141

• No issues found!

On latest master, the cursor doesn't blink.
https://user-images.githubusercontent.com/67046386/104291691-d9009180-54e1-11eb-9bad-3f083cbf619a.mov

master flutter doctor -v
[✓] Flutter (Channel master, 1.26.0-2.0.pre.295, on Mac OS X 10.15.4 19E2269
    darwin-x64, locale en-IN)
    • Flutter version 1.26.0-2.0.pre.295 at
      /Users/dhs/documents/Fluttersdk/flutter
    • Framework revision c19fdad097 (6 hours ago), 2021-01-11 22:19:02 -0500
    • Engine revision 0ed964d6b7
    • Dart version 2.12.0 (build 2.12.0-212.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (5 available)
    • SM A260G (mobile)                   • 5200763ebcfa861f
      • android-arm    • Android 8.1.0 (API 27)
    • AOSP on IA Emulator (mobile)        • emulator-5556
      • android-x86    • Android 9 (API 28) (emulator)
    • iPhone SE (2nd generation) (mobile) • 6C85835D-FBFD-4AB3-8DE8-B4FAD35E5367
      • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • macOS (desktop)                     • macos
      • darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)                        • chrome
      • web-javascript • Google Chrome 87.0.4280.141

! Doctor found issues in 1 category.

Sounds like this is fixed.

Sounds like this is fixed.