WhereIsAI/github-issue-similarity huggingface dataset:
Issue 1:
How to convert from given Flask to FastAPI:

Will I get better performance doing so in this Kakfa context?

producer.py:

from flask import Flask, request, jsonify
from kafka import KafkaProducer
import json

app = Flask(__name__)
producer = KafkaProducer(bootstrap_servers='kafka:9092')
topic_name = 'messages'

@app.route('/', methods=["POST"])
def send():
app.logger.info("received message")
content = request.get_json()
jd = json.dumps(content).encode('utf-8')
producer.send(topic_name, jd)
app.logger.info("sent message")
return jsonify({"status":"ok"})

if __name__ == '__main__':
app.logger.info('Starting server...')
app.run(host='0.0.0.0', port=8080)

consumer.py:

from kafka import KafkaConsumer

topic_name = 'messages'

if __name__ == '__main__':
print('Starting consumer...')
consumer = KafkaConsumer(topic_name, bootstrap_servers='kafka:9092')

print('receiving messages...')
for message in consumer:
print(f'received message {message}')

print('exiting...')

producer/okteto.yml:

name: producer
labels:
stack.okteto.com/service: producer
command: bash
environment:
- FLASK_DEBUG=1
volumes:
- /root/.cache/pip
sync:
- .:/usr/src/app
forward:
- 8080:8080
reverse:
- 9000:9000
resources:
limits:
cpu: "1"
memory: 2Gi

producer/Dockerfile:

FROM okteto/python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /usr/src/app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY app.py app.py
EXPOSE 8080
CMD ["python", "app.py" ]

consumer/okteto.yml:

name: consumer
labels:
stack.okteto.com/service: consumer
command: bash
volumes:
- /root/.cache/pip
sync:
- .:/usr/src/app
reverse:
- 9000:9000
resources:
limits:
cpu: "1"
memory: 2Gi

consumer/Dockerfile:

FROM okteto/python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /usr/src/app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY app.py app.py
EXPOSE 8080
CMD ["python", "app.py" ]

requirements.txt:

kafka-python

Flask==1.1.1

Issue 2:
After upgrading from 0.55.1 to 0.60.1 all of my endpoints containing an optional trailing slash in the path regex (like "/?") now result in 404 Not Found.

Example to reproduce in 0.60.1:

from fastapi import FastAPI

app = FastAPI()

@app.get("/items/{item_id}/?")
async def read_item(item_id):
return {"item_id": item_id}

Description

In 0.55.1 the above code works fine, allowing the optional trailing slash as expected. In 0.60.1 this behavior is now resulting in 404 Not Found with or without the trailing slash.

Reproduce By:

Open the browser and call the endpoint /items/1/ or /items/1.

It returns 404 Not Found but expected is {"item_id": 1}

Environment

OS: Reproduced on Windows 10 and Ubuntu

FastAPI Version: 0.60.1 (upgraded from 0.55.1)

Python version: 3.6
Issue 1:
[x ] I have searched the issues of this repository and this could be a duplicate of #841.

Current Behavior

Expected Behavior

<Dialog
title='Make transaction'
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
actions={<RemoteSubmitButton handleClose={this.handleClose}/>}
contentStyle={{width: '95%', maxWidth: '1400px'}}
bodyStyle={{maxHeight: '250px', overflowY: 'auto'}}
style={{marginTop: '-200px', paddingTop: '100px'}}>

<div />

</Dialog>

With style attribute of Dialog I want to set the style of the root element.

The marginTop attribute is set but paddingTop is not, instead internal paddingTop is used and cannot be overriden with style={{}}.

I should be able to override the styles of dialog.

Your Environment

Tech
Version

Material-UI
v0.19.4

Issue 2:
Hi Everyone,

I am using horizontal stepper from material UI and integrated in my react app. In all steps i am having different forms and submit button, i need to trigger next button event on form submit button click.

I tried various options but unable to duplicate next event on form submit button.

Example:-

In step 1:
<form>
<input type=text>
.
.
.
<button>submit</button>
</form>

Same type of form in all steps.

(Stepper next button is outside form)

Can anyone help me to resolve the issue ?

Many Thanks in advance..

Regards,

Brajesh
Issue 1:
I would like to propose the addition of another method to reflect.StructTag. The proposed change is very simple, and I'm happy to produce a design document and a PR. I have filed this issue to see if there is any likelihood of this change being accepted.

The reflect.StructTag currently has one method, Get, which makes it easy to extract the value for the associated key from the tag. What it does not do, however, is indicate if the key exists with an empty value.

So in the following example, the Get method will return the same value for the db tag assocated with the Name field as for the db tag associated with the Address field, but there is a difference in the meaning.

struct {
Name string `db:"" json:"-"`
Address string
}

It could be argued that this is a pretty simple function and should not be added to the Go standard library. I am suggesting that it should be added because any third-party implementation requires some duplication of the code for the Get method in the standard library. Duplicating the code from the Go standard library presents at least two challenges:

There is an ongoing maintenance overhead of tracking any future changes to the Go standard library.

The Go BSD license requires distributing the Go copyright notice and conditions with any redistribution of source code. Not a huge deal, but an inconvenience that can be omitted by adding Lookup to the standard libary.

Note also that there was a similar addition in Go 1.5 in the os package, where the LookupEnv function was introduced to complement the GetEnv function.

Proposed New Method

func (StructTag) Lookup

func (tag StructTag) Lookup(key string) (string, bool)

Lookup returns the value associated with key in the tag string. If the key is present in the tag the value (which may be empty) is returned and the boolean is true. Otherwise the returned value will be empty and the boolean is false. If the tag does not have the conventional format, the value returned by Lookup is unspecified.

Issue 2:
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem. Thanks.

What steps will reproduce the problem?
Try the program:

package main

import "fmt"

func f(ch chan int) (n int) {
select {
case n := <-ch:
fmt.Printf("n=%d\n",n)
return
}
panic("x")
}

func main() {
ch := make(chan int)
go func(){
ch <- 5
}()
fmt.Printf("f=%d\n",f(ch))
}

What is the expected output? What do you see instead?

What you MAY expect is (see discussion below):
n=5
f=5

What you see is:
n=5
f=0

What is your $GOOS? $GOARCH?
darwin, amd64

Which revision are you using? (hg identify)
613f36280394+ tip

Please provide any additional information below.

This situation has created sneaky bugs in my programs.
I think that either, the correct behavior should be to
output:
n=5
f=5
Or, when the compiler sees the reassignment of an
existing variable in "case n := <-ch:", it should output
a compiler error, just like it would do if you had
a clause like "n := 4" in the body of f().
Issue 1:
VSCode Version: 0.10.11

OS Version: Windows 7 Professional (x64)

Steps to Reproduce:

Create new file with C++ language

Add the following code:

void fn() {
f(";", value); // Line must begin with at least 1 space.
}

Syntax highlighting for string begins from the second double-comma

This was discovered when trying to view the muse-sequencer's main.cpp (line 137).

This is an odd bug for sure because it's so easy to trigger!

Issue 2:
VSCode Version: 0.10.11

OS Version: Windows 7

Issue 1:

In the following code (using C++ syntax highlighting), the string literal(s) are not highlighted at all.

This issue is exclusive to C++ syntax highlighting and does not occur with C syntax highlighting.

Code:

int main()
{
printf("%s\n", "a string");
}

Result

Issue 2:

In custom tmLanguage based colorizers that reference source.c from within rules that begin with certain patterns, the inlined C highlighting is incorrect (this issue also applies to rules using source.c++ but does not occur in rules using source.js).

Code

(See https://github.com/SE2Dev/VSCode-BugExample)

Result
Issue 1:
Code Sample

df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]})
df = df.stack()
df.loc[0] = [0,0]

This returns

In [27]: df
Out[27]:
0 A 0
B 0
1 A 2
B 5
2 A 3
B 6
dtype: int64

Then, if I try

df.loc[0] = df.loc[1]

I get

In [29]: df
Out[29]:
0 A NaN
B NaN
1 A 2.0
B 5.0
2 A 3.0
B 6.0
dtype: float64

Expected Output

It should either raise an exception/warning, or produce the same result with df.loc[0] = df.loc[1].values.

Issue 2:
Best shown with an example.

import numpy as np, pandas as pd
timestamps = map(pd.Timestamp, ['2014-01-01', '2014-02-01'])
categories = ['A', 'B', 'C', 'D']
df = pd.DataFrame(index=pd.MultiIndex.from_product([timestamps, categories], names=['ts', 'cat']),
columns=['Col1', 'Col2'])

>>> df
Col1 Col2
ts cat
2014-01-01 A NaN NaN
B NaN NaN
C NaN NaN
D NaN NaN
2014-02-01 A NaN NaN
B NaN NaN
C NaN NaN
D NaN NaN

I want to set the values for all categories in a single month. These examples work just fine.

df.loc['2014-01-01', 'Col1'] = 5
df.loc['2014-01-01', 'Col2'] = [1,2,3,4]

>>> df
Col1 Col2
ts cat
2014-01-01 A 5 1
B 5 2
C 5 3
D 5 4
2014-02-01 A NaN NaN
B NaN NaN
C NaN NaN
D NaN NaN

These examples don't work.

df.loc['2014-01-01', 'Col1'] += 1
df.loc['2014-02-01', 'Col2'] = df.loc['2014-01-01', 'Col2']

>>> df
Col1 Col2
ts cat
2014-01-01 A NaN 1
B NaN 2
C NaN 3
D NaN 4
2014-02-01 A NaN NaN
B NaN NaN
C NaN NaN
D NaN NaN

It doesn't seem to be a "setting a value on a copy" issue. Instead, Pandas is writing the NaNs.

My current workaround is to unstack each column into a DataFrame with simple indexes. This works, but I have lots of columns to work with. One dataframe is much easier to work with than a pile of dataframes.

The computations for each month depend on the values computed in the previous month, hence why it can't be done fully vectorized on an entire column.
Issue 1:
import seaborn as sns

This causes:

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py:886: MatplotlibDeprecationWarning:
examples.directory is deprecated; in the future, examples will be found relative to the 'datapath' directory.
"found relative to the 'datapath' directory.".format(key))

python 3.6

Issue 2:
Seaborn triggers following MatplotlibDeprecationWarning examples.directory is deprecated on import.

From what I understand seaborn touches this configuration with matplotlib rcParams, which now triggers a warning.

I don't see any other side-effects yet, it is for not just annoying to see.

Installed versions:

seaborn [required: Any, installed: 0.9.0]

matplotlib [required: >=1.4.3, installed: 3.0.0]

Steps to reproduce:

python
Python 3.7.1 (default, Oct 22 2018, 10:41:28)
[GCC 8.2.1 20180831] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import seaborn
/home/me/.local/share/virtualenvs/QbuZIpeN/lib/python3.7/site-packages/matplotlib/__init__.py:886: MatplotlibDeprecationWarning:
examples.directory is deprecated; in the future, examples will be found relative to the 'datapath' directory.
"found relative to the 'datapath' directory.".format(key))
>>>
Issue 1:
Currently any remote content for the modal dialogs are loaded once upon initialization of the Modal object.

The remote content should instead be loaded in the Modal#show method instead so that the modal contents are always the latest version available on the server.

Issue 2:
I am using the modal dialog on a Grails based application. The first time I click a link (using the <a> tag) my action is fired as I can see in my debugger and I'm able to operate on data. Any link clicked afterwards is no longer 'loading' the URL specified by data-remote so the same dialog from the first attempt is displayed over and over.

I am assuming that this would work correctly in the javascript version. Is there no way for this to work with the data api version?
Issue 1:
I was trying to write a unit test which relied on code that was intended to run during ngOnChanges,

it('should emit an event when the message has changed', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.createAsync(MyComponent, (fixture) =>
var result = fixture.componentInstance.change.first().toPromise().then((change) => {
//expectations
});
fixture.componentInstance.message = 'some message';
fixture.detectChanges();
return result;
});

However this does nothing as the change detector will not detect that the input property has changed, since I'm modifying the value on the child component.

I eventually solved the issue by wrapping the test component in another component as follows:

@ng.Component({
selector: 'my-component-host'
template: '<my-component [message]="message" (change)="onChange.emit($event)"></my-component>
directives: [MyComponent]
})
class MyComponentHost {
message: string;
onChange = new EventEmitter();
}

And then ran the test on the host component instead. However, this is needlessly cumbersome and verbose for what should be a simple unit test.

Would it be possible to add a method like ComponentFixture.bindInput(input: string, toValue: any) which would modify one of the component's input properties so that the change is detected during change detection?

Issue 2:
Our package.json lists many peer dependencies as just dependencies, but should be reflected as peer dependencies:

reflect-metadata

rxjs

zone.js

es6-shim

This is to make sure duplicates don't end up in bundles, and to make sure Angular is sharing the same instances of modules. This is particularly important with RxJS where importing operators has a side effect of monkey-patching the Observable imported from rxjs/Observable.
Issue 1:
🚀 Feature

If a model consists of a DDP submodule, the module cannot be torchscripted since DDP itself cannot be torchscripted.

Motivation

Certain complex models (especially with model parallelism) might consist of submodules where only some of the submodules need to be replicated via DDP. Torchscripting such a complex module would fail since DDP is not torchscriptable. Supporting torchscript for DDP would allow users much more flexibility in how they build and torchscript complex models.

cc @gmagogsfm @pietern @mrshenli @pritamdamania87 @zhaojuanmao @satgera @rohan-varma @gqchen @aazzolini @xush6528 @osalpekar @jiayisuse @agolynski

Issue 2:
🚀 Feature

The torch.distributed package provides PyTorch support and communication primitives for multiprocess parallelism across several computation nodes running on one or more machines. It is the new basis for the DistributedDataParallel wrapper class, which provides a higher-level toolkit for performing synchronous distributed training.

An internal request is that we extend TorchScript to support the torch.distributed package, so that people can use the distributed communication primitives within a TorchScript program.

cc @suo @gmagogsfm
Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

ansible-inventory

ANSIBLE VERSION

ansible 2.4.2.0
config file = /Users/kevin.ashline/code/DevOps/ansible/ansible.cfg
configured module search path = [u'/Users/kevin.ashline/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Cellar/ansible/2.4.2.0_2/libexec/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.10 (default, Jul 15 2017, 17:16:57) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]

CONFIGURATION

DEFAULT_FORCE_HANDLERS(/Users/kevin.ashline/code/DevOps/ansible/ansible.cfg) = True

DEFAULT_STDOUT_CALLBACK(/Users/kevin.ashline/code/DevOps/ansible/ansible.cfg) = debug

HOST_KEY_CHECKING(/Users/kevin.ashline/code/DevOps/ansible/ansible.cfg) = False

RETRY_FILES_SAVE_PATH(/Users/kevin.ashline/code/DevOps/ansible/ansible.cfg) = /Users/kevin.ashline/code/DevOps/ansible/retry_files

OS / ENVIRONMENT

macOS High Sierra

Version 10.13.2

SUMMARY

When attempting to recreate an issue noticed in AWX, I ran:

ansible-inventory --list -i og/hosts

to try to list my inventory file.

I did recreate my issue, however the error message I received actually contained my coworkers CORP account password in clear text:

ERROR! Unexpected Exception, this is probably a bug: Cannot json serialize corp password here

STEPS TO REPRODUCE

Have a .yml in your host file directory which contains a vault encrypted string. Run the above command targeting your inventory file.

Based on my testing it's literally any vault encrypted strings and my coworker was unlucky enough that the first string encountered was his corp password.

ansible-inventory --list -i hosts

EXPECTED RESULTS

list my inventory the way ansible sees it

ACTUAL RESULTS

unsecured coworker

ERROR! Unexpected Exception, this is probably a bug: Cannot json serialize *corp password here*

Issue 2:
If only newline symbol was added/removed, output of --diff mode may be confusing for user:

TASK: [common | install /etc/timezone] ****************************************
--- before: /etc/timezone
+++ after: /tmp/tmpuzXAH7
@@ -1 +1 @@
-Asia/Baghdad
+Asia/Baghdad
changed: [redmine]

This leads to problems like this: #13476 #8443

I think, it would be more convenient and error-prone to explicitly mark newline add/remove in --diff output, like git diff does.
Issue 1:
Symfony version(s) affected: 3.4.12

Description

The values LessThan::TOO_HIGH_ERROR and LessThntOrEqual::TOO_HIGH_ERROR match (whereas GreaterThan::TOO_LOW_ERROR and GreaterThanOrEqual::TOO_LOW_ERROR don't).

I'm not sure which case is supposed to be correct (I suspect the former).

How to reproduce

No reproduction other than to compare the values in the code. ;-)

Possible Solution

Generate a new uuid for one of the Constraints? But what if people have made assumptions about the value being fixed?

Additional context

None

Issue 2:
Q
A

Bug report?
maybe

Feature request?
no

BC Break report?
no

RFC?
no

Symfony version
3.3 or 3.4. and higher

Hello,

we are working with 3.3 or 3.4. and

I am not sure if it is really a problem, but I noticed, that

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/LessThan.php

and

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php

have same TOO_HIGH_ERROR value.

They are only ones from all Constraints like that,

for example https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/GreaterThan.php and https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php have different values for same constant.

Have a nice day!
Issue 1:
Hi, It looks like the way that csr_matrix objects are created by FeatureHasher can result in outputs that explicitly represent a lot of 0s.

FeatureHasher uses the tuple-based initialization for csr_matrix, which will just take 0s and store them rather than trying to filter them out for efficient storage.

I think the simplest way to address this is to call eliminate_zeros() on the matrix before returning it. However, I'm not sure this would be efficient enough for very large datasets. It might be better to construct one row at a time, call eliminate_zeros(), and then stack them or something like that.

m = sp.csr_matrix(([0,1,0,0],[0,1,0,1],[0,2,4]), dtype=int)
print m.nnz
m.eliminate_zeros()
print m.nnz

Issue 2:
Describe the bug

While using sklearn.ensemble.RandomForestClassifier with a custom dictionary specified for class_weight parameter, a ValueError is raised when a key (label) present in class_weight is not found in any of the labels. I got this error while using TimeSeriesSplit. Specifically, if a split is such that training data doesn't have a label specified in class_weight, a ValueError will be raised. This stops users from evaluating their model since class_weight cannot be changed on a go after the model has been created.

Is there any reason this check is being done? There's no error when we don't specify class_weight. The code raising this error can be found here (link).

Steps/Code to Reproduce

from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(class_weight={1:10, 0:1})
rfc.fit([[0, 0, 1], [1, 0, 1]], [0, 0])

Expected Results

No errors raised.

Actual Results

ValueError: Class label 1 not present.

Versions

System:
python: 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)]
executable: c:\python3.9.2\python.exe
machine: Windows-10-10.0.19041-SP0

Python dependencies:
pip: 21.3.1
setuptools: 58.3.0
sklearn: 0.24.1
numpy: 1.21.3
scipy: 1.6.1
Cython: 0.29.24
pandas: 1.2.3
matplotlib: 3.3.4
joblib: 1.0.1
threadpoolctl: 2.1.0

Built with OpenMP: True
Issue 1:
Environment

Windows build number: Microsoft Windows [Version 10.0.18362.239]
Windows Terminal version (if applicable):

Any other software?

Steps to reproduce

Can't scroll

Expected behavior

Can scroll

Actual behavior

Can't scroll

Issue 2:
AppKeyBindingsSerialization::ToJson iterates over actions and serializes down the first key it can find.

Environment

Microsoft Windows [Version 10.0.18947.1000]
Windows Terminal latest store version

Steps to reproduce

Haven't found a pattern yet.

Expected behavior

My shortcuts which I have defined in https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8 should be kept

Actual behavior

My shortcuts for copy (ctrl+insert) and paste (shift+insert) keep on disappearing.
Issue 1:
Challenge Waypoint: Comment your JavaScript Code has an issue.

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/40.0.2214.94 Chrome/40.0.2214.94 Safari/537.36.

Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

//This is a comment.

Issue 2:
in every link from the "basic javascript" section i go(and the later Javascipt lessons, not jQuery lessons or anything else), i have a

TypeError: Object.assign is not a function

two days ago these links worked and i already have completed these lessons but now they're not working. all of them.

i did reset the code

made a hard refresh using the F5 key

deleted localStorage

tried the incognito mode

still i have the same error.

and this error is in my console too.

i tried with my Galaxy Note 4:

in Dolphin browser, i have the error.

but in chrome there is no error!
Issue 1:
The tutorial duplicates many of the examples already present.

For example now there is a color quantization example and a grey-scale quantization example.

Also, there are now three k-means examples.

I'm pretty sure we can get rid of some.

Maybe @jaquesgrobler can have a look?

Issue 2:
A few estimators like Lasso support the warm_start option.

lasso = Lasso(warm_start=True)
scores = []
for alpha in alphas:
lasso.set_params(alpha=alpha)
lasso.fit(X_train, y_train)
scores.append(lasso.score(X_test, y_test))

Due to how GridSearchCV is designed (use of clone, parallelism with n_jobs), setting the warm_start option wouldn't have any effect.

It would be nice to create a grid search object which can benefit from warm-start. n_jobs could still be supported but should be with respect to cross-validation folds.

This would require specifying with respect to what parameters the warm-starting must be done (e.g., alpha in the case of Lasso).