#πŸ”’ Uvicorn does not update after file change?

58 messages Β· Page 1 of 1 (latest)

atomic sedge
#

Hey, I'm getting an error for unexpected indent. However, when I change the file, like removing all contents and saving, I still get the same error for the same line of code (which shouldnt exists)

Alright, so from the beginning... this is the error:

 File "/home/ubuntu/innova/backend/app/main.py", line 121, in <module>
   from app.api.v1.endpoints import auth, users, roles, permissions, admin, blog, shortcuts, page, market_guard
 File "/home/ubuntu/innova/backend/app/api/v1/endpoints/auth.py", line 7, in <module>
   from app.api import deps
 File "/home/ubuntu/innova/backend/app/api/deps.py", line 9, in <module>
   from app.setup.config import settings
 File "/home/ubuntu/innova/backend/app/setup/config.py", line 30
   DB_HOST: str = os.getenv("DB_HOST")
IndentationError: unexpected indent```

I ran the program using this command: `uvicorn app.main:app --reload` I tried it without the reload flag as well. Same result.

Like I said, even when removing all contents from config.py I still get the exact same error for line 30.

Has someone here encountered a similar problem? What am I missing?
blissful elbowBOT
#

@atomic sedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

atomic sedge
#

Let me know if you need to see some code snippets from the config or any other files

#

or maybe the full traceback

#

but I'm really lost with this and I cant get it to use the newest file version or something

uneven jungle
#

Redact anything sensitive

#

Please upload via pastebin service

blissful elbowBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

uneven jungle
uneven jungle
#

Its different

atomic sedge
#

but the thing is, even if i change it, let's say I set line 30 to DB_HOST: str = "localhost" it still shows as DB_HOST: str = os.getenv("DB_HOST") in the error message

uneven jungle
#

Line 30 is showing DB_PORT now

#

OK what editor are you using?

#

VSCode?

atomic sedge
#

yes, and MobaTextEditor to update files live on the server (I havent set up the ci/cd yet)

#

also I'm only getting this error on the server

#

it's ubuntu aws

uneven jungle
#

oh boy...

#

idk about MobaTextEditor but in VSCode you can see whether you have spaces or tabs

atomic sedge
#

that was the first thing i checked. But again, it doesnt matter if it's spaces, tabs or even if the whole config file is empty. I still get the exact same error

#

I edit it, I save the file, I re run the uvicorn command and the error doesnt change

#

tried deleting all __pycache folders but that didnt fix it either

uneven jungle
atomic sedge
#

sure

uneven jungle
#

yeah thats fine

#

Doesn't make sense that its complaining at line 30 for the DB_HOST but the one that you shared is DB_PORT for line 30.

#

I really do suspect that you have extra spacing in your config.py in your server

#

And this is difficult to prove because of the way you are handling your deployment

#

Do you at least use git to keep track of these changes?

#

@atomic sedge

atomic sedge
#

hmm so like I said, when I change the config.py file at line 30 and I save the changes, re run, I still get the same error. It's difficult to track why that happens, or rather why the changes aren't reflected

uneven jungle
atomic sedge
atomic sedge
#

this is not optimal i know

#

but i gotta fix that fast

#

production is on halt

#

many people cant work

#

and my boss is breathing down my neck

uneven jungle
#

Can you set up git on the server?

atomic sedge
#

sure it'll take a while tho

uneven jungle
#

sudo apt install git -y

#

Can't be too difficult

#

Mind you, you might have a lot of changes on the server that the git repo and your local machine may not have.

#

I'm basically asking you to overwrite all changes on the server and rely only changes from the git repo

atomic sedge
#

yeah you're right imma remove everything and set it up properly using git

atomic sedge
#

there's so many conflicts to fix this'll take like a good 10-20 more minutes

late thicket
#

Can you run on the server:

cat /path/to/config.py
uvicorn app.main:app
```and send a screenshot/pastebin the output.
Again, redact anything sensitive. We need to see what the `config.py` looks like where you are getting the error.
atomic sedge
#

alright @late thicket and @uneven jungle thank you both so much for the time and support. I tried all your solutions. One thing they made clear is: the issue had to be way simpler.
Now i fixed it. Apparently the inbuilt editor I used didnt actually save the changes on the server. Once I edited the files using nano I was able to see the reflected changes

#

!close

blissful elbowBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.