R
Railwayā€¢10mo ago
L

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ā€¢10mo ago
Project ID: eda27a88-d8f4-495f-b917-1fd2269f5764
L
Lā€¢10mo ago
Project ID: eda27a88-d8f4-495f-b917-1fd2269f5764
Brody
Brodyā€¢10mo 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ā€¢10mo 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ā€¢10mo ago
railway.json/toml is the preferred method for new projects
L
Lā€¢10mo ago
omg guys,tks tks for the support It makes sense you guys are awesome
Brody
Brodyā€¢10mo 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
L
Lā€¢10mo ago
Only the requirements.txt and pipfile
Brody
Brodyā€¢10mo 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ā€¢10mo 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ā€¢10mo ago
only if your py file is main.py https://nixpacks.com/docs/providers/python#start
L
Lā€¢10mo ago
awesome, i'm really impressed you are not in railway staff brody.
Brody
Brodyā€¢10mo ago
haha thanks
Floris
Florisā€¢10mo ago
dont worry bro imma move mountains to get railway to recruit him get dis man da credit he deserve
L
Lā€¢10mo ago
and morpheus, thanks for your awesome help aswell
Floris
Florisā€¢10mo ago
anytime bro
L
Lā€¢10mo ago
awesome stuff here ā¤ļø
Floris
Florisā€¢10mo ago
python code is my domain so if you need help let me know
L
Lā€¢10mo ago
my regards from brazil thanks!!
Floris
Florisā€¢10mo ago
brazilball
L
Lā€¢10mo ago
tamo junto!
Floris
Florisā€¢10mo ago
whatever he said šŸ™ i read part of it but not all
L
Lā€¢10mo 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ā€¢10mo 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
L
Lā€¢10mo ago
I provide indicators like hyblock, glassnode and cryptoquant
Floris
Florisā€¢10mo ago
i dont know any of them we have our own libraries for market structure for example chochs etc
L
Lā€¢10mo ago
Awesome man I really appreciate your work
Floris
Florisā€¢10mo ago
i believe we own the most accurate one wait i show u
L
Lā€¢10mo ago
awesome In a good moment for you, could you send me some resources to start in algo trading?
Floris
Florisā€¢10mo ago
check your dm
Floris
Florisā€¢10mo ago
No description
Floris
Florisā€¢10mo ago
No description
Floris
Florisā€¢10mo ago
these 2 libs are for ms and liq
L
Lā€¢10mo ago
wowww thats awesome! guys, do you think its good to run this code 24h/7 in production?
Floris
Florisā€¢10mo ago
do you need it to run 24/7? railways running costs are incredibly low so it doesnt really matter
L
Lā€¢10mo ago
My code updates a database each 5 minutes, but when its not updating, its sleeping.
Floris
Florisā€¢10mo 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 ?
L
Lā€¢10mo 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ā€¢10mo 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
L
Lā€¢10mo ago
That makes sense No need to database here right
Floris
Florisā€¢10mo 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
L
Lā€¢10mo 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