#dev-contrib
1 messages · Page 163 of 1
Fixed, thanks
Doing that may break another test
I went for```py
mock_member = MockMember(display_name="Bobby Johnson", roles=[MockRole(id=1)])
with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task):
await self.cog_instance.process_event(
reaction=incidents.Signal.ACTIONED.value,
incident=MockMessage(author=mock_member, id=123),
member=mock_member
)```instead
That way it won't break anything else
Yea, that would work
👌
bot#2031 is now up; would appreciate some reviews.
@gritty wind wheres the mention of the revised URL filter 😡 \j
bot#1889
Why do there have to be so many reviewers 🥲
Nooot that I know of
chris i think - oop nvm
nope
I keep having trouble with Poetry on Linux where it's not using wheels even though they're available.
Yesterday it built numpy from source. Today, it's trying (but failing) to build psycopg2-binary
And yet I can successfully install the wheel from PyPI if I just do it manually
help 😦
Actually, it installs fine outside of the venv Poetry creates, but if I try to install it inside the venv, it says that wheel is unsupported on my platform
Hmm, maybe just don't use Linux, if possible? Idk
I can also manually create a venv with python -m venv and then successfully install the wheel
Poetry is just creating some borked venv
what version of poetry are you on?
Latest
Yes that is the latest
alr
Are wheel and setuptools installed on the venv?
Is poetry just missing those out?
And are you in the wheel group
https://github.com/python-poetry/poetry/issues/3591 Suggests disabling the experimental installer
poetry config experimental.new-installer false
and upgrading pip, but that doesn't sound like it would help
Yes, wheel and setuptools are present in the venv it creates
That config didn't help
Maybe I need to recreate the venv
possibly
would also mean numpy won't be in there, now that we removed it
the other suggested fix was to poetry run pip install -U pip
I'm trying to install site deps now
ah
hence psycopg2
of course
It might also be related to me relying on pyenv for Python 3.9, since my system's Python is on 3.10
Even though I have done pyenv local 3.9.9, weirdly Poetry still says
The currently activated Python version 3.10.1 is not supported by the project (3.9.*).
Trying to find and use a compatible version.
Using python3 (3.9.9)
3.10 is definitely not the currently activated Python
I have that problem occasionally, I do poetry use env /path/to/python.exe to create the base venv
then do poetry install
Since 3.10 is the default poetry uses on my system
so I do that for 3.9 projects
Nice
poetry usees it's own config for python paths afaik
not sure how it intacts with pyenv
but I know it doesn't respect windows PATH priority
Well it bugged out cause it detected 3.10 was active, but then claimed it managed to find and use 3.9. And when the venv was active showed 3.9 as the version
I guess I cannot rely on autodetection
Yeah everything installed now. Thanks for the tip
Nice, was a hard one to figure out a while ago
Yeah the auto detection bull shit was a known downside when migrating
We’re usually compatible with latest, and latest is usually the default
So we usually don’t run into problems
hmmmm I have a circular import and not sure how to get rid of it
I guess I can annotate with a string
Move the shared thing to another module
Oh it's for type annotations?
use if typing.TYPE_CHECKING: and put your import in that. I don't remember the exact name of that.
import annotations from future
that did it 👍
either what numerlor said or put the use of it in quotes
yeah quotes was what I did originally
docker-compose.yaml line 28
- .:/app:ro```
It’s a volume on most of our projects so your code changes are loaded into the docker container without needing a full rebuild
What kind of modification would this need in order to use it? https://github.com/python-discord/pixels/blob/d98adad00e1ea99a67a0d024326a53a80de3cb42/pixels/utils/ratelimits.py
It’s supposed to just work with fastapi or starlette
Though there are currently only handlers for Postgres and redis
If you want a different bucket type, you’d have to implement it yourself
I have connections for both of ready
clean_up_tasks: list[typing.Callable]
web_1 | TypeError: 'type' object is not subscriptable
``` I did try running it but it ended up with this
Are you running on python 3.9?
3.9.6, ye
could you double check that?
how are you running it?
docker-compose up --build
What version of Python is in the dockerfile?
^ that version down at the bottom of vscode is independent of the dockerfile
3.9 is for docker
Is this code on github?
Dockerfile line 1
FROM python:3.9.5-slim```
something like this?
You can hack it by changing that type hint to typing.List, but you’d have to modify like half the type hints, and other stuff might break
version: "3.9"
services:
web:
build: .
ports:
- "5001:5001"
redis:
image: "redis:alpine"
That's the docker-compose file.
That docker version
and what's in the Dockerfile
from typing import List as list
FROM python:3.9-alpine
WORKDIR /chatapp
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
EXPOSE 5001
COPY . .
CMD ["python3", "-m", "chatapp"]
that's fine, I have typescript now
Could you change the cmd to list version
hm?
CMD ["python3", "-V"]
sure
afaik the python image installs as python not python3, but I can’t imagine it’ll be different
yeah what chris and scale said before me
Python 3.9.9
Can you do docker-compose up --build
That's what I did
just to make sure you're actually using that version
.
The dockerfile there says 3.8
That's one of the changes I had made
So I imagine it's still using that image.
Can you stop the container
do docker-compose down
it's stopped
then docker-compose up --build
do I change the command back to normal?
Yea
interesting, it started up
let me try the endpoint
this is redis stuff, right? ```
web_1 | return await dependant.call(**values)
web_1 | File "/chatapp/chatapp/backend/ratelimits/limiter.py", line 191, in caller
web_1 | request: fastapi.Request = _kwargs['request']
web_1 | KeyError: 'request'
wdym?
@router.get("/testing")
@UserRedis(
requests=5,
time_unit=10,
cooldown=60,
)
async def _test():
return {
"message": "working"
}
now it seems like the endpoint is not being reached (keeps loading)
I'll debug it a bit and will come back after 👍 . Thx alot for helping 😄
My guess is it might be redis connection, good luck
Thanks for the review on sir-lancebot#988 @brisk brook. You had some great feedback
I've resolved your comments now
I think I found out why it did not work, I seem to have missed this https://github.com/python-discord/pixels/blob/0f89cf231f2533e633daa4abbcfc399476434519/pixels/pixels.py#L86-L90
pixels/pixels.py lines 86 to 90
app.state.redis_pool = await aioredis.create_redis_pool(Connections.REDIS_URL)
Connections.REDIS_FUTURE.set_result(app.state.redis_pool)
app.state.canvas = Canvas(app.state.redis_pool)
await app.state.canvas.sync_cache(await Connections.DB_POOL.acquire())```
Now after a while I have fixed Redis connection stuff (I guess) and what is this? https://github.com/python-discord/pixels/blob/main/pixels/utils/ratelimits.py#L258
pixels/utils/ratelimits.py line 258
user_id: int```
The code runs fine until I reach out for endpoint: https://paste.pythondiscord.com/vajobiluki.sql
Thats from the auth
where we decode the authorization token given in the header, check who it belongs to via the database, and then add the user_id to the state
Since we ratelimit based on the user requesting
So uh... I'm loading the filtered regex patterns from the DB, and it's reading "\b" as the single character, not literally slash and b
Trying to figure out why it's working in prod
wdym
Are you running the main branch?
I'm running the new schema branch
new-filter-schema
Oh that's from our old PR isn't it
I saw the emails haha
lol
So have you checked it is correctly stored in the db using psql or something
nope, my knowledge of psql is nill
yeah
docker-compose exec -it postgres psql -U pysite should open a shell
If my memory is right
Right
didn't work with docker-compose, did with docker
Alright, well
What's the name of the model we want, hmm
SELECT * FROM sitefilter I believe?
I'm really not sure about the table name
It should be pretty obvious to guess if you press tab after typing the from
Don't you want api_filter
Yup
cool I try that
You have some commands starting with some slashes too, but you shouldn't need any here
Well I used \dt to see the table names 😄
Haha
You are now a certified psql user, congratulation
So, what's inside the db?
uuuh a lot of things... it's not letting me use the like operator
lol are the default filters that big
It should be a raw string for that to be the case, no? Oh wait I understand now
Okay sorry I have to handle some problematic irl stuff
Good luck on the troubleshooting
I'd check the serializer first
yeah no worries, thanks for the help
huh. The DB on the main branch contains the same thing
how is it even working in prod then?
Maybe, it's because they're stored like:
("\bgoo+ks*\b", None, False)
instead of:
(r"\bgoo+ks*\b", None, False),?
Well
\b
!int e await ctx.send((await ctx.guild.get_channel(635950537262759947).fetch_message(926214981496766544)).content[0])
\
In [6]: await ctx.send((await ctx.guild.get_channel(635950537262759947).fetch_message(926214981496766544)).content[0])
Out[6]: <Message id=926215255418339398 channel=<TextChannel id=635950537262759947 name='dev-contrib' position=71 nsfw=False news=False category_id=411199786025484308> type=<MessageType.default: 0> author=<Member id=409107086526644234 name='Python' discriminator='4329' bot=True nick=None guild=<Guild id=267624335836053506 name='Python' shard_id=0 chunked=True member_count=292562>> flags=<MessageFlags value=0>>```
Yeah, but aren't you trying to load the regexes from the DB?
If we were to use this: (r"\bgoo+ks*\b", None, False)
It would store them like that: \\b
Right I'm saying it's already escaped though. Also you can't put an r on a variable, it needs to be dynamic
I might have misunderstood the context then. 😄( Was refering to this: https://github.com/python-discord/site/blob/new-filter-schema/pydis_site/apps/api/migrations/0059_populate_filterlists.py)
The DB contains patterns. The bot code in the main branch manages to match them, but the new code doesn't, I'm trying to understand why
Because as far as matching goes I just copied the logic from the existing code
I notice we're using a CharField now for the filter content
Rather than a TextField
in the model that is
Not sure if that's causing the encoding that's breaking this
@cold island not sure if this will help, or if you already saw it
yeah I'm just about to run the bot to try it
rebuilt the DB
Didn't seem to do the trick
I'll try running the main branch and see how things look like there
If it’s in the sample filters inserted into the DB
Those aren’t in prod in the first place
oh right
oh.
Ok
Sorry @molten perch you were probably right
I'll try changing migration 59 now
I was just convinced that it was working in the old code, but it actually doesn't
Oh, alright! 😅
Alright thanks for the help everyone
Should I create a new migration for dev purposes to fix 59, or do I edit the existing one?
I'd just fix the existing one
Also, good news: there's a functioning regex filter in the new system. Bad news: it's alerting me for the same message indefinitely 🙂 baby steps
lol
Reasoning for this is that most dev systems don't have long-lasting databases anyway, so the migrations will be re-ran eventually
and the people that do keep a long lasting database, they can just add a new filter
I don't think it's worth adding an extra step in the migration process
hmmm I don't see how the migration didn't run in prod though
did we just replace those filters?
It ran once like ages ago
Yeah they probably got replaced since
iirc that migration was added when the table got lost for some reason
Like two years ago or something
Yea, it was added over a year ago
🚤
Haha, managed to approve it in the end 😄
lol
Lmao
So pixels need OAuth2 URL, and is that URL the bots OAuth2 URL?
Yes, we used Discord OAuth as part of the access token creation flow
so that we could get the user's userID
I think I'm now getting how that system works, slowly but surely
You can find it under the OAuth2 section of the Discord API portal for your application
yup
Great! I'll try that tomorrow because it's nearly 1am. Thx alot 😄
No problem!
Is something brewing with pixels?
mostly just wanted to deal with the PRs and issues
I'm thinking of making a private fork, so our plans for next year aren't spoiled
Lmfao
“Private fork” :(
Not a thing, but we can push the code to another repo, and push it back to pixels afterwards
Inb4 he just opens a security advisory for that
We could make pixels private again if we aren’t planning on doing it for too long
I didn't want to do that since a few people reference the code there
such as the ratelimiting and auth
Making a private copy is probably the easiest
Yea
probably just make an empty private repo and maybe even set the upstream to the public one
Nah, just locally to pull changes
Haha true
Speaking of, we do need to sit down and start scoping out pixels v2. I did put it later in the events calendar, but that was only to ensure we had enough dev time for it
Yea, we should try and figure out how we're gonna mix it up
there's a bunch of good ideas in that notion page
Can confirm the Notion page has awesome ideas
It's already there
Was one of the first things I did when making the project public
botcore is not
oh it was added 10 days ago
is this the module that auth uses? https://github.com/python-discord/pixels/blob/98a91594797d0229542f968104137e9902677351/pixels/utils/auth.py#L8
pixels/utils/auth.py line 8
from jose import JWTError, jwt```
!pypi jose
pyproject.toml line 21
python-jose = {extras = ["cryptography"], version = "^3.3.0"}```
That file includes the other deps that pixels uses.
ooh I see
I have now nearly everything set up I guess, but how do I access the callback endpoint? It was the endpoint I receive the token from, right? https://paste.pythondiscord.com/xezedilase.sql
You set it in the discord dashboard
For dev purposes it might be something like localhost:port/callback
I have this set up from there
Could you print out what the app got from discord when you called callback
wdym?
:incoming_envelope: :ok_hand: applied mute to @clever wraith until <t:1640953409:f> (9 minutes and 59 seconds) (reason: burst rule: sent 8 messages in 10s).
This function is the one raising the error
Try printing out the content of the request from that function
The body to be more specific
Actually discord puts it in the query params
So
Request.query_params
sec
I am going to guess the OAuth2 url you are using doesn't have the identify scope
That's your issue then 🙂
oh
The easiest thing to do is to go into the URL generator section and do it from there
and not use any of them?
.
I had the local host url in there 🤦
I'd suggest reading the readme
I did but I misunderstood which url it meant
I think it worked
It gave me code=CPj3FXbLGHmkun521pa5ZO0vAHo5D5
I… don’t think you should share that code lol
Technically you can’t do anything without your backend auth but
No reason to share it lol
Anyways it looks right
but after it redirected me to /callback?code=<the_token> it threw me a error
What’s the error
I think it's about db pool: https://paste.pythondiscord.com/uwusuhekoh.sql
pixels/endpoints/authorization.py line 66
token, _ = await auth.reset_user_token(request.state.db_conn, user["id"])```
pixels/pixels.py lines 100 to 110
@app.middleware("http")
async def setup_data(request: Request, callnext: t.Callable) -> Response:
"""Get a connection from the pool and a canvas reference for this request."""
async with Connections.DB_POOL.acquire() as connection:
request.state.db_conn = connection
request.state.canvas = app.state.canvas
request.state.redis_pool = app.state.redis_pool
response = await callnext(request)
request.state.db_conn = None
request.state.canvas = None
return response```
This is where our state vars are set

then I can re create it with my own db connection without needing to mess up with more pixels code.
uh and where is the database tables created in at? I think I have to set them up as well
that will be a bit painful but I think I can manage
if I just find a few SQL statements
Make sure to do something similar to what is in the code about, with the async context manager in the middleware
that way the connection is freed up after the request is done
I could use this ```py
async def create_db_pool():
"""
creates a database pool
---
Arguments -> None
"""
bot.db = await asyncpg.create_pool(dsn=URL)
bot.loop.run_until_complete(create_db_pool())
That will create the pool sure.
I was referring to actually getting a connection from that pool in the middleware
oh
Otherwise you'll use up all the connections
what does that mean?
postgres by default only has 100 available connections
asyncpg.create_pool() creates a connection to the database, and grabs 10 connections
if you don't use the context manager, or manually close connections when you're done, then the pool will run out of connections
since they'll be dangling
and middleware is used to resets the those connections?
this is the middleware
You can see we have the async with Connections.DB_POOL.acquire() as connection: line
this means that all of the code within that context manager has a connection
once code leaves the context manager, the connection is freed
now I got it, thx again 😄
response = await callnext(request) is how you actually call the request from within the middleware
human ORM moment
@patent pivot sorry for the ping but if you made the db tables, do you happen to have the data types for them because I can't figure them out.
pretty sure we had the SQL in a file in the pixels repo
oh
Out of curiosity, did it ever happen that the bot creates the same thread twice in the nomination voting channel?
And yeah, pixels has its init SQL in its repo, with my fancy database trigger 
Not yet
Hmm, we're having this problem at Quilt, and it just happened to some user accounts, so I am wondering if it is an API bug
I have not set up full pixels setup so how could I run those sql statements in init.sql. I tried to run .execute(<sql here>) but it did not like that syntax
At least this caused some error (currently can't access that traceback) ```sql
user_id int8 NOT NULL,
I have been updating the purgeban command, so it uses our clean tool, rather than discord's native purge, to retain context, however I've ran into some very odd behaviour.
I have updated purgeban to include this code ```py
infraction = await self.apply_ban(ctx, user, reason, expires_at=duration)
log.info(f"From apply_ban return: {infraction}")
`self.apply_ban()` then has this code at the end ```py
log.info(f"Inside apply_ban: {infraction}")
return infraction
So even though I'm returning directly after the log, and then logging the return value, this is what the log appears like:
bot_1 | 2021-12-31 17:02:15 | bot.exts.moderation.infraction.infractions | INFO | Inside apply_ban: {'id': 6, 'inserted_at': '2021-12-31T17:02:14.694643Z', 'expires_at': None, 'active': True, 'user': 825398857218129920, 'actor': 126811506632294400, 'type': 'ban', 'reason': None, 'hidden': False, 'dm_sent': False, 'purge': ''}
bot_1 | 2021-12-31 17:02:15 | bot.exts.moderation.infraction.infractions | INFO | From apply_ban return: None
So somehow it's getting set to None
we ran them directly on the database in prod, and used a docker-compose volume in dev. However, I think this is off topic from this channel now, as it's no longer about one of our projects directly, but rather how to change our code to work in your project, so would be better served by #databases or a help channel.
If someone has any ideas please let me know! In the meantime I'm gonna work on getting the bot running locally so I can attach a debugger
Does the function have a decorator?
Yea, it's the respect_role_hierarchy deco
ah lol
await func(*args, **kwargs)
need to return this

Oh ye, my bad 😅
How strange, we have the mods channel in the config yml, but not in constants.py
guess it's one less line diff for this PR 😛
This is why we don’t hardcode a ton of nonsense into two separate files
🤡
@fallen patrol i don't quite follow your comment.
I'm only importing for type checking, so surely that doesn't apply?
well, I think I marked that in the linked comment
oh, that was in the next one
tldr if you're using TYPE_CHECKING you're fine
Which I am.
yeah i didn't look at the code
I forgot to add it to the announcement lol
Oh wait no, I did
At least half of what I was gonna add
21 PR opened on the bot repo in the whole 2021 year sounds very wrong
its not total opened in the whole year, its total open rn
@gritty wind you are a very misleading person
even more so than I had just presumed
What
I hoped that’d be implied since the closed is bigger than the open
This page is so confusing haha
It was made in like 10 mins during a staff meeting ¯_(ツ)_/¯
also closed is actually pulls merged or pulls closed with unmerged commits
We don’t have many closed PRs that aren’t merged, so I just did it lazily and ignored them
Except on forms
What
That’s really fucked lol
Can we have a proper stats page haha
forms-frontend#298
bruh
I volunteer for making one tomorrow
Tbh idrc, go for it lol
we should write a python client that will request and get all of this info
and output it as an csv
It was a planned project for this year
which is what I thought scale was doing but no, he was just searching every repo smh mh smh
But we didn’t have the bandwidth for it
lol rip ledger
Maybe next year
well why didn't you tell me I would have made it in 3 days /srs
I'll proooooobably make a simple script for it
But you can also write some smart queries in github to search across multiple repos. I have one for pulling recently closed things for the weekly staff meeting agenda
lol I've already worked with the api
haven't worked with the graphql client yet
which would prooobably be better for this
I'd use GraphQL for this for sure
We have one pinned in #dev-core but it wouldve been the same amount of work
I wanted the stats per project
We made some auto-generated graphql queries for the code jam management stuff last year, that was pretty cool
It is really cool how you can query a ton of data at once
And not require a stupid amount of requests to do so
Could you share said query @gritty wind?
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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
It’s more relevant to getting PRs from contribs, but you can strip out that part
Contributor statistics
query ($user: String!) {
user(login: $user) {
login
contributionsCollection(organizationID: "MDEyOk9yZ2FuaXphdGlvbjM2MTAxNDkz") {
pullRequestReviewContributions(first: 1) {
totalCount
}
pullRequestContributions(first: 1) {
totalCount
}
totalCommitContributions
}
}
}
Paste this into https://docs.github.com/en/graphql/overview/explorer and then enter an object into the variables like:
{
"user": "courtesy of jb3"
}
Another year another 365 days without ledger😔
listen, if you want ledger, I can make ledger happen
I think if we spec it out ledger could be a good idea
It’s just it was fairly loosely defined
Let’s defined the questions rather than the data, what do we want ledger to answer, etc. instead of just “let’s download arbitrary attributes of all pull requests ever in a table”
devops is migrating from Kubernetes in the new year though so for my involvement it may be pushed a month or two down the line
Some early 🚰 there
early potable water
I can definitely define some questions if that's what you're after
Is it planned on throwing data into the stats infra?
Postgres for persistence
But still go through the normal staff infra?
hey @thorny obsidian, given that the aoc role goes until the end of the month, can we update the aoc commands to be supported until the end of the month?
the channels still exist, including #aoc-bot-commands.
assume the typo is for stats infra, in which case yeah we’ll be querying it from grafana or metabase, all depends on what sort of questions we want to answer
Ansibling
I'll have a paper on it soon
most stuff remains the same
still containers, running in podman instead of docker, still Debian based, but obviously embracing that more
What's up with lance?
nothing, we're restarting to swap some secrets to try and get AoC commands working
...
Sorry, an unexpected error occurred. Please let us know!
AttributeError: 'TagIdentifier' object has no attribute 'qualified_name'
!src paste
Sorry, an unexpected error occurred. Please let us know!
AttributeError: 'TagIdentifier' object has no attribute 'qualified_name'
!src command for tag doesnt work but it used to. is it an expected behavior?
there's an issue for that which I've suggested a fix but its not approved yet
still waiting
@patent pivot so from what it sounds like you're working on this already?
Oh that's us
Yeah, we are part of the same system
The commit is on main but it isn't released yet
The task itself links to the correct PR.
Alright
What would cause the sentry issue you speak of?
@fallen patrol do you have a traceback from that test?
I'm intrigued what would raise the error.
What is the traceback
2022-01-01 10:00:48 | bot.exts.events.advent_of_code._helpers | ERROR | Unexpected response
404while fetching leaderboard968271
no traceback
What is AOC_YEAR set to?
so its expected to update that every year?
Since we have it set to 2021, it would still pull last year's
;-;
well then
will fix in pull as soon as my other aoc pulls are merged
will make it default to the last one until november and then use the current year.
Sure, could you open an issue for it to describe your plans
its just a constants.py edit
i'll do it after my other aoc pulls are reviewed/merged
I was kind of expecting to see them in prod before aoc ended.
sir-lancebot#969
sir-lancebot#966
sir-lancebot#967
if (
current_date.month not in (Month.NOVEMBER, Month.DECEMBER) and current_date.year != AocConfig.year or
current_date.month != Month.JANUARY and current_date.year != AocConfig.year + 1
): ```that's such a big if haha
lol yup
I was going to do a not all, but then it was a large negative all, which can be hard to read
so this was better
Dates are fun 🤡
I'm trying to run the bot project via docker-compose run bot and I keep getting a crash error saying the auth credentials weren't provided for the api?py Traceback (most recent call last): File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/bot/bot/__main__.py", line 13, in <module> bot.instance.run(constants.Bot.token) File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 663, in run return future.result() File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 642, in runner await self.start(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 605, in start await self.login(token) File "/bot/bot/bot.py", line 256, in login await self.cache_filter_list_data() File "/bot/bot/bot.py", line 87, in cache_filter_list_data full_cache = await self.api_client.get('bot/filter-lists') File "/bot/bot/api.py", line 81, in get return await self.request("GET", endpoint, raise_for_status=raise_for_status, **kwargs) File "/bot/bot/api.py", line 76, in request await self.maybe_raise_for_status(resp, raise_for_status) File "/bot/bot/api.py", line 68, in maybe_raise_for_status raise ResponseCodeError(response=response, response_json=response_json) bot.api.ResponseCodeError: Status: 401 Response: {'detail': 'Authentication credentials were not provided.'}
Are you on main, or do you have changes?
I have changes but it's literally just adding a footer to an embed
(bot#2034)
I think it's because I changed all of my env settings etc. to use my own local instance of site whilst I was implementing bot#1951
Ah, then you'll likely need to change them back.
Have you changed the docker-compose?
or do you have an override present?
I honestly can't remember
I don't need any changes in them so I can just "reset to defaults" and presumably things will work
There isn't
I had changed the docker-compose.yml but I think I've reverted those changes now
I'd made all sorts of changes to make #1951 work and now I need to revert them all but I don't know what it was before 
Just reset to main
It doesn't change files in the .gitignore though
docker-compose.yml isn't in the gitignore
bot_1 | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:8000 ssl:default [Connect call failed ('127.0.0.1', 8000)]
bot_1 | 2022-01-01 17:04:59 | bot | CRITICAL | Could not connect to site API. Is it running?```
false
fakeredis makes it so that asyncrediscache only uses memory, rather than call out to actual redis
Wait, it literally says that on the page lol 🤦
So when I've done the top steps, re-build?
or when dockerfile changes
Nice
@fallen patrol out of interest, have you made any progress with bot#1924 / bot#2020?
Can I claim sir-lancebot#995?
I see this is just adding the missing enums right?
Yep
I was gonna do it tomorrow if no one had gotten around to it
It's adding the missing enums for both AgeRatingCategories and AgeRatings If I remember correctly
I assume sentry is some sort of app for logging errors?
Yeah, basically
Turning```py
class AgeRatingCategories(IntEnum):
"""IGDB API Age Rating categories IDs."""
ESRB = 1
PEGI = 2
intopy
class AgeRatingCategories(IntEnum):
"""IGDB API Age Rating categories IDs."""
ESRB = 1
PEGI = 2
CERO = 3
USK = 4
GRAC = 5
CLASS_IND = 6
ACB = 7```and then doing the same for the `AgeRatings` class
And I guess looking for any other missing enums
got it
I need your GitHub so I can assign you @summer garden
Right yeah, true
👍 I did just there
Feel free to @ me here and request a review when it's done @summer garden
https://github.com/python-discord/sir-lancebot/pull/997 If you don't mind :)
Could you add Closes SIR-LANCEBOT-7H to the PR description too?
The sentry integration isn't smart enough yet to follow the chain
Just the text? Not the link in the issue?
Yea, just that text will be enough
not recently, no
Done 👍
Has been merged
sir-lancebot#778 really needs reviews
And sir-lancebot#901 (core-dev)!
awesome
@austere hornet when you get a chance to implement my feedback, could you also update the branch to main? GitHub UI doesn't have the option for me.
Did you allow edits from maintainers?
No I didn't, but I just did
Cool, I can update the branch now
I'll wait until after your change though, so I can test it after merging main
@vale ibex I have implemented your feedback on sir-lancebot#901
hm
this is probably a dumb question because i started django like yesterday
but
isnt https://github.com/python-discord/site/tree/main/pydis_site/apps/admin unused
unlike the other apps, there is no mention of pydis_site.apps.admin in https://github.com/python-discord/site/blob/main/pydis_site/urls.py
pydis_site/urls.py line 7
path('admin/', admin.site.urls),```
uses django.contrib.admin
Yes that was a typo heh
@placid ermine admin is a special built-in app
If you navigate to /admin you'll see it
yeah but that's django.contrib.admin, right? not pydis_site.apps.admin
Basically those are auto generated html views for models
Oh
iirc that's how you configure admin
Although that's pretty pointless, yeah
CC @last patio
It is served correctly
But we don’t use it
I don’t think anyone besides Joe understands the log in mechanism
It used to be tied to github OAuth
Could someone tell me how many autobans have been issued so far please?
A metabase question with infractions starting with Your account has been used to send links to a phishing website. over time would be chiefkiss 
Yes, but it’s very difficult to actually get in now, and the stats are mostly in meta base and grafana lol
Yep
I mean, there isn't any credentials by default even
Someone has to manually insert them
Fwiw that wouldn't be accurate because we manually ban with that message too. Ig you'd fix that by setting the infractor to @stable mountain
I didn't exactly remember the difference between the two messages
I remember there is one
Hmm
Ahh, Your account has been used to send links to a phishing website. You have been automatically banned.
The start is different isn't it
"...You have been banned..." vs "...You have been automatically banned..."
You know what would even better, use the first criteria and do a filter on actor__bot
Do you want the autobans or the manual one
So as long as you include the "automatically" it'd be fine
that's what I said above
I mean so you have two curves
But I mainly just want the number of automatic one please good sir
lol it sure is interesting
To be fair it is much better than mobile grafana
At least metabase tried
409107086526644234
Huh
Grafana doesn't store bans from the bot from what I can tell
It is also putting automutes so that doesn't make any sense
What, we’re using meta base
Grafana does store them anyway
Right, ignore then
The results and the ID are there if I don’t filter for them
Doesn't allow you to filter by the bot then
But then
Are you using a numerical check or something
There is a quite bad bug in metabase if you try to represent the ID by a number because JS will truncate it
No it’s just pasting the ID incorrectly
Because of the truncation
But you can’t make it a string on mobile
Really, that's cool
@fallen patrol fyi have left another review & two comments which should've been part of the review on bot#2017
:x: Please use #aoc-bot-commands for aoc commands instead.
Well I'm not liked by the bot but it will say "in one year" for at least a whole month if I understand I it correctly
What exactly is the issue?
Or is this something on a PR?
Anyway, the "in one year" is because Discord rounds their timestamps
the fuck
I also see 1 Dec 2022 on mobile
!raw 897932607545823342-927158962997059674
You are not allowed to use that command here. Please use the #bot-commands channel instead.
I guess Discord™️ 🤷
So this thing ^^ never got solved in the discussion here a few weeks ago. Should I create an issue on lance?
There might not be much that’ll come out of an issue
If you can get down a solid reproduction, go for it
Ok cool. What do you mean by a "solid reproduction"?
a set of steps allowing you to reproduce the bug
.wa 1-(tanh(x))^2
I mean, there should just be more logging in that command
the answer should be logged if it didn't 200
Feel free to PR some non-spammy logs directly
why would you migrate from notion to the site? the notion page is public
That would make it available for anyone to update, not just staff
guess it is pretty much a copy paste anyway
It's also for better consistency. It would be odd if all our projects except Forms was on site. There's also no strong reason to keep it on Notion if we're opening it up to outside contributors
I have a question with unittest.
I have this test: ```py
@patch("bot.converters.Age")
async def test_foo(self, mocked_age_converter):
within the test I do ```py
mocked_age_converter.return_value.convert = AsyncMock(return_value="foo")
await self.cog.some_func_that_calls_age_converter()
Where the func I'm awaiting calls the age convertor with await Age().convert(ctx, "1h")
I was under the impression that my patch, an subsequent update of the return value would cause the age convert within the cog function to return foo.
However, my assert_awaited_once_with a little further down shows it's still using the default return values, rather than my patched ones. Am I doing something wrong?
@gritty wind there, fixed
I’m not sure what you’ve done
It looks a lot like the notion table with “closed PRs vs merged PRs” stuff, just without the totals lol
but the counts aren't wrong/misleading :P
I still don't know how you ended up with 21 open PRs on bot
It’s off by like a fraction even on the biggest projects lmao
Because they are 21
peepoLeave
This is exactly my data that’s what I’m saying
Could you try sequentially patching it? Set the return value to an (a)sync mock and set its convert to another ashnc fund
mocked_age_converter.return_value.convert = AsyncMock(return_value="foo")
mocked_age_converter here is the converter class, no? I don't think you need the return_value here
also you used the since parameter to generate the notion page, right?
Because if so your count isn't right but mine is
Because since is created or updated since
Yea, it is. I have mocked_age_converter.return_value there because within some_func_that_calls_age_converter it instantiates the converter class again, so I want to change the convert function on the mocked_age_converter.return_value, which is a MagicMock
At least, that's what I got from https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch
but clearly I'm missing something 😅
fwiw mocked_age_converter.convert = AsyncMock(return_value="foo") doesn't work either
This is the full code btw https://paste.pythondiscord.com/qofenivuco.py
Where line 48 is where the converter class from line 76 down is instantiated
The reason I need to mock this is because I need to specify an arg for first_limit when calling assert_awaited_once_with, which is made hard by the converter basing it from datetime.now()
ah, unless I got it wrong, you have to patch Age in the infractions module, since I assume you're importing like this: from bot.converters import Age
ref: https://docs.python.org/3/library/unittest.mock.html#where-to-patch
Ahhhhhhhh
Changing to @patch("bot.exts.moderation.infraction.infractions.Age") and mocked_age_converter.return_value.convert = AsyncMock(return_value="foo") works now
that's where I was going wrong 😅
Thanks 😄
I should filter out bots so forms-frontend doesn't get like 300 PRs haha
Maybe add commits too while I'm at it
@vale ibex Could you please #changelog this?
I used updated:>2021-1-1
Btw, I’ve gotta say before you put any more effort in
Don’t do it unless you enjoy doing it
Besides a few nit pickers most people don’t care
I'm doing that for Quilt at the same time
Cool, tests are done for bot#2033
I've added a few more stats that I've found interesting, and removed bot contributions https://gist.github.com/Akarys42/cf88a85cfa8bd691bc8928546fcd8129#file-python_discord-md
I find the mean commits per PR and mean diff size stats quite interesting
do you think it would be worth adding to the announcement?
also fyi Xav reviewed madlib, not ak
Can we change the emojis on @dusky shore's issue regex thing to match GitHub's recent change to closed issues?
I.e. issues that were closed by a merged PR should show a purple tick, not the red
bot#2034 as an example
In fact, it looks like all closed issues have the purple tick currently
bot#1801 was closed without a PR but still shows as purple on GH
Would we be able to add that logic ourselves?
Looks like github have just replaced the red icon with the purple one, we can do the same
What logic?
Purple if it has a linked PR, otherwise red
So two separate issues? Or one issue with two PRs?
Do you happen to have the purple version? I can upload that to the emoji server
Adding that custom logic should be an issue, so we can discuss whether we want it or not.
We can just change the icon now though
Errr not sure how to get it
Ahh, no worries, I left a comment in the repo last time I did it
# These icons are from Github's repo https://github.com/primer/octicons/
I'll grab it now
The raw thing doesn't seem to have the colour
this is the image then (uploaded as a .png)
@vale ibex would the PR just be```diff
bot/constants.py, within the Emojis class
-
issue_closed = ":IssueClosed:"
-
issue_closed = "<:IssueClosed:NEW_ID>"```?
That's not what it currently is
It's currently issue_closed = ""
you'll just need to update the id
when I upload the new emoji
Yep my bad
Theoretically you can just edit the emoji in the server?
Rather than uploading a new one?
Then no PR is needed?
not sure you can do that
example for what lol?
#dev-log 👀
T’was a joke, you can’t actually see me typing
Unless
Hm, no cameras here
@vocal wolf ticking things in my PR 

Approved by the way
I don't know if it has been mentioned already but Xavier reviewed the madlib PR, not me
twas not me
!remind 6H pitch BOT_ENABLED_EXTENSIONS for Lance. Won't have to load all 58+ cogs every time as a developer when writing a new cog.
Your reminder will arrive on <t:1641225243:F>!
the reminder is to pitch it in 6 hours smh so
!remind 6H answer scale
Your reminder will arrive on <t:1641226032:F>!
I saw your other message lol
If it’s slash commands, that’s the wrong way to go about it
The interactions between various components is still important, it’s wiser to write your registration system to compare the required commands vs the changed commands and only send off the ones that have changed
I actually wrote basically that when I wrote a small interactions client
it's not smh
sir-lancebot#999 is up; would appreciate feedback on the issue
@vale ibex ^
Here's your reminder: pitch BOT_ENABLED_EXTENSIONS for Lance. Won't have to load all 58+ cogs every time as a developer when writing a new cog.
[Jump back to when you created the reminder](#dev-contrib message)
i got @stable mountain working 
props to @tawdry vapor (i think?) or whoever wrote the contributing guides. made it painless for even a noob like me
is there a particular reason not to
Can't take credit for it all. I improved on someone else's work, but I forget who started it. Zig also significantly revised the bot guide.
here's what I implemented on my own bot: https://github.com/onerandomusername/monty-python/commit/79cd5cc4b34718dc1bcad2035398dd600c822cbf
oh
87+ cogs, on lance, and on each message there's 6 or 7 debug logs that a listener was blocked from firing in the wrong month
additionally, some of them make initial requests to apis (github cog), and even others error because xxx config variable was not set up, so there's one or two tracebacks every load
The debug logs I've seen have really only been the Candy Collection and Spooky React. It's very specific logs
I don't think there are that many of them for it to be an issue
If it's an issue we could just reduce the logging on those cogs
What are the tracebacks you are referring to? I've see some warning/error logs if a cog isn't loaded, but I've never encountered a traceback
those should be fixed.
for instance, for one command this is the debug log:
But it's clear it's only 1 cog producing those debug messages.
I get a traceback if I don't properly configure non-critical vars, like the trash can or not setting the Advent of Code role id
Yea, that's not really linked to loading specific cogs though
that's just if the paginator is ever called
We could change the default emoji though, and have prod override with an env var
That's just an example of the general errors, I've only encountered the tracebacks if I don't properly configure stuff. It happens with AoC stuff as well (like not configuring the notifier AoC role id)
We should do similar in the AoC cog as we do for other cogs then, check if required env vars are set, if not don't load the cog
fixing the cause, rather than symptoms
tbh I'm okay with an occasional traceback because I didn't fully set stuff up.
sounds like a lot better idea than what I proposed lol
like, during my PR review sprint I only got 2 tracebacks and that was me not setting up the AoC notifier role id and being too lazy to change the trashcan emoji
I don't have anything against your idea, I just feel like it'll be something barely anyone uses
The biggest improvement that could be made is decreasing the logging done in the CandyCollection and SpookyReacts cog
which isn't to say we shouldn't do it, but if it's trying to fix a problem, then there are other options that hiding the issue by not loading the cog
yeahh
in_month guards could easily be trace logs imo
I do think the idea does introduce some fundamental problems for integration
Buttttt if no one is arguing for it anymore /shrug
since I implemented it elsewhere I'd still like to hear this 
I may make a PR to introduce this to the cogs I mentioned above if that's alright
it should just be changing this line https://github.com/python-discord/sir-lancebot/blob/main/bot/utils/decorators.py#L83
bot/utils/decorators.py line 83
log.debug(f"Guarded {listener.__qualname__} from invoking in {current_month!s}")```
rather than having to do things in each cog
When you have everything loaded, you’re getting closer to prod environment, and are ultimately more likely to catch errors that stem from things that are unrelated to the code you’re modifying. For instance, naming collisions, change of a function used elsewhere, one feature firing off something unrelated from a different cog, etc
While unloading cogs doesn’t directly cause it, it doesn’t really hurt to have all cogs loaded
so the other two changes possibly suggested are default trashcan (maybe 🗑️) and also blocking the aoc cog from loading if not everything is configured
Yea those are the two other things I mentioned
gotcha, ty
tbh I'd rather not block loading of the AoC cog because the notifier role isn't set up. The traceback occurs once and would allow faster testing of AoC features for me
Not setting the AoC notifier role results in a traceback. I feel like there should be an error or warning log if not present instead. What do you think?
I don’t know the ins and outs of the aoc system, but shouldn’t you set the role either way
yeah, that sounds fine to me
it's not used for anything but the notifier
i'll write up an issue sometime
Hey @vale ibex and @fervent sage regarding sir-lancebot#710, could I take it? I've noticed it's been inactive for a while
Sorry was gonna reply earlier but then we drove out of 4g signal, you're welcome to take that over
Dw about it lol, thanks
On a road trip?
@vale ibex I'll push soon I'm just gonna go for a walk
alright, pushed
oh hey, I see cool stats on that computer
sir lance PRs are much more chonky on average than I thought
Hi :D
Would it be a good idea to add a tag which explains why when someone uses pycharm, and runs into problem when they try to install packages outside of the Pychamr's venv, and its not found when they run their script
That would be good, but maybe just explain how the venv thing works in general
Virtual Environments
Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.
To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)
Then, to activate the new virtual environment:
Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate
Packages can then be installed to the virtual environment using pip, as normal.
For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.
Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.
Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Maybe a tag like !venv-packages
is this problem only present for pycharm users? i guess more prevalent bc of the way pycharm automatically creates a venv?
i'm guessing you want a tag that you can use to assist someone that's installed packages outside the intended location. how does a help session like this typically go, and what kind of information or instructions do you envision this tag having?
It’s been suggested before, but explaining this concept to the people who’ll benefit the most of it is difficult in such a limited format
i imagine there's a bit of troubleshooting that always has to be done before you can be sure of the problem & help. dunno if it would work well in a tag
yeah, it is
Theres a lot of people who end up getting confused by it
hm, yeah thats fair
bot#1828 is a sort of relevant issue
Well, not that relevant, although it all links together
There's so many different setups and ways of doing things and gotchas that im not really sure what the right setup if tags/guides would be
i'd suggest that as you help & troubleshoot these issues note them and see how a tag could help you and in what scenarios. that will help solidify a possible idea/proposal
or like wookie said it might be too much variance to put all in one tag
I think it may be worth having a short tag explaining to use the command prompt in PyCharm itself or the Settings ->Project->Project Name->Interpreter menu method. I've helped debug this so many times I've memorized the steps in PyCharm even though I don't use PyCharm.
It's a problem that really only heavily affects PyCharm because of its automatic venv creation
Yeah that seems fair
A lot of people flock to it as their first editor, since its sort of the poster python IDE
I'm confused, how do I make a request to endpoints that need authentication, it's telling me to make post request to endpoint which did not work
I passed the headers etc as in the example
I think we disabled pixels didn’t we
I'm setting only some parts of it, ratelimits to be exact (and authentication)
It seems like the auth system has caused you more trouble than it’s worth for you
sir-lancebot#910 could use a coredev review. It's for an event I'd like to run in January that I'm going to trial run maybe this weekend with staff
Can you show your request
Sure when I get back to laptop ~ 5mins
i'll take a look!
thank you!
token = SECRET
headers = {"Authorization": f"Bearer {token}"}
r = requests.post("http://127.0.0.1:5001/authenticate", headers=headers)
data = r.content
print(data)
I did try http://127.0.0.1:5001/authenticate?body=token as well
I’m not familiar with passing the body like that, afaik that’s just a url parameter