ZeroTwentyFifty / zero_twenty_fifty

Open Source Product Carbon Footprint exchange platform that is PACT Conformant.
https://www.zerotwentyfifty.com
4 stars 3 forks source link

Feedback on Setup Process #36

Closed scottgifford closed 1 week ago

scottgifford commented 2 months ago

Hi Louis,

I've been playing around with this code a bit, to get a feel for the PACT standard. I've been able to get the basics working, and load and retrieve the example footprint from the PACT standard, so far so good! I wanted to share my notes on how the initial installation went for me, in case it is helpful.

I think for many users a link to a Postgres setup guide would have been helpful. I've used Postgres before so was able to get back up-to-speed pretty quickly, but I think a new user might get stuck on this step.

I initially tried to do this on an Amazon Linux instance, but the versions of things were too old. Specifying the minimum versions of Python and Postgres would have saved me a few hours of figuring this out the hard way.

The instructions didn't include how to create the database user and grant access to it. It took me a little trial and error to get a ztf user created, and grant access to the ztf database like this:

GRANT ALL PRIVILEGES ON ztf TO ztf;
\c ztf
GRANT ALL ON SCHEMA public TO ztf;

In my initial attempt, uvicorn main:app didn't provision the tables in Postgres, I had to run migrate.py before anything would work.

I also spun my wheels a bit figuring out how to bootstrap an initial user, eventually I wrote a small script to do it, which I'll include in a comment.

Finally, it took me awhile to figure out that the Swagger UI didn't support authentication, and I had to give up on that and switch over to using shell scripts and curl. Once I did that, things worked pretty well!

Appreciate your work on this project, and I hope this feedback is helpful! I'll keep playing around with it and let you know how it goes.

scottgifford commented 2 months ago

This is the create_user.py script I ended up writing:

from contextlib import contextmanager
from db.session import get_db
from db.repository.users import create_new_user
from schemas.user import UserCreate
from getpass import getpass

username=input("New username: ")
email=input("New email: ")

while True:
    pass1=getpass("Password: ")
    pass2=getpass("Confirm Password: ")
    if pass1 == pass2:
        break
    else:
        print("Passwords don't match")

while True:
    print(f"\nAbout to create user '{username}' with email '{email}'\n")
    accept=input("Confirm [y or CTRL-C to quit]: ")
    if accept == "y":
        break

new_user = {
    "username": username,
    "email": email,
    "password": pass1
}

with contextmanager(get_db)() as db:
    create_new_user(UserCreate(**new_user), db)
JohnVonNeumann commented 1 month ago

Hey Scott!

Thank you very much for creating this issue and interacting with the code base! I'm stoked to see someone getting some use out of it and I appreciate the time you've spent on it.

I have a busy few days coming up over the first half of this week (I am doing a full initial release of our Python library for the PACT Methodology, which you can see here: https://github.com/ZeroTwentyFifty/pact_methodology), but wanted to just give you an acknowledgement that I've seen this issue in the meantime.

In terms of providing a bit of context, you're right when it comes to the docs being lax right now, ultimately I've been (from my knowledge), the only person really playing with this app, and so I have some crude internal docs for myself as well general in-brain knowledge that's not been jotted down anywhere, the classic issue that seems to plague all projects! Writing docs up to this point has not necessarily been something I've had the luxury of being able to do. As I also mentioned, I've been working on the client lib/SDK more recently, and have plans to integrate that into the app, in order to make the code a bit cleaner and provide a bit of a nicer abstraction and separation of concerns between the API and DB, and need to get the codebase updated to provide support for more recent versions of the tech spec.

The TLDR of that last paragraph is that I am aware that this repo is currently not in the state I'd like it to be, and as I rotate back to it, there are a bunch of house cleaning items that will be attended to, this is one of them.

I will get back to you by the end of this week with a more concrete plan, and if you have any suggestions in the meantime, I'd love to hear them!

Once again, thanks for creating the issue, look forward to chatting soon.

JohnVonNeumann commented 1 month ago

Hey @scottgifford!

Thanks for your patience on this one, I have been having a series of conversations recently that seemed related to the overall approach ZeroTwentyFifty takes towards Open Source, product direction etc and I wanted to take a minute to digest and come up with an appropriate plan of attack given the very generous feedback you've given. Here's what I've come up with:

I already have some internal documentation written that enables myself to be able to set up the project, databases and all the things in between, it's reasonably comprehensive but obviously not written for public consumption, but it's in fairly good shape, I don't think it would take much to get it prepped and ready for general use.

I was wondering if I was to put these docs on a branch, would you be interested in contributing to the project via a PR, going through them as a user to make sure they do in fact work as intended, and then becoming the first non-zerotwentyfifty contribution? I think some of what you've already done will mesh nicely with what I've already got. I'd be open to suggestions around how we handle documentation more generally, best methods to surface it all.

Let me know if this is something you'd be interested in!

Thanks!

JohnVonNeumann commented 2 weeks ago

Hey @scottgifford I've just put up PR #41, if you wanna have a quick look at it and let me know if it solves some concerns. I'd like to really get a nice hosting setup built and all of that but I'm not sure what it would look like right now. Sorry it took a bit to get back to you, I've been working on this stuff for a while in isolation so starting to weave community engagement in is a new thing, I'm going to be more active with it from now on. I really appreciate you taking the time to create this issue and set the project up.

JohnVonNeumann commented 1 week ago

closed with #41