Getting the url from an incoming request?
There are two Flask services, each running on a different port on localhost. Service A is a routing service that receives commands from a server and routes them to the appropriate instance of the Service B. There will eventually be hundreds of instances of Service B, each in its own docker container, so when it starts up, I want it to let Service A know where it is running.
I've created an endpoint in service A '/register' that accepts a post request, but I can't figure out how to get the host and port number dynamically.
request.remote_addr just gives me '127.0.0.1'
request.environ.get('REMOTE_PORT') returns 60702, which is NOT the port I'm running it on (9999).
Alternatively, is there a way in a Flask app to dynamically retrieve the URL and Port that the app itself is running on? Because then Service B could just put its own url in the request json.
Sorry if I wasn't clear enough, but I'm beating my head against the wall here
/r/flask
https://redd.it/av51ig
There are two Flask services, each running on a different port on localhost. Service A is a routing service that receives commands from a server and routes them to the appropriate instance of the Service B. There will eventually be hundreds of instances of Service B, each in its own docker container, so when it starts up, I want it to let Service A know where it is running.
I've created an endpoint in service A '/register' that accepts a post request, but I can't figure out how to get the host and port number dynamically.
request.remote_addr just gives me '127.0.0.1'
request.environ.get('REMOTE_PORT') returns 60702, which is NOT the port I'm running it on (9999).
Alternatively, is there a way in a Flask app to dynamically retrieve the URL and Port that the app itself is running on? Because then Service B could just put its own url in the request json.
Sorry if I wasn't clear enough, but I'm beating my head against the wall here
/r/flask
https://redd.it/av51ig
reddit
r/flask - Getting the url from an incoming request?
9 votes and 4 comments so far on Reddit
[P] Open source machine learning platform for developers
Hi all,
We recently open sourced the first version of our machine learning platform. My friend and I started getting into machine learning engineering a little over a year ago, and we were frustrated by how hard it was to get a simple machine learning application up and running on cloud infrastructure. We felt like we were spending way too much time configuring data pipelines, managing dependencies, and solving common problems like applying the same data transformations at training and inference time. Our project automates a lot of the underlying infrastructure work to help developers avoid dealing with the same challenges we had to.
We’d love to hear your feedback!
[https://github.com/cortexlabs/cortex](https://github.com/cortexlabs/cortex)
/r/MachineLearning
https://redd.it/av7o14
Hi all,
We recently open sourced the first version of our machine learning platform. My friend and I started getting into machine learning engineering a little over a year ago, and we were frustrated by how hard it was to get a simple machine learning application up and running on cloud infrastructure. We felt like we were spending way too much time configuring data pipelines, managing dependencies, and solving common problems like applying the same data transformations at training and inference time. Our project automates a lot of the underlying infrastructure work to help developers avoid dealing with the same challenges we had to.
We’d love to hear your feedback!
[https://github.com/cortexlabs/cortex](https://github.com/cortexlabs/cortex)
/r/MachineLearning
https://redd.it/av7o14
GitHub
GitHub - cortexlabs/cortex: Production infrastructure for machine learning at scale
Production infrastructure for machine learning at scale - cortexlabs/cortex
Jinja vs Flask Files - Which is best?
I'm still very new to Flask and Jinja.
If I use an API that returns a JSON object that I want to display via render\_template; is it best to pass the entire JSON object to the template and handle it in Jinja, or should I only pass the parts of the JSON object to Jinja.
Or does it not matter? Is there no real benefit to either approach?
/r/flask
https://redd.it/av8lv8
I'm still very new to Flask and Jinja.
If I use an API that returns a JSON object that I want to display via render\_template; is it best to pass the entire JSON object to the template and handle it in Jinja, or should I only pass the parts of the JSON object to Jinja.
Or does it not matter? Is there no real benefit to either approach?
/r/flask
https://redd.it/av8lv8
reddit
r/flask - Jinja vs Flask Files - Which is best?
1 vote and 2 comments so far on Reddit
[P] Decision Tree Regressors for stock price data
Decided to play a bit with scikit-learn and adapted a previous project. Turns out decision tree regressor recalibrated on a rolling basis works pretty well (systematic) out-of-sample (on a return perspective) for stock price data
Suggestions / opinions anyone? Returns about 10%/year during the last 19 years
It's open-source - [https://github.com/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb](https://github.com/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb)
(NBViewer for you mobile users - [https://nbviewer.jupyter.org/github/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb](https://nbviewer.jupyter.org/github/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb))
/r/MachineLearning
https://redd.it/avefa3
Decided to play a bit with scikit-learn and adapted a previous project. Turns out decision tree regressor recalibrated on a rolling basis works pretty well (systematic) out-of-sample (on a return perspective) for stock price data
Suggestions / opinions anyone? Returns about 10%/year during the last 19 years
It's open-source - [https://github.com/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb](https://github.com/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb)
(NBViewer for you mobile users - [https://nbviewer.jupyter.org/github/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb](https://nbviewer.jupyter.org/github/LongOnly/Quantitative-Notebooks/blob/master/DecisionTreeRegression.ipynb))
/r/MachineLearning
https://redd.it/avefa3
GitHub
LongOnly/Quantitative-Notebooks
Educational notebooks on quantitative finance, algorithmic trading, financial modelling and investment strategy - LongOnly/Quantitative-Notebooks
This media is not supported in your browser
VIEW IN TELEGRAM
Django Jet admin interface 2.0 is now compatible with any stack with SQL database
/r/Python
https://redd.it/avgmiq
/r/Python
https://redd.it/avgmiq
Tip on speeding up subqueries
I'm creating a site that works a lot like Reddit in all intents and purposes, and I've gotten my queries pretty well tuned in with prefetch_related and select_related for getting lists of posts and comments. The one thing I can't seem to speed up is setting up a users vote on a post or if he has saved or not ( like on reddits front page, it shows a red arrow if you've already voted).
In my app, I have the field 'user_vote' and 'user_saved' as Serializer method fields. This requires a query for each post (25 paginated) like post.votes.filter(pk=user.id). This brings the response into to the 3 second range.
I've toyed with caching the votes, but this still means the first time loading the page incurs the initial db lookup, and the caching speedup will only work the next time the user loads the same posts or posts (assuming that will even happen).
Any suggestions? Thanks.
/r/django
https://redd.it/avfraz
I'm creating a site that works a lot like Reddit in all intents and purposes, and I've gotten my queries pretty well tuned in with prefetch_related and select_related for getting lists of posts and comments. The one thing I can't seem to speed up is setting up a users vote on a post or if he has saved or not ( like on reddits front page, it shows a red arrow if you've already voted).
In my app, I have the field 'user_vote' and 'user_saved' as Serializer method fields. This requires a query for each post (25 paginated) like post.votes.filter(pk=user.id). This brings the response into to the 3 second range.
I've toyed with caching the votes, but this still means the first time loading the page incurs the initial db lookup, and the caching speedup will only work the next time the user loads the same posts or posts (assuming that will even happen).
Any suggestions? Thanks.
/r/django
https://redd.it/avfraz
reddit
r/django - Tip on speeding up subqueries
2 votes and 4 comments so far on Reddit
How would you convince (higher) management to invest in Python skills in 2019?
hi, i'm tasked to provide a 45 min presentation next week on the subject: **why should our company invest in Python capabilities these days?**
Target audience is senior management of a global technical advisory firm, without any Python skills at all, who need to be convinced to invest time and $$ for upskilling its engineers. I was thinking about presenting some stats and facts of Python adoption rate over the last years and how python is substituting incumbent analytics tools like Matlab. I think, funny / anecdotical facts, pictures or even short videos work best to convey this message.
* What are, in your opinion, the top three arguments to highlight?
* Which resources would recommend to refer to ? Like studies, YouTube video's, slides, pictures....
Appreciate your input!
​
https://i.redd.it/sdgymxa0z2j21.jpg
​
/r/Python
https://redd.it/avbnna
hi, i'm tasked to provide a 45 min presentation next week on the subject: **why should our company invest in Python capabilities these days?**
Target audience is senior management of a global technical advisory firm, without any Python skills at all, who need to be convinced to invest time and $$ for upskilling its engineers. I was thinking about presenting some stats and facts of Python adoption rate over the last years and how python is substituting incumbent analytics tools like Matlab. I think, funny / anecdotical facts, pictures or even short videos work best to convey this message.
* What are, in your opinion, the top three arguments to highlight?
* Which resources would recommend to refer to ? Like studies, YouTube video's, slides, pictures....
Appreciate your input!
​
https://i.redd.it/sdgymxa0z2j21.jpg
​
/r/Python
https://redd.it/avbnna
Most frequently mentioned words in the top 1000 StackOverflow questions tagged #Python [x-post /r/DataArt]
/r/flask
https://redd.it/avh5ri
/r/flask
https://redd.it/avh5ri
[P] PyTorch under the hood
I made available some slides about a presentation from PyData Montreal called **"PyTorch under the hood"**, for those who are interested in knowing more about how PyTorch works, here is the link to the slide deck:
https://speakerdeck.com/perone/pytorch-under-the-hood
/r/MachineLearning
https://redd.it/avfoso
I made available some slides about a presentation from PyData Montreal called **"PyTorch under the hood"**, for those who are interested in knowing more about how PyTorch works, here is the link to the slide deck:
https://speakerdeck.com/perone/pytorch-under-the-hood
/r/MachineLearning
https://redd.it/avfoso
Speaker Deck
PyTorch under the hood
Presentation about PyTorch internals presented at the PyData Montreal in Feb 2019.
Dependent cached properties on-change refresh management via decorators (not yo’ javascript’s promise)
https://github.com/Andrew-Hogan/Promised
/r/Python
https://redd.it/avkwhj
https://github.com/Andrew-Hogan/Promised
/r/Python
https://redd.it/avkwhj
GitHub
Andrew-Hogan/Promised
A flexible cached property with get/set/del/init/cached-mapping capabilities. - Andrew-Hogan/Promised
My first Python turtle race game built on incredible app on android - Pydroid3
/r/Python
https://redd.it/avk9va
/r/Python
https://redd.it/avk9va
Django Book
I posted here a couple months ago regarding a tutorial book in Django. I am getting ready to release it, and want to go through it a few times for accuracy. However, I love the idea of a open sourcing education. So, after I am OK with the release of it, I was thinking about publishing it to a public github and letting people add their two cents as well. Has anybody done something like this? What do you think? Since there wouldn't be a huge amount of content like Wikipedia, I want to know if anyone has done something similar based on single articles/books.
/r/django
https://redd.it/avno12
I posted here a couple months ago regarding a tutorial book in Django. I am getting ready to release it, and want to go through it a few times for accuracy. However, I love the idea of a open sourcing education. So, after I am OK with the release of it, I was thinking about publishing it to a public github and letting people add their two cents as well. Has anybody done something like this? What do you think? Since there wouldn't be a huge amount of content like Wikipedia, I want to know if anyone has done something similar based on single articles/books.
/r/django
https://redd.it/avno12
reddit
r/django - Django Book
0 votes and 2 comments so far on Reddit
First time coding anything other than HTML on my first day at university (Except the cls function)
/r/Python
https://redd.it/avnpue
/r/Python
https://redd.it/avnpue
The purpose of this sub-reddit
*In this post I don't to be somehow rude, and if it sounds like this - it is just because English is my first language.*
​
the description of sub-reddit says: "news about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python"
​
But is the same time, so many times I saw post like "My first project .... ", "my 24h project", "I'm 99 old man, start learning Python, check out my project"... and so one.. Those kind of post gets insane amount of upvotes, which is cool, which means community wants to cheers some how what they done (and It doesn't mean it is very interesting in general)
​
My question is - "Is it relevant to the purpose if the sub-reddit?"
​
I'm not a very active user reddit , I use reddit-app which once per week send me a notification about the most popular in subreddit, too often I see posts about someone pet-project.
​
What do you think? Does it make sense what I said?
​
Thank you, and sorry again for being rude to someones pet-project (I'm founder of couple coding project and understand how it can be hard to hear)
/r/Python
https://redd.it/avpi5h
*In this post I don't to be somehow rude, and if it sounds like this - it is just because English is my first language.*
​
the description of sub-reddit says: "news about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python"
​
But is the same time, so many times I saw post like "My first project .... ", "my 24h project", "I'm 99 old man, start learning Python, check out my project"... and so one.. Those kind of post gets insane amount of upvotes, which is cool, which means community wants to cheers some how what they done (and It doesn't mean it is very interesting in general)
​
My question is - "Is it relevant to the purpose if the sub-reddit?"
​
I'm not a very active user reddit , I use reddit-app which once per week send me a notification about the most popular in subreddit, too often I see posts about someone pet-project.
​
What do you think? Does it make sense what I said?
​
Thank you, and sorry again for being rude to someones pet-project (I'm founder of couple coding project and understand how it can be hard to hear)
/r/Python
https://redd.it/avpi5h
reddit
r/Python - The purpose of this sub-reddit
0 votes and 2 comments so far on Reddit
[P] Implementations of 7 research papers on Deep Seq2Seq learning using Pytorch (Sketch generation, handwriting synthesis, variational autoencoders, machine translation, etc.)
Github repo - [https://github.com/GauravBh1010tt/DL-Seq2Seq](https://github.com/GauravBh1010tt/DL-Seq2Seq)
​
Reproducible Pytorch code on Deep Seq2seq learning for the following papers:
* Sketch Generation - [A Neural Representation of Sketch Drawings](https://openreview.net/pdf?id=Hy6GHpkCW)
* Machine translation - [Effective Approaches to Attention-based Neural Machine Translation](https://arxiv.org/pdf/1508.04025.pdf)
* Handwriting synthesis - [Generating Sequences With Recurrent Neural Networks](https://arxiv.org/pdf/1308.0850.pdf)
* Variational Autoencoders (VAE) - [Auto-Encoding Variational Bayes](https://arxiv.org/pdf/1312.6114.pdf)
* Scheduled Sampling - [Scheduled Sampling for Sequence Prediction with Recurrent Neural Networks](https://arxiv.org/pdf/1506.03099.pdf)
* Conditional VAE - [Learning Structured Output Representation using Deep Conditional Generative Models](https://papers.nips.cc/paper/5775-learning-structured-output-representation-using-deep-conditional-generative-models.pdf)
* Mixture Density Networks - [Mixture Density Networks](https://publications.aston.ac.uk/373/1/NCRG_94_004.pdf)
Let me know if you have any suggestions or comments.
/r/MachineLearning
https://redd.it/avq80b
Github repo - [https://github.com/GauravBh1010tt/DL-Seq2Seq](https://github.com/GauravBh1010tt/DL-Seq2Seq)
​
Reproducible Pytorch code on Deep Seq2seq learning for the following papers:
* Sketch Generation - [A Neural Representation of Sketch Drawings](https://openreview.net/pdf?id=Hy6GHpkCW)
* Machine translation - [Effective Approaches to Attention-based Neural Machine Translation](https://arxiv.org/pdf/1508.04025.pdf)
* Handwriting synthesis - [Generating Sequences With Recurrent Neural Networks](https://arxiv.org/pdf/1308.0850.pdf)
* Variational Autoencoders (VAE) - [Auto-Encoding Variational Bayes](https://arxiv.org/pdf/1312.6114.pdf)
* Scheduled Sampling - [Scheduled Sampling for Sequence Prediction with Recurrent Neural Networks](https://arxiv.org/pdf/1506.03099.pdf)
* Conditional VAE - [Learning Structured Output Representation using Deep Conditional Generative Models](https://papers.nips.cc/paper/5775-learning-structured-output-representation-using-deep-conditional-generative-models.pdf)
* Mixture Density Networks - [Mixture Density Networks](https://publications.aston.ac.uk/373/1/NCRG_94_004.pdf)
Let me know if you have any suggestions or comments.
/r/MachineLearning
https://redd.it/avq80b
GitHub
GauravBh1010tt/DL-Seq2Seq
Implementation of papers on Deep Seq2seq learning using Pytorch. - GauravBh1010tt/DL-Seq2Seq
Blog categories and blog post filtered by request.user.is_staff (need some help guys)
https://www.reddit.com/r/django/comments/aviu7c/i_have_some_problem_description_below/
/r/djangolearning
https://redd.it/avphfg
https://www.reddit.com/r/django/comments/aviu7c/i_have_some_problem_description_below/
/r/djangolearning
https://redd.it/avphfg
reddit
r/django - I have some problem (description below)
0 votes and 3 comments so far on Reddit
Better workflow using django-rest-framework-simplejwt?
It's my first time working with JSON Web Tokens and I'm using this package called [django-rest-framework-simplejwt](https://github.com/davesque/django-rest-framework-simplejwt). My understanding is if I am going to log in I have to redirect to the token endpoint first to get the token and redirect back to the desired view. So this has to be done in front-end. How should I implement the api view if I don't have to get the token from the same endpoint with the log in endpoint?
/r/django
https://redd.it/avs4q3
It's my first time working with JSON Web Tokens and I'm using this package called [django-rest-framework-simplejwt](https://github.com/davesque/django-rest-framework-simplejwt). My understanding is if I am going to log in I have to redirect to the token endpoint first to get the token and redirect back to the desired view. So this has to be done in front-end. How should I implement the api view if I don't have to get the token from the same endpoint with the log in endpoint?
/r/django
https://redd.it/avs4q3
GitHub
GitHub - jazzband/djangorestframework-simplejwt: A JSON Web Token authentication plugin for the Django REST Framework.
A JSON Web Token authentication plugin for the Django REST Framework. - jazzband/djangorestframework-simplejwt
Data passed Across Forms
Hello,
I am currently working with django, specifically form wizard, to create a multi-tier form that can pass data across itself. I have three forms (form 0, form 1, form 2) that I want to pass data to. I want to be able to get the data from form 0 and pass it to form 1, and then pass certain data elements from form 1 to form 2. I have been playing around with the get_form_initial() method and have had no success. What type of implementations have you used before? I am flexible to checking out new tech and ideas as well
Thanks in advance
/r/django
https://redd.it/avtmul
Hello,
I am currently working with django, specifically form wizard, to create a multi-tier form that can pass data across itself. I have three forms (form 0, form 1, form 2) that I want to pass data to. I want to be able to get the data from form 0 and pass it to form 1, and then pass certain data elements from form 1 to form 2. I have been playing around with the get_form_initial() method and have had no success. What type of implementations have you used before? I am flexible to checking out new tech and ideas as well
Thanks in advance
/r/django
https://redd.it/avtmul
reddit
r/django - Data passed Across Forms
0 votes and 1 comment so far on Reddit
Flask Background Task in Celery unable to use URL_FOR() function? Help?
Hey Guys,
Got a Flask app with a Celery background task that runs and an API that my front end calls to get the "Status" of the job. When it finishes I want to pass it the the URL for the output file. However I have an issue. the Celery Background job can't run URL\_FOR to give me a link back to the Downloads folder in Static.
I get the following error:
'Application was not able to create a URL adapter for request' RuntimeError: Application was not able to create a URL adapter for request independent URL generation. You might be able to fix this by setting the SERVER_NAME config variable.
I know that the URL\_FOR function is working with foreground tasks as I don't have any issues with it on other sections of my app. However the celery task seems to have issues. I don't understand how to fix it and I am not quite sure why the application cannot see the SERVER\_NAME configuration.
/r/flask
https://redd.it/avph7p
Hey Guys,
Got a Flask app with a Celery background task that runs and an API that my front end calls to get the "Status" of the job. When it finishes I want to pass it the the URL for the output file. However I have an issue. the Celery Background job can't run URL\_FOR to give me a link back to the Downloads folder in Static.
I get the following error:
'Application was not able to create a URL adapter for request' RuntimeError: Application was not able to create a URL adapter for request independent URL generation. You might be able to fix this by setting the SERVER_NAME config variable.
I know that the URL\_FOR function is working with foreground tasks as I don't have any issues with it on other sections of my app. However the celery task seems to have issues. I don't understand how to fix it and I am not quite sure why the application cannot see the SERVER\_NAME configuration.
/r/flask
https://redd.it/avph7p
reddit
r/flask - Flask Background Task in Celery unable to use URL_FOR() function? Help?
5 votes and 4 comments so far on Reddit