#dev-contrib
1 messages Β· Page 134 of 1
lol
lol, okay
i was going to add a worker
I don't know where to ask, but kind of two things:
- Is there a guide on how to contribute the bot? I mean there is a guide on how to run it, but is there a github guide on how to open a PR, make the changes and submit? I think there was a github learning camp here, but not sure if this topic was there.
- If I want to "practice" on making a PR and submitting, how can I? I tried to make a a repo of my-self but it says I can't fork the repo becaus I already own this repo...
@patent pivot is
User-agent: *
Allow: /
Disallow: /admin
```correct?
I don't know much about robots.txt files
might need a trailing slash on the admin path
Does that apply to subdomains or are they treated separately (e.g. paste)?
That won't apply to subdomain, plus paste is an independent service
For the first one there is the setup and config guide for Sir-Lancebot, Bot and Site that is linked here: https://pythondiscord.com/pages/guides/pydis-guides/contributing/
For the second one, I think it is kind of a trial by fire. I definitely learned by doing breaking things for my first Issue / PR / linking a branch of a remote
A guide to contributing to our open source projects.
I guess if we want to give them a robots file we should use a worker
There's a typo in that docstring
@patent pivot OK worker sounds actually better, we could have our policy in a KV for each service, you can assign workers to as many paths as you want
So we can have a single worker serving @/robots.txt, paste./robots.txt,api./robots.txt, etc..
Um ok, thanks! It's just I want for sir-lancebot#862 , which is an easy solution really
Oh sweet, yeah that should be good to go. Have you forked the main repo, then cloned your fork to your computer?
Do I have to do that?
Can't I just change @in_month(Month.DECEMBER) to @in_month(Month.NOVEMBER, Month.DECEMBER)
From the main repo? Not directly.
I mean to fork the repo, change it in my forked repo, and than making a PR
Then yes
In general, the process for contributions is:
- fork the repo
- make a branch on your forked repo
- make the changes on that branch and push back to github
- create a PR asking to merge the branch on your fork into main
Branches are good
step 4 is my biggest problem, no idea how
Keep main updated with main, make new branches for new features or changes
I know how to create a PR
I can walk you through that part~ Github has a UI to walk you through it too
So I won't have to fork everytime?
Ok let me try it
https://github.com/python-discord/sir-lancebot/blob/edb80b90186b7ebfcce8b3dae55fedb62a77b912/bot/exts/holidays/hanukkah/hanukkah_embed.py#L41 In this line, shouldn't the alias be called chanukka
bot/exts/holidays/hanukkah/hanukkah_embed.py line 41
@commands.command(name="hanukkah", aliases=("chanukah",))```
Add it to the possible aliases, seems like a good idea
no, chanuka is correct
Ok π
@green oriole 
Oh naw!
Now level 4
Should I press this?
Sure, is that on your fork or the python-discord
NIRDERIi:hanukka_cmd_month is a branch in the fork I did, and when I got to the PR page in python-discord:sir-lancebot I have this message
yup! that's the correct button
That is good, click the button
Nope, it is already correctly comparing across forks
Since it has your fork and branch in the comparison
Oh it did the job for me cool
So I just create the PR right? Just one more thing, I didn't read the templates comments because I have no idea where that is
You are currently filling out the PR template, just make sure you read the comments and have added the relevant info
These things:
Relevant Issues
<!--
It is mandatory to link to an issue that has been approved by a Core Developer, indicated by an "approved" label.
Issues can be skipped with explicit core dev approval, but you have to link the discussion.
--><!-- Link the issue by typing: "Closes #<number>" (Closes #0 to close issue 0 for example). -->
Description
<!-- Describe what changes you made, and how you've implemented them. -->
It was approved right?
Technically not yet, but maybe kat or Xith can add the label
It is approved though, you have wookie and kat Ok with it
So I'll leve the approve part blank
Go for it
Hmm, that's an excellent question
Is it the wrong way around
!e
import re
print(re.match(r"(?:(a)b)c", "abc").groups())
@green oriole :white_check_mark: Your eval job has completed with return code 0.
('a',)
So we do need another ?:
it depends how we extract the actual invite code from the groups
if we do something like .group(1), then if we add a new matching group, then it would pull that new one instead of the code
Since we've added a capturing group around [\.,]|dot then that will be then first group
I honestly hope that's not how we do it lol
iirc the api requires just the code, so I think that's how we'd need to do it
but I haven't looked at the impl myself
All of the other groups in the regex are marked as non-capturing too
except for the code group
Named groups are the way to go my dear Chris, not fragile indices 
self incrimination
https://github.com/python-discord/bot/blob/main/.github/CODEOWNERS#L24
.github/CODEOWNERS line 24
bot/utils/regex.py @Akarys42```
lol
Hey! May I ask what's the situation of api#16 ?
Can anyone please review sir-lancebot#864?
i think that decorator means staff member OR bot commands
Oh ok
Can you provide more context?
Maybe something wrong with bot.api_client for you?
Is this you running the bot locally?
?
Is metricity and the site configured?
For sir-lancebot#859 , any opinions on this: https://github.com/python-discord/sir-lancebot/pull/859#issuecomment-915352246
Have you fetched and updated your fork though?
No need then
Did you simply clone the project?
Through Git, or did you only download a zip (I actually don't know if you get the git history with that)
Have you pulled since then?
You may not have the fix
Then you need to pull the changes, what happened was that it was fixed but the bot you're running does not have those fixes
Yes
should be, rebuild the docker image first
When you do git log what's the output you get at the top?
Ah good, that means you should have that change
Did you do the docker-compose down and then docker-compose up stuff?
Ah, that won't rebuild the Docker image, which I believe was necessary for the change you're looking for (because it changed some stuff about the Docker image)
docker-compose down
docker-compose up or docker-compose up --build
you'll need to delete the site image
docker-compose up --build doesn't re-pull site:latest
if there is one local
at least not all the time, I think there's some cache rule that determines when to do so
If you do docker-compose down, that will remove the containers
If you open docker desktop and goto the images tab, you can delete the site image there
it'll be site_web iirc
π
there is docker-compose pull to get latest images
or just deleting the one you have works ye
I am hosting @stable mountain locally using docker. How can I get the latest commit from github and update my bot?
Yeah I forked the project, and downloaded it to my computer
Oh I just realized I could just navigate to the dir and do git clone right?
you should be able to just git pull
Me bad with git
then restart the app
it shouldn't require a rebuild; the code is mounted as a volume into the container
unless there are dep changes or something
Well it would if the Docker image scripts changed, which they did recently
yeah of course
For sir-lancebot#859, any opinions on this? https://github.com/python-discord/sir-lancebot/pull/859#issuecomment-915352246
Same for sir-lancebot#834. I don't know if I have the issue in the right place
My biggest worry is how big WTFPython examples get
Right? There are some entries that are quite long
Anyone mind looking at sir-lancebot#864 ? It's really small issue I know
idea: upload them as files
Already did π
let the discord preview wrap them
joe can you look at it?
So I would parse out that section to a temp file, then let discord handle the preview for it?
Yeah I saw it, thanks(give this man contributor role dammit)
approved
yeah
is it 1 example per item or multiple?
hmmmm interesting. I would imagine one file per example
so that probably works alright
we didn't want to enable for users but for the bot it seems solid
So I just need to wait for two more reviews right?
1
@clever wraith what's with that PR?
not a huge fan of "shit code" and a no-body PR with no assigned issue
I'll have to test that out and see what the output is like
π
What's an union with noreturn even supposed to mean
give me a ping if you give it a try
raises exception I guess?
sometimes it never returns anything π
I don't think you typehint for that though
hah will do, no promises on when that would be π
You generally don't yeah
NoReturn is for like an infinite loop
noreturn is only for situations where you never return
rock solid, no pressure, just an out of the box idea for it lol
It would be annoying to add for all cases where you may raise an error
With exceptions that can be raised anywhere, it's definitely not applicable
yeah
it's specifically documented as never returning
yeah
okay so not a thing that needs to change
well, can wait to hear from author but otherwise I'll drop a comment and close, it should have been raised here or had an issue opened
closed
what PR?
bot#1818
yeah that one
Were these changes auto gened π
The only places NoReturn makes sense imo are exit functions
Anyone want to review a PR real quick? bot#864
You want a core dev, like wookie, xith, akarys
Yeah I know
So. Trying to setup Python bot to test some stuff. I'm getting an error on the Python News cog where it's failing to send a message to the webhook. For some reason it's failing there and I'm not sure why.
Is your test server setup as a community server?
you can't publish messages to announce channels if they're not
uhhhh, probably doesn't, since that is newer than the docs
I ran into in on the test server and just turned it on
Are the messages still sending to the channel, but still erroring?
This is how I feel about using our current contributing guides:
I sense a site issue about to be opened
lol yup
Like, the contributing guide just focuses on the wrong stuff.
Why not use the staff server?
Because I want to have control over my own testing?
I'm allowed to use my testing server.
Yes, you are, I am just wondering why
No dice. No messages are being sent. I'm getting an error on the is_news() check, where apparently msg is NoneType
Kat is becoming sentient
What is a News cog? Where is it located?
Oh thanks
Message is none, huh
Unable to convert 'News' to valid command, tag, or Cog.
!source [source_item]
Can also use: src
Display information and a GitHub link to the source code of a command, tag, or cog.
U suck
I think it's erroring out on sending the webhook, but not like... actually raising an error so it's propagating the None throughout the code where it assumes the webhook object or whatever has been returned. But I can't find anything helpful about setting up the webhooks in our contributing guide
Did you get an exception log?
is the channel marked as an announement channel?
Seems like our utility to send webhook will return none if it runs into an error which is silly
yup
oh wait, it's saying msg.channel is None
that's odd
oh no, msg is None
where is msg getting set?
Did you not set up a webhook?
this is where it's failing, I just have no insight into why:
hmmm, that's failing for some reason
Look at the except branch of the definition of send_webhook
And did you slap the webhook ID in the config?
Yup. The webhook ID is for the same channel as the python news and it's an announcements channel.
https://github.com/python-discord/bot/blob/main/bot/utils/webhooks.py#L12-L34 Maybe check if msg or smth
config-default.yml line 306
python_news: &PYNEWS_WEBHOOK 704381182279942324```
Yup. Triple checked the webhook ID as well.
hmmmmmmm
this isn't something you'd typically document in contribution guidelines, it's into the weeds
I mean like "hey, here's how to set-up the basic required stuff of our test server to match the config.yml"
you'd either:
a) have the code handle for it, print a warning
b) have the program catch the exception and rewrite it to tell you what is wrong
yeah
I think I know
either way, we should handle for it in code as well
It is stupid
Is
python_news:
channel: *PYNEWS_CHANNEL
webhook: *PYNEWS_WEBHOOK
```in your config.yaml file?
Or is it only in the default config
It's in my config.yml because my config.yml is a copy of the default-config.yml with values changed, per the contribution guidelines.
Welp
Maybe try to mess with the code an print the error of why it doesn't send
Does the bot have admin perms?
Nope. That's all I got. That error traceback
Could you add a log.info(self.webhook) before line 118
and a log.info(msg) on line 156
unless you're running bot locally, then debugger would be nice π
the send_webhook should be logging the exc though, no?
it makes an exception log in the except block
First, if it's Webhook.send, how can it have .channel if the return type is WebhookMessage. And second, it says Optional[WebhookMessage], but I am ust guessing https://discordpy.readthedocs.io/en/stable/api.html#discord.Webhook.send
yea, which is weird since it's not raising
WebhookMessage inherits from discord.Message
Oh
Okay, a restart and some other debugging later.
It's giving me 400 Bad Request: Invalid Form Body during the send.
If i print the webhook, it gives me <Webhook id=...> with the ID being the one I have in the config and the one I confirmed is the webhook ID for that announcements channel.
hmm alr, so webhook is alright
it's the send that's the issue
hmmm
What main commit are you base on?
commit 160f0ecb125fe317abc644100e58ab9557ea7faa (HEAD -> main, origin/main)
Author: TizzySaurus <47674925+TizzySaurus@users.noreply.github.com>
Date: Wed Sep 8 09:48:22 2021 +0100
Add support for `!infraction last` (#1804)
This?
I just cloned for this, latest commit is 160f0ecb
does a send with some simple known content work?
Um ig I should let you know? Not related to current topic
known bug - not mission critical though really
hmm that implies the source data is off
but if that was the case we should be seeing that in prod too
Sentry Issue: BOT-6H The command uses discord.py's default Paginator. Can that be replaced with our LinePaginator, which automatically moves long text to a new page? RuntimeError: Line exce...
I know, I have no idea what's going wrong with the setup of bot though
Oh ok thank you Zig and a nameless owner
can you debug all the arugments being passed to the webhook send call?
Lmao
So I'm trying to test a super basic one, because I feel like it's something with the webhook setup, I just ... don't know what I'm messing up.
await send_webhook(webhook=self.webhook, content="Testing")
Even this is failing with Invalid Form Body.
wtf
I've checked the channel ID and the webhook ID I think a dozen times now
and if you try run .send on the webhook?
could also set wait to true as a kwarg to send_webhook and then try debug print the response in send_webhook
The issue with send_webhook is that it doesn't output a response. It just logs the exception and then the code fails later on because it's given a None value.
right - but you can add debug to send_webhook
@vale ibex approved the cache pr
ah cool I'll fixup now
And to answer your question, yea I think we should. It added error handling right there, rather than when the obj is destroyed
Numerlor has bot#1807 open for it
So I can't really get any other debugging response besides just "Invalid Form Body"
I can use the webhook directly with a bare aiohttp client session and discord.Webhook.
I feel like I'm missing something vital with setting up webhooks for python bot.
I wonder if it's the omission of arguments that is causing things to bug out
maybe setting name / avatar / etc would make it work
Their test code above works for me
well that's weird
I'll give it a try locally as well
If it's not config, maybe its version of d.py?
Are you running in docker, or locally?
Ah nvm, your error looks liek docker
Docker, I'm not that much of a masochist
This is my first time ever building bot too
Could you change this to just await self.webhook.send(content="Testing")
skip the util
I tried that too, Invalid Form Body
guessing that says the same?
did we just deploy site
sad
not too recently no
ye
π€
Logs?
me and volcyy put together https://grafana.pythondiscord.com/d/YkOYWwVnk/issue-96?orgId=2
which imo at least shows a pretty tight correlation
no bot deploys = no site restarts
Joe what are we looking at
hahahaa
so the top one has a point every time we restarted bot
and the bottom one shows every time sites P99 (max time for 99% of reqs) crosses 1 second
can I add my bot to your server?
and try with your ids
which then causes the workers to saturate, healthchecks to fail and pod gets restarted
Is the bot blocking something?
ignore the huge empty space that's because prometheus ran out of disk space and i didn't notice
lol
it's the huge sync at bot startup
just gave you ultra perms, go nuts
Well, could you try to deploy a build without the sync steps and see how that goes
yeah, although my config.yml is the most thrown together thing and there's probably other stuff in there that'll break. I just can't get past the webhooks ;-;
If itβs the sync steps could we have the bot fetch from a public request instead of directly through the network π€‘
Let CF handle the spam
So I deleted the image, re pulled, re-built. No dice.
... Maybe I just don't ever contribute to Python
Whatcha workin on?
another beauty from the python discord hivemind
me or joe?
tags ;-;
Ahh
I wanted to test out the string-formatting tag and a contributing tag
Can I have a recap? what isn't working?
You know what, this reminds me. I was working on a thing to get tag previews on GitHub so you donβt have to do this at all
Webhooks are bombing out for me, I have no idea why.
mmm
Very far fetched idea though
Can you send your config?
I'm pretty sure it's something in my set-up, I just don't know what
Are you using our test server?
nope, my own
Figured I could also use this to see the pain points in our contributing guide
lol, tbh I'd rather just not contribute to Python than go through the whole set-up of using the staff test server and having to ask Mark for perms and then worrying if my bot is going cause issues.
It's just inviting your bot to the server, really. You don't need any perms to work on tags
Neither does your bot, except sending embeds
Inviting the bot takes admin perms, no?
For you, I can give it to you now
I'm pretty sure it's something in my set-up, I just don't know what
yes, I'm just trying to mimic every configuration and see if I can fuzz the error
that's annoying
found the issue
so we set allowed mentions using allowed_roles = [discord.Object(id_) for id_ in constants.MODERATION_ROLES]
since it's a list it can have duplicates, if the config has duplicates
so when d.py sends that to discord, it's an invalid list of roles, since they're not unique
we should warn if there are duplicates
or pass through a dict first
Sweet. Here I thought "surely, I don't need separate roles for mod and mod team and admins and owners"
It works now. Thanks for helping Chris.
π
(set)
allowed_roles = [discord.Object(id_) for id_ in constants.MODERATION_ROLES]
mylist = list(dict.fromkeys(allowed_roles))
You can list({discord.Object(id_) for id_ in constants.MODERATION_ROLES})
I don't think order matters
true
If you do it on consts.mod-role you skip the second variable
Or that
At this point though
Nit picks
aaaalright, there we go:
π

Manage server
It should exist from the SQL you ran
When uhh
When did you last create the postgres container?
What the heck, Kat's issue was about having duplicate allowed mentions?
That's discord for ya
Sigh
Did you update the repo first?
Hm, well it should in theory exist then
Sure, you should just need to remove the postgres one
Can you show the rest of output above
That's the important part
It might be an html page
Oh boy, there are both logs at the same time
Can you open a new window and do docker-compose logs web and docker-compose logs bot separately?
You should be able to open a new one yeah
Also closing the terminal may not stop the services
All the errors seem to be related to the database not having the tables it should
That can be solved by running the sql manually, but docker-compose up really should've done it
Do you use docker for anything else othe than pydis?
If not, you can run docker-compose down then docker system prune --all --volumes it'll delete everything docker related. Then you can docker-compose up to start again
@vocal wolf concering 2.0 the two bugs I've found: one is a dm typing event which doesn't get dispatched. Doesn't affect pydis bots (does affect modmail)
And threads.archiver_id is always None, but that's since discord removed that. Only way to get this is through the audit log now
no plans to migrate modmail to 2.0, so we're good
Meh, put that there for myself lol
Modmail fully breaks under 2.0 lol
Not worth anyone's energy here to monkey patch it up
What command are you running to get that error?
This but the cropped out error in xxxx stuff
I am not sure what we would gain from a 2.0 modmail bot
Alright, after you got back did you delete the volume, then did a compose down and up?
Huh
Can you upload the full logs?
that's a fun bug
no, this needs to be merged
for now you need to do the same fix as before, running the sql manually π¦
@green oriole in case you were interested in what the issue was, see the above pr desc
not by default, no
some commands my implement that, but it's not default behaviour
That's interesting, weird we didn't see any warning or anything
I mean we wouldn't in prod, since metricity already exists
and I had debug logging and saw it creating the tables and inserting rows just fine
just in the wrong db lmfao
yea, read the PR description π
yup
I mean, weird that psql doesn't write any warning when running locally
?
What did you do?
ahhh yea ofc, that is the wrong sql now, since this is after the change
1 sec
yup, send some messages in the server
that'll insert some messages for your acc
That won't insert anything if you don't have metricity running lul
What are you working on that requires metricity?
Yes but are you working on voice verification?
What was your purpose for starting up the bot?
ok
If you want to use it, you can either modify the end of the sql to have your ID, or set up metricity
Did you clone the repo?
Normally you wouldnβt need to set metricity up at all, very few command depend on it
Especially on your own user
Are you using docker?
Are you sure the two containers are able to communicate?
Or at least, that metricity is using the same instance of postgres
If you look at your list of containers it should have a single postgres container running
Also my knowledge might be outdated, but if you're using metricity you need to destroy the testing metricity tables created by the site so that metricity can create its own
Not really available to do the full explanation, but last time I had to interactively enter the container and drop the tables, and only then start metricity
One could say we should improve the metricity setup process. But we could also argue that nobody really does that, lol. Being able to place them in the same compose project would be handy, although can be quite buggy.
It should be relatively easy once you get it set up for the first time, but it definitely requires a lot of work - you're not intended to run the system like this
Hmm thinking about it
Why do you think itβd be buggy
It shouldn't be buggy. That said we'd need to change tests for something like voice verification which assumes specific rows exist in the db
Sorry, not voice verification, I mean the endpoints on the site
What we could do is override the command in the compose to not run the migrations, and just start the project
That'll get rid of the table already exists errors
I'm not seeing anything else that could cause problems, neither on site, nor bot
That may be more useful in the site, in the bot it's probably better to not pre-create the data, and instead have the users dynamically populate it
That way we don't have things like ^
tbh I'd like to be able to start the bot with the full feature-set with the compose
I'm starting to like my solution of initialising metricity on boot less and less
the recent PR will fix the issue we have now
but I'm leaning towards putting metricity in the site & bot composes
and removing init from site all together
We can insert the rows that the tests are dependant on in a fixture
or even have a debug flag on metricity that does it
If the purpose of that init is for tests, and there's a way to create it only when testing, and it's not a nightmare to write, I'm in favor of it
I considered doing it from metricity, but alembic manages the migrations and it's kind of annoying to do it from metricity
Just a lot of work when there's a simpler solution
Also not relevant for metricity itself is the most important part
site requires metricity to exist on boot now, and requires data for tests
You mean the metricity db?
yea
Wasn't that the case already?
Site I think can still use the init
not on boot
it used to error if a metricity endpoint was hit
now it errors on boot
But if you want to use metricity in the bot compose it's going to clash
Yea, I'm thinking we add metricity to bot & site compose, to handle creating the relations (which it already does)
I think it got muddled a bit
then we insert data needed for site tests during the test fixtures
So on site:
- We use the init
- We force metricity to start without running migrations, which voids the whole table already exists problems.
- We now have the data we need
In bot:
- We don't use an init
- We just run metricity and let it go wild
- Users insert data by typing in their servers, which is more useful since it'll be actual data that can be used for commands such as user
Maybe it doesn't make sense to run metricity on site at all the more I think about it
You'd need a bot token and w/e, and it really isn't useful
Basically, site can exist as it does now with no problems
What if you want to use site in docker and bot locally?
Exact same process
which i do
But then you start the site and it doesn't have metricity set up
So you have to set it up manually
bot
Right, so do you also want to start the metricity bot seperate of the compose?
I think referring to everything by the same generic terms got a bit confusing π
So we add a new env var that tells site to init metricity db, that only gets set in site compose
We don't really need an env var I don't think
that way, running site we don't have metricity running, but the data is there
What will it do?
Well, we just use the init for that, why do we need metricity on site
How do you otherwise separate the two states?
because it errors if db relations don't exist
If you set up the site currently, it runs the init
You need to somehow tell it not to
Right, so you're talking about running the site separate from bot?
yes
Well, I was just gonna go with what we currently have, which is deleting the tables manually. Can we load the sql init on a var?
That should be possible
Yea so what I'm thinking now is there is a env var that controls whether site inits metricity relations on boot. This gets ran when you run the site compose file, but not the bot compose file
since we don't want it to run when we run bot, since we will add metricity to the compose
Ok, now I'm confused again
If you are running site alone, and bot alone
How would you make a decision based on the bot's compose
The gist is, don't destroy the db, tell it not to create it in the first place in the case of the bot compose
I'm referring to if you're developing on the site repo, or if you're developing on the bot repo
site repo you want metricity relations to exist, but you're not running metricity the program, so you need site to init them
I don't think we want the init on the bot, no?
bot repo, you are running metricty the program, which pulls up it's own relations, so you don't want site to init them
Right
so we need a way to tell site to init or not
What I'm getting confused about is I'm assuming when you say run seperate projects, you're running the compose of the bot with just the bot, and the compose of the site, with just the site, so something like:
If we want to run the metricity bot:
Let the metricity bot init the metricity DB
otherwise:
Let site init the metricity DB
We don't want the metricity bot on site, but we do want it for bot
So to summarize:
- On bot, no init, just metricity
- On site, we have init based on an env var
Right, that's what I'm thinking
We have an env var anyway, it just gets a different value on each compose
The env var is for the site
Because the site needs to know whether to init the test DB
But I mean the site itself can't process that env var
docker-compose is what needs to
yes
I think we should get site#587 reviewed and merged first
the init is in site now
at runtime
not in compose
Oh?
since bot doesn't have access to the init.sql on teh site repo
it couldn't init metricity at all
I see... should we revert that based on the discussions above?
so we moved it into site runtime, so when you run site via bot compose it still has relations
no I don't think we should
hmmm
actually
It shoulllllldn't be relevant for bot anymore
yea, if we're adding metricity to bot compose, as long as we make sure metricity finishes migrations before pulling up site, it should work
we can revert all of this and move back to a init volume
Ah, seems we are on the same page
Now to figure out how to make sure metricity finishes migrations before pulling up site
lol
docker-compose depends just waits for the container to start, not for migrations to happen
Why is this necessary?
There is an option for liveness probe
But yeah, I'm not 100% sure where that fits in
Does the site need the table for startup?
since if metricity hasn't finished migrating, the metricity relations don't exist, and then when site boots it'll error
yes
What does the site need it for?
django-prometheus requires metricity relations on boot
it's a new thing we added for devops iirc
not sure why it needs it, but it errors if it doesn't exist
https://docs.docker.com/compose/startup-order/
So the top suggestion is to create the liveness check at the site level, but that may be blocked by whether or not we can get our code to run before prom
it's hit whenever we do django.setup()
The suggestions after that though are wrappers around the container we're waiting for
Seems like a good place for this
Ok, that sounds like a good gameplan to me. It doesn't even require a second bot token I think
yea, I've got site working and checking for metricity relations
just need to get it working with bot
metricity is not patient with postgres lol
huh metricity isn't doing migrations itself 
Added this to the docker-compose ```
metricity:
<< : *logging
<< : *restart_policy
depends_on:
- postgres
image: ghcr.io/python-discord/metricity:latest
env_file:
- .env
environment:
DATABASE_URI: postgres://pysite:pysite@postgres:5432/metricity
ahh ofc
database uri needs to be pysite
then it switches
nope it doesn't switch
I think we're going to have to create two postgres instances in the bot docker compose
we need 2 databases running, pysite and metricity
Anyone wanna #763406158522220544 and pair?
need to explain the issue I'm in and make sure I'm not missing something obvious
There shouldn't be an issue with having two databases in the same instance
yea, the issue is creating it
If it's working in prod now
might need to write a bootstrap script in the bot repo to create the metricity db
Why does the bot need to do that, and not the metricity bot?
metricity bot doesn't create the db, it connects to it and populates it
postgres:
<< : *logging
<< : *restart_policy
image: postgres:13-alpine
environment:
POSTGRES_DB: pysite
POSTGRES_PASSWORD: pysite
POSTGRES_USER: pysite
this creates a pysite db
how would that work?
string compare the database, if its not "metricty" then metricty crates a new db?
I recall not being able to start metricity, because the image was trying to apply migrations and the test database already existed. Which is why I needed to drop it first
yea, that's not the issue
What I'm trying to say is that the image should be taking care of creating the db
Maaaybe it doesn't take in any database fragment, and will connect first to the engine to create the database if it doesn't exist, then connect to the actual database
the image just connects to a db, it doesn't create a db
it creates tables within the db it's given connection string to
IMO it should :D
Ah I see
yea, so we'd give metricity a bare connection string, with no db
and it creates the metricity db in it before migrating?
I think so
You can still supply a db, and create it only if it doesn't exist
true
That sounds a bit cumbersome
we'd need to write something to do this though, as the current entry point for the dockerfile is albemic
so we'd need to change the metricity entry point, since the db needs to exist before that
If I specify a database name and it doesn't exist, I would like the bot to assume something is wrong and it isn't connecting to the right cluster or don't have the right perms
hmm that's true
We can have a shell entry point that runs a creation script, then jump to alembic
yea
also, this is pretty cool ```
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pysite"]
interval: 2s
timeout: 1s
retries: 5
then ```
metricity:
<< : *logging
<< : *restart_policy
depends_on:
postgres:
condition: service_healthy
so that metricity doesn't try to start before psql is healthy
all in compose
hah yea this is in the bot compose
O really
well, on my machine it is lol
Are we adding metricity to the bot?
yup
this is where this whole conversation started
the metricity init solution for site didn't actually work
Wait, so are going to have PG + site + bot + metricity?
and redis and snekbox 
Do you want to discourage all of our contribs on lower end computers haha
It should be an optional dep imo
where can i share my github project in this discord server ?
In the metro, back in an hot minute
if you need help something in particular with it you can have a read of #βο½how-to-get-help
i did, no body replied me
I can't see any messages from you in help channels
Take a read of #βο½how-to-get-help, it explains how our help system works
There is also a guide in there on how to ask good questions, which will increase your chances of getting a reply
yea, this is true
π Me reading kat's messages about setting up Python and Site yesterday and then this convo today....
well yea, it needs to be improved somehow right
not sure we'd be able to do that without discussing...
I think it is pretty freaking sweet, I like technical discussions and especially when I don't understand it. Lets me know there are things to learn, and who to contact for when the time comes
Yea, there's quite a bit to our infra lol
Can't wait to set up Python, which requires Site
And then breaking all of the things (on my side)
bluenix going wild on reviews 
since metricity doesn't have psql installed, we can't really do it from a bash script
we'd need to put a python script to init, using psycopg or smth
yea, in bot that's where the logging is setup
What do you mean? metricity is updating the DB on sent messages
via python yea
I'm referring to the psql cli tool
ah
@vale ibex so here is my two cents: starting up a metricity instance should be a conscious decision. Having two bots silently starting up while you expect only one to start seems quite counter intuitive, especially when you except to start @stable mountain and nothing else. Besides, metricity is only required for two features of the bot, and it takes up resources.
We could make it so the bot doesn't depend on metricity, you'd have to excplicitely start it up I believe. If it doesn't work like that, we can always have it in a separate compose file and have it be selected from the command line.
Also let's just make it a python script instead
the issue is that site depends on metricity relations existing to boot
we didn't want site to handle it all the time, since if you wanted to spin up metricity you'd need to remote into psql and delete the tables
otherwise metricity would complain during migration
Metricity doesn't have commands, it's just an event listener written with Python
yea, I think the reservation there is it's another thing running on your machine, which might impact lower end PCs
since to run python via compose you would now need to run 6 services
I'm not sure exactly how much it would impact it
we'd need metricity to run alembic but not start fully
Hmm
LMAO @brisk brook
Technically there can be a separate entrypoint in the init file
we would change docker CMD ["sh", "-c", "alembic upgrade head && poetry run start"] to ```docker
CMD ["alembic", "upgrade", "head"]
RUN if [[ -z "$start_metricity" ]]
then
poetry run start
fi
or smth like that
ic
hmm, can any1 tell me what discussion is going on here, i am not willing to read those 200 messages π
python - site - metricity - db problems (i don't know, just following lol)
umm i had this problem about 2 weeks back when the prometheus PR by joe (was requiring a metricity db) was merged, i just created the DB and it was working fine after that π€·ββοΈ
Even if it's necessary from a perms perspective (no idea there), you definitely don't need every channel set for developing
Permissions should already be defined. It doesn't matter anyway if you're not doing anything that relates to it
the only thing that really matters for testing is that it sends it to the db and tries to mute
huh, wouldn't think the newline thing applied to md files as well
π π ... tag speedrun? π₯Ί
link me the pr :P
bot#1819
I believe one way to do it would be
CMD ["/bin/bash", "-c"]
RUN ['alembic upgrade head; if [[ -z "$start_metricity" ]]; then; poetry run start; fi']
```but honestly we would be better off adding a shell script to the repo lul
I've just written the py script in metricity to create the db
python create_metricity_db.py
alembic upgrade head
if [ -z "$start_metricity" ]
then
poetry run start
fi
this is the current entry point script
I think we should start by default if there is no env var
and then have the bot set one to not start it
to keep with current behaviour
Create If not exists?
Can you actually write sql queries
As in, can you write custom sql queries with the migration tool
Not questioning your sql skills π€‘
@brazen charm what about something like this?
Oh that is cool
doesn't exist for psql databases lol
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
with conn.cursor() as cursor:
cursor.execute("SELECT 1 FROM pg_catalog.pg_database WHERE datname = %s", (db_name,))
exists = cursor.fetchone()
if not exists:
print("Creating metricity database.")
cursor.execute(
sql.SQL("CREATE DATABASE {dbname}").format(dbname=sql.Identifier(db_name))
)
conn.close()
gotta do this instead
oh I forgot about the fill char, that looks great and shows one more feature of it
@cold island thoughts?
Yeah that's good, better than what I suggested in the PR
metricity#7 is a non-breaking change that will move us towards getting metricity working in site & bot
would appreciate comments
That's very stupid though haha, "I don't know if I have a database π€·ββοΈ" π
big sad
sir-lancebot#849 any reviews would be great
also for visibility @brisk brook
Yeah I saw that, I think that may be the best way actually
It looks decently sized as well
Don't forget to set -e
good point, will do after dinner
I'll trade you a bad review for pressing a merge button :D @vale ibex
point me to the button lol
bot#1819
huh, automerge doesn't ask for a commit message on the github app
Presses request changes
lol
The only thing is the format of the if branch being obviously wrong 
lol not this again
lucky I don't write bash often
is it if [ ... ]; then rather than new line?
that convention sucks π
I'm so used to putting { a new line
I do the same for then
Ya haha
But honestly that isn't an issue since it is the only bash file of the repo
lol yea
if you approve this, then it becomes convention for metricity
and I will request changes for any new bash files
π
lol, I honestly don't know enough about that SQL madness to approve
imagine SQL
Would love to get some reviews on bot#1634 bot#1446 sir-lancebot#745
which part? π
Okay, I'd like to get a !contribute tag going driving people to some of our projects, particularly Lancebot. What would you say are the vital pieces of information people should have?
Off the top of my head:
- Listing our common/larger projects (lance, python)
- Directing people to this channel
- Linking to our "start here" contributing guides or what have you
there is alredy a issue on that i think
Could it pull issues marked as "good first issue" from GitHub?
Wouldn't expanding the https://pythondiscord.com/pages/guides/pydis-guides/contributing/ page be better in this case? I think the topic too broad for a tag
yess that one
So, I think the goal here is to have a command that will easily direct people to this channel and that guide if they ask if they can contribute to stuff. So less of an explaining and way more of a "go here!"
If we'd use the "good first issue" labels more, it could display at the bottom (requires making it a command though) approved issues to get someone started
I am thinking it would easily get someone potentially excited about something they can work on
OK I think I actually got the gist of it lol, works fine, approved
Just need to add set -e to the bash
kk force pushed changes to the bash file
Alright gonna push the site and bot changes
Alright, to summarise.
In metricity#7, metricity now creates it's own DB if one doesn't exist, along with running it's migrations as it used to.
In site#588, site no longer runs metricity migrations at runtime, it instead uses a volume in it's docker compose
In bot#1820, bot includes metricity in it's compose, but sets an env var so the actual bot doesn't start, only the migrations run. This is so that when site boots up the metricity relations are ready.
If someone actually wants to run metricity with the bot, then they just need to remove the skip_metricity env var in the compose
The metricity PR can be merged as is, but the bot and site PRs need to be merged around the same time. Merging at different times won't affect prod, but will impact local devs pulling new site images
cc @cold island @gritty wind @green oriole since we discussed earlier
sick
good job
docker compose healthchecks are cool
π π π
if tag_name_or_group is None and tag_name is None:
if self.tags:
await self.list_all_tags(ctx)
return True
else:
await ctx.send(embed=Embed(description="**There are no tags!**"))
return True
elif tag_name is None:
if any(
tag_name_or_group == identifier.group and tag.accessible_by(ctx.author)
for identifier, tag in self.tags.items()
):
await self.list_tags_in_group(ctx, tag_name_or_group)
return True
else:
tag_name = tag_name_or_group
tag_group = None
else:
tag_group = tag_name_or_group
embed = await self.get_tag_embed(ctx, TagIdentifier(tag_group, tag_name))
if embed is None:
return False
if embed is not COOLDOWN.obj:
await wait_for_deletion(
await ctx.send(embed=embed),
(ctx.author.id,)
)
# A valid tag was found and was either sent, or is on cooldown
return True
So this is quite the mouthful from bot#1663, any ideas on how we can make it more readable?
if not self.tags:
await ctx.send(embed=Embed(description="**There are no tags!**"))
return True
if tag_name_or_group is None and tag_name is None:
await self.list_all_tags(ctx)
return True
if tag_name is None:
found = await self.list_tags_in_group(ctx, tag_name_or_group)
# If there is a group with that name and we paginated it
if found:
return True
tag_name = tag_name_or_group
tag_group = None
else:
tag_group = tag_name_or_group
...
What about this instead?
Though it requires changes to list_tags_in_groups() so that it looks like the following: ```py
async def list_tags_in_group(self, ctx: Context, group: str) -> bool:
"""Send a paginator with all tags under group, that are accessible by ctx.author."""
embed = Embed(title=f"Tags under {group}")
tag_lines = sorted(
f"\N{RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK} {identifier}"
for identifier, tag in self.tags.items()
if identifier.group == group and tag.accessible_by(ctx.author)
)
if not tag_lines:
return False
await LinePaginator.paginate(tag_lines, ctx, embed, footer_text=FOOTER_TEXT, empty=False, max_lines=15)
return True
@brazen charm thoughts about these changes? I can't suggest them because it overlaps removed lines which GitHub isn't happy about.
match :P
Can someone point me at how https://github.com/python-discord/site/blob/main/pydis_site/apps/api/viewsets/bot/infraction.py#L62 was achieved?
pydis_site/apps/api/viewsets/bot/infraction.py line 62
Response is paginated but the result is returned without any pagination metadata.```
pydis_site/apps/api/viewsets/bot/infraction.py line 150
pagination_class = LimitOffsetPaginationExtended```
`pydis_site/apps/api/pagination.py` line 7
```py
class LimitOffsetPaginationExtended(LimitOffsetPagination):```
looks like we subclassed LimitOffsetPagination to remove the meta data
π
@clever wraith I responded in site#578 with a method that might be simpler.
Ah, that looks even better - if there was a way for it to not return a nested dict and instead give back the information directly that would be even nicer imo
my solution was based off a stackoverflow answer and someone saying that it follows convention to implement bot/users/username to add an alternative to fetch by username, so I really don't have an opinion on which one of them is better π
With the second comment it will return a list of dicts, so adding a [0] will give you the user's info
.uwu 885596963255484436
885596963255484436
this doesn't work for message IDs?
it just replaces r's with w's iirc and something else
.uwu rrrrr
I thought it could look up message IDs in the cache and uwu them
try a message link
.uwu #dev-contrib message
twy a message wink
ah
it'll only work on IDs if that message is in the message cache iirc
messageid <-- message in same channel
textchannelid-messageid <-- message in same server
messageurl <-- any message
All assuming cache etc.
I started up 11 hours ago.
885263482725994536
Yeah, the last two aren't dependant on cache
.uwu 885618510217248849
.uwu 885263482725994536
π€
Since there's no way to get message (thus content) from just the id
others are fine
Or at least there wasn't when the converter was made
Yea, it's a bug in the d.py convertor 
I think might be possible with PartialMessage now, not sure
why do we cache the messages? why not just use bot.fetch_message?
.uwu 885618804896456724
de docstwing says it assumes cuwwent channew if no id is given
YAY
lol
Right, yeah
.uwu this is a thing
dis is a fing
Short: Because it's an api call and those are bad
how does it know which <th> is which?
but in English, <th> represents two different sounds
.uwu this is a thing
dis is a fing
UWU_WORDS = {
"fi": "fwi",
"l": "w",
"r": "w",
"some": "sum",
"th": "d",
"thing": "fing",
"tho": "fo",
"you're": "yuw'we",
"your": "yur",
"you": "yuw",
}
that's how lol
.uwu thick
dick
lol yup
that's a rip


!warn @dusky shore inappropriate message
I shall call on this favour one day
||!pban||
Lance no
are you saying lance can't be gay?
Does it suffer from the Scunthorpe Problem?
Couldn't someone just .uwu f*ck
we should make the bot respond with this whenever people put profanity in code samples. most of those are from people in #discord-bots trying to make their own profanity filter.
The what
google it π
we're gonna have to make this channel nsfw now
it's a problem basic profanity filters run into
Oh lmfao
Says the guy who just shamed me for saying "Lance no" lol
you were gay shaming him. obviously.
I am a member and supporter of the LGBTQ2IA+ community and continue rant here
what is the 2?
Two spirit iirc
what if we just call it + so we dont have to add more letters
or .* cause that covers everything
but it can still include heterosexual
we'd just assume it stands for homosexual
LGBTQ.txt
anyway, I'm hesitant to include two spirit as that's a gender identity unrelated to Western queerness.
but now we're off topic
It's a native American thing here in canada
([A-GI-RT-Z]|H[^E])+
Very offtopic
that still hasnt been merged huh
fduck yes
@patent pivot you maaay want to turn off sending status checks to the discord webhook for king arthur now lmfao
Your reminder will arrive on <t:1631241572:F>!
winner
@brisk brook I've commented on bot#1821 but the comment is rather rushed since I'm going to bed so if there's anything you don't understand etc. just lmk.
That sounds great, if you're interested in it go ahead!
heh I just realised I have now referenced one of my projects in a pydis commit-- stuff from modmail is on @radiant merlin now π
inb4 revert
(technically not, because it was a workflow file and King arthur actually isn't running it)
(and was initially pulled from pydis/bot)
but the point still stands π
i might pull out the status embed
meh
11 was related to the isort and black conflicts
which aside from a bug in isort conflicting with black, is pretty much resolved.
out of curosity why
just personal preference, not a huge fan of the artefact stage Β―_(γ)_/Β―
true
it could be moved to lint or build
since like
wait
it could be moved to lint, ig
or we just use the default embeds, lol
we can have it report only on suites, not stages
suites will be just one embed for the ci stage, as opposed to each job
where is the stage defined?
that's the workflow
ah
aight I turned it on for one of my repos, will see if it goes off
since its a 4 stage workflow
I'll do it once I'm done gaming
lol
Lmao
well damn, @patent pivot , I found a problem with my checks anyhow lol
thanks for that info
I'm never turning it on again
need to figure out how many times its changing its statuses lmfao
lol
I didn't push to main.