R
Railwayā€¢15mo ago
BIGHOUSE OG

Running Python Script on Railway

I have a python script that: - gets that from api - do data analysis - insert into database The code runs continously with a while True: statement. Is it possible to run this code on railway ? How could I do that? Image contains the final part of the code
No description
42 Replies
Percy
Percyā€¢15mo ago
Project ID: eda27a88-d8f4-495f-b917-1fd2269f5764
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
Project ID: eda27a88-d8f4-495f-b917-1fd2269f5764
Brody
Brodyā€¢15mo ago
https://nixpacks.com/docs/providers/python Python is detected if any of the following files are found - main.py - requirements.txt - pyproject.toml - Pipfile so if you have a main.py file it will be ran if you have a requirements.txt/pyproject.toml/Pipfile the dependencies will be installed
Floris
Florisā€¢15mo ago
if you want this ran constantly what brody said just make a requirements.txt with all your dependancies like asyncio and then just make a .toml or a procfile i usually just make proc which since yours isnt a webserver could just go on a worker worker: python main:app i think thats correct not at my pc rn ^
Brody
Brodyā€¢15mo ago
railway.json/toml is the preferred method for new projects
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
omg guys,tks tks for the support It makes sense you guys are awesome
Brody
Brodyā€¢15mo ago
for clarity, if your .py file is main.py, you dont need a procfile or railway.json/toml since railway will automatically run a main.py
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
Only the requirements.txt and pipfile
Brody
Brodyā€¢15mo ago
it was requirements.txt or pyproject.toml or Pipfile you only need one of them, you should only have one of them
Floris
Florisā€¢15mo ago
only main.py and requirements.txt i didnt know u didnt need proc thanks brody ^ you know how a requirements.txt is formatted im sure yeah?
Brody
Brodyā€¢15mo ago
only if your py file is main.py https://nixpacks.com/docs/providers/python#start
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
awesome, i'm really impressed you are not in railway staff brody.
Brody
Brodyā€¢15mo ago
haha thanks
Floris
Florisā€¢15mo ago
dont worry bro imma move mountains to get railway to recruit him get dis man da credit he deserve
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
and morpheus, thanks for your awesome help aswell
Floris
Florisā€¢15mo ago
anytime bro
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
awesome stuff here ā¤ļø
Floris
Florisā€¢15mo ago
python code is my domain so if you need help let me know
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
my regards from brazil thanks!!
Floris
Florisā€¢15mo ago
brazilball
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
tamo junto!
Floris
Florisā€¢15mo ago
whatever he said šŸ™ i read part of it but not all
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
Morpheus, you are a Algo Trader, thats awesome! You guys are helping me build a crypto indicator company. In the future maybe you can access our API to develop some of your strategies
Floris
Florisā€¢15mo ago
we have several public api's accessible top 250 crypto coins on a 1 min interval all fx pairs with realtime all popular cash & future indicies roughly 560 instruments in total
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
I provide indicators like hyblock, glassnode and cryptoquant
Floris
Florisā€¢15mo ago
i dont know any of them we have our own libraries for market structure for example chochs etc
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
Awesome man I really appreciate your work
Floris
Florisā€¢15mo ago
i believe we own the most accurate one wait i show u
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
awesome In a good moment for you, could you send me some resources to start in algo trading?
Floris
Florisā€¢15mo ago
check your dm
Floris
Florisā€¢15mo ago
No description
Floris
Florisā€¢15mo ago
No description
Floris
Florisā€¢15mo ago
these 2 libs are for ms and liq
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
wowww thats awesome! guys, do you think its good to run this code 24h/7 in production?
Floris
Florisā€¢15mo ago
do you need it to run 24/7? railways running costs are incredibly low so it doesnt really matter
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
My code updates a database each 5 minutes, but when its not updating, its sleeping.
Floris
Florisā€¢15mo ago
is there any specific reason you want a 5 min interval into a database? by storing it into a db straight away im assuming you will collect it to use it another time but not in that instance right ?
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
With the database being updated in database, my Dash Plotly application creates a chart using the database data. So I' thought it would be good to always updated the data in db so my user can always check upadted data.
Floris
Florisā€¢15mo ago
Ah !!!! What you can do instead is send a batch get request whenever the user loads the chart, and everytime they batch request you cache that Thats what we do So fetch the equivalent amount as amount of bars that your chart populates obv
BIGHOUSE OG
BIGHOUSE OGOPā€¢15mo ago
That makes sense No need to database here right
Floris
Florisā€¢15mo ago
nope unless you want to cache it to reduce request size if you have more than 1 end user using it but if you arent rate limited, i would just make the requests as candlestick data is not alot
BIGHOUSE OG
BIGHOUSE OGOPā€¢14mo ago
Even tought my db is updating, my chart isnt. I'm using a Dash app with mongodb and redis cache I believe the problem is with dash
Want results from more Discord servers?
Add your server