#dev-contrib
1 messages · Page 103 of 1
Tells the linter what type the object will be
or you could just do from typing import List and it'd be pretty much same lol
Riiight, I see
Nah this looks cleaner
yes
!d typing
It tells your IDE what the return type of the function is
New in version 3.5.
Source code: Lib/typing.py
Note
The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.
This module provides runtime support for type hints as specified by PEP 484, PEP 526, PEP 544, PEP 586, PEP 589, and PEP 591. The most fundamental support consists of the types Any, Union, Tuple, Callable, TypeVar, and Generic. For full specification please see PEP 484. For a simplified introduction to type hints see PEP 483.
The function below takes and returns a string and is annotated as follows...
I mean lowercase looks better
Typing is useless during runtime, except in specific cases
Like d.py cases, where it chooses to analyze the signature for some god forsaken reason
In 3.10 it's completely ignored until you call get_type_hints or something
pydantic
d,py makes a really bad use case of typing haha
its actually becoming increasing more important as argument validation
It is a bit more reasonable with the introduction of Annotated
It hurts when I see people doing x: str = None
Yikes
👀
converters*
Yeah, that’s the real issue
I was about to say that decorators are good 😄
lol, brain fart
Type hinting to functions are the worst
even pygen reminds me of latex pain now 😔
@green oriole migrated the command to a new file, and removed unnecessary imports
Currently looking at
import pathlib
import resource
import signal
import sys
import types
import typing
from functools import partial
from io import BytesIO
import matplotlib.pyplot as plt```
still need 400mb though
any ideas why
Hmm
let me test that
disclaimer: I'm not actually counting, I'm just seeing the minimum needed to not get an error
Ok, if I remove nothing except the call to the render
I can go down as low as 0.0001mb
probably lower
I haven't tested
Ok, new idea
I'll also use matplotlib.Figure
Sure, the 0.0001 figure was everything other than the render call
ask matplotlib lol
it barely crossed 200mb without changes for me
iirc matplotlib uses a gui backend for every plot
so I'm not surprised on the memory reqs
plt.savefig(rendered_image, bbox_inches="tight", dpi=600)
everything before this line
that line spikes about 42mb for me
I don't remember which rendering backend is the lowest in mem usage... You can specify different ones though
You could try matplotilb.use('agg')
jumping up to 100, it still fails
Interesting
and I don't think we'll give one command even 100mb in prod
using agg, it'll remove the need to teardown and gui objects
is this before or after creating it
before
ok, still nothing on 10mb
jumping to 100
still a no
why is savefig taking so much ram
and what can we do about it
ok better question, what does it actually do
we write to file after that
Can you pipe it to stdout?
pipe what?
yeah, but we never get past the savefig
so my question is what does that do
Documentation says it "saves the figure"
Wow
so... what does the writing to file do
what a documentation
600 dpi is enormous dear god
32 is still too high for 100mb
Looking at some backend source code, savefig triggers the render (?)
i- what is the image size?
I wonder if it's because of windows
I just dropped to 32dpi
no other changes
I'll deploy this on my server
There is no image size setting?
matplotlib.use("agg")
fig = plt.figure()
rendered_image = BytesIO()
fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top")
plt.savefig(rendered_image, bbox_inches="tight", dpi=32)
rendered_image.seek(0)
with open(filepath, "wb") as f:
f.write(rendered_image.getbuffer())
entire code right now
it fits to the text size
and the font size is set in rcParams.update
i think i set it to 16
plt.figure() isn't reference counted properly apparently, that's why I switched to figure.Figure
that still has the same problem
it takes too much mem to save
even for really short inputs
i don't think the input size affects it much at all
Yeah it shouldn’t
it was definitely enough to cause the initial memory trips that caused this issue to be raised in the first place
matplotlib.use("tk")?
agg is the raw backend
not sure how much better tk would be
worth trying at least though 
'tk' is not a valid value for backend; supported values are ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']
take your pick lol
TkAgg?
TkAgg probably
that's not happy with 100mb either, but on 500:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/bot/bot/exts/evergreen/latex.py", line 105, in latex
raise Exception(process.stdout.read().decode())
Exception: libtk8.6.so: cannot open shared object file: No such file or directory
it's not writing the file 🤷♂️
or not writing it correctly
looks like it happens when tkinter is not installed
Yeah
Although
It is interesting
Because it is failing before the backend is initialized
alright, tested on a clean linux install
still same prob with 100mb
bumping it higher is fine
(note: I've jumped back to 600dpi)
with just the command and without the dpy boilerplate the mem usage rarely jumps over 80mb for me /shrug
with the gc.collects that is
So the library is doing something before initializing the backend that requires that much memory
Is it because it is a forked process
possibly
Let's see
that doesn't explain the remaining 300mb but even then
half of that is from the memory profiler
How do you create the new process again?
its 45MB for me then, discounting for the memory profiler
i have absolutely no idea why you're needing something like 400mb
Hmmmm it seems to indeed be sharing the same resources as the main process
one sec, going to push the current changes too
Can you try to run the generation script directly, not through the bot?
¯\_(ツ)_/¯
I'm supposed to profile only render right
Well, try profiling it from the subprocess, instead of on it's own
that way we can see where the extra size is coming from
and to confirm: running the render on its own does in fact use more than 100mb
I called it like python utils/latex.py test ./something.png
and it errored out
out of interest, is the huge memory requirement just on the first plot?
IE if you try to plot a second directly after, does it use a normal amount of memory?
module 'signal' has no attribute 'SIGXCPU'
🤔
what OS are you on
These changes are for unix based system exclusively
what are you using to profile?
!pypi memory_profiler
ok, going to test the second drawing idea
then I'll do profiling
ok, the second one does run, I'll try to do it from the bot itself now
hmm, no, I lie
it failed on the second one
also failed from the bot obv
So question: is this still dealing with mpl's latex rendering? Could we just sidestep this and see if a slim but robust latex install might be the way to go?
yes
interesting
what about the infinite loops and file read write and all that that would come with it
wonder how much plain latex allows, hmm
Profiler refused to profile, so I'll just try the function itself now
Line # Mem usage Increment Occurences Line Contents
============================================================
57 84.7 MiB 84.7 MiB 1 @profile
58 async def _latex(self, ctx: commands.Context, *, text: str) -> None:
59 """Renders the text in latex and sends the image."""
60 84.7 MiB 0.0 MiB 1 text = self._prepare_input(text)
61 84.7 MiB 0.0 MiB 1 query_hash = hashlib.md5(text.encode()).hexdigest()
62 84.7 MiB 0.0 MiB 1 image_path = CACHE_DIRECTORY.joinpath(f"{query_hash}.png")
63 84.8 MiB 0.1 MiB 2 async with ctx.typing():
64 84.8 MiB 0.0 MiB 1 if image_path.exists():
65 84.8 MiB 0.0 MiB 2 await ctx.send(file=discord.File(image_path))
66 84.8 MiB 0.0 MiB 1 return
everything after this line is unprofiled
that's ugly
there lol
It seems to have 80Mb of globals doesn't it?
profiler is approx 50mb
What am I supposed to look at then haha
yup, the profiler was kind of useless
I'm currently trying to profile the function itself
looks like even minimal latex installations still take at least 50MB+
I think 50MB of library is honestly pretty okay
We aren't short in memory by any mean right now
hmm
Lance has ffmpeg when it barely uses it
If at all
That takes up 200mb
Including its 100 dependencies
lol
I don't think it's used at all, need to do more testing though. sir-lancebot#686 for reference
it would be nice if tests were complete
Lol
In that case you could just delete the dependency and run all of the tests
There's no tests on lancebot
Yeah heavy testing raises the entry bar to contribution, especially for discord.py bots
Yeah
testing in bots is miserable
sir-lancebot#686 is ready for review, couldn't find anything that actually uses discord voice or ffmpeg
noob question
how would latex be installed locally
not like you can just download a file and run the installer or something
right
?
between linux internals, and a random pypi library, not sure which to believe
oh, ignore the logging lol
!pypi latex
makes pdf
not jpeg
or png
we could still use matplotlib
and just make it use system's latex instead of its own engine
Wut
Did you
and, well, if that has memory issues
Not sure if that thing would work
we could switch
which thing
I forgot
@placid ermine Recap: whats the current issue and also main issue with the latex command?
memory usage goes brrrr
Iirc what's happening is its not closing right?
Well, I'm not really sure there is anything left for me to try with the process stuff, so I'll just deploy it on my cluster, and we'll see if it hits limits
'ight
your cluster?
kubernetes cluster
any updates
I have access to the manifest used to deploy sir-lance, so I can get something pretty similiar
Well, it's a 200mb image
taking a minute to push to the hub lol
~100mb done
o
where do you run it?
iirc scaleios self-hosts k8s
managed DO cluster
who was it that self-hosts
I would self-host if I wasn't a moron
yeah lak haha
Ok, we really need to fix the dockerignore
it loaded my .env
so I accidentally just published a bunch of tokens
Oof
Uh oh
Time to regen ig
dockerignore doesn't work with docker compose afaik
And that is exactly why the approach of a whitelist is better than a blacklist.
# Exclude everything
*
# Make exceptions for what's needed
!bot
for example
That is the current config
# Exclude everything
*
# Make exceptions for what's needed
!bot
!Pipfile
!Pipfile.lock
!LICENSE
But I just sshed into the container, and there it was
my .env
Was it inside the bot directory?
Then as far as I can tell that is an impossible situation
if its in the docker folder how is that published?
yeah
which I published before noticing
If you run a container locally do you also see the file in there?
but ideally, the .env file would be loaded as env variables, not an actual file
So do I
COPY respects dockerignore
Then theoretically, it shouldn't have copied my env
What actually happens is that the build context is modified by the dockerignore
Well, shouldn't it still ignore everything
I think it's this in the docker-compose ```
volumes:
- .:/bot
Right now, it is not ignoring anything
since that'll share the whole folder right?
I think that's the interior bot folder
It may need to be ** instead of *
I see some saying ** and others *
the star didn't seem to matter
I don't think ** is necessary
👍
I didn't expect a volume to matter for building purposes
If you look at docker build there isn't even a way to specify a volume during building
What was happening then? The volume being mounted was giving a misleading result when running the container?
I tested locally, and saw the .env
I didn't actually check the remote image
Didn't consider how the compose would affect it
Yea, so the volume was being mounted and all the files from the project root were put into the container
I thought you said you ssh'd. I interpreted that as ssh'ing into the prod or something
k8s ig?
I don't think it does, that was not the right terminology
I opened a terminal in it locally
ahh just spawning a shell process
Someone snuck in an nbsp into the dockerfile haha
&
@sleek steppe Greetings. You around?
Yep
Alright so about this PR: https://github.com/python-discord/sir-lancebot/pull/684
Although I realize I've already approved, we cannot accept the pull request since we can't exactly filter out all emojis that are inappropriate.
That's why we only allow the ones that we have on this server to be shown.
No relevant issues as this was discussed in .
This also cannot be accepted, as this PR should've been discussed within an issue before making a PR.
May I ask who you talked to about this issue?
So after I opened the PR I had already asked some people, and then you and ks discussed it here <#dev-contrib message>
I mean we could do !e print("bad word") really
Other commands can do that too
Someone with an nsfw pfp can use an avatar command
Yeah but I doubt they'll stick around for any longer
Any community they are in can moderate them and report to discord
Don't think there will ever be a scenario where someone with an nsfw emoji will use an emoji command, but I guess you don't want to take that risk ¯\_(ツ)_/¯
So, hi guys. Im from Rus, and i downloaded Ubunt (Linux). And i have many problems with python on terminal in this system. Who can help me to download and use python on Linux?
That was discussed
This thing first mention: #dev-contrib message
How do people feel about adding aliases to the doc command. From a cursory look, it seems possible to add a list of aliases that the bot translates before searching, but it might require a schema change on site, and quite a bit of added logic to the bot.
The use case for something like this would be aliasing certain modules that are better known by other names. For example: np or pd (maybe dpy to a lesser extent). Other challenges I foresee, besides the complexity issues, are issues with namespace pollution. Adding np as an alias is fine, but you run into problems when you want to add a package called np. I don't think that's true for any of our current docs, but it's a consideration.
It would be fairly simple bot side if it just tried the alias replacements in case of a failed lookup like it's done here https://github.com/python-discord/bot/blob/main/bot/exts/info/doc/_cog.py#L222-L234. For the use I personally don't see much benefit to it as you're probably already typing out things so the difference isn't huge, but then again I also don't use and fetch info from for example numpy often
iirc we had some complaints about not being able to search just by using the name discord (something about the inventory path being different)
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
nice
i think the bigger issue with this is !d discord.ext.commands.Bot shows the exact object path in the name. !discord ext.commands.Bot just doesn't make as much since, as it is always part of the discord object.
Does this make sense?
hey folks! I've just deployed some changes to pythondiscord.com and a set of our other services to introduce a set of new security headers, stuff like disabling permissions we don't need, tightening our referrer policy, rejecting iframes and so on (and of course disabling the horror that is FLoC). If you notice anything weird about resource loading on site please let me know.
(and of course disabling the horror that is FLoC)
every header. its stupid way to opt out
i mean that's how you opt out, no? every request has the specific opt out header
ah
i think i need to learn some front end some time
puts it on a list for months from now
I am also deploying an exiting change shortly which is uhhhh
actually I'll just deploy it and then talk about it
for those who wanna know if they're in the "beta" https://amifloced.org/
i just realized as of now it seems mostly im-- wait nvm i... yeah.
was gonna say it isn't possible for FLoC to be on iPhones since every browser has to use webkit but that's wrong
allllllrigh
t
there we go
should be live
CSP is enabled on all python discord web properties, for now though we're only reporting instead of enforcing
we're also passing it through a worker to strip off IP data
What's FLoC?
Is bot#1498 still possibly useful, or not?
lol that's a great title
basically instead of identifying people individually through cookies identifying them through groups of cohorts with similar interests
👍
Fancy. But seems like a weird, not very good idea
FLoC is FLoCing terrible
yeah, it's a very bad idea
yeah that seems fine
@sleek steppe assigned you
Oh thanks
I think I'll need to rework redirect_output or make a new utility function
Maybe an allowed_channels parameter
i mean it only works for #python-discussion now so
what is scp?
content security policy
that's still useful
a header which basically says which origins/locations any scripts/stylesheets/images can be loaded from
right now it's set to anything https://, pythondiscord.com or inline, I'll make it more granular in coming weeks
i thought it was
related to tracking since you said it right after floc and cookies
nah, CSP is a security move for clients
so if we have a failure in that policy I see something like uhhh
ah
I think I'm ready to make a PR now, I also made not_in_blacklist useless
https://github.com/python-discord/bot/pull/1446#pullrequestreview-637609616 any confirmation on this?
If I wanted to add a feature to the @stable mountain bot do I just go for it with a pull request? Or discuss it here first or..?
I'm totally new to open source stuff 
And I wanted to see if I (or someone) could make it so editing !e into a code post will execute it
So the first step would be to open an issue on the @stable mountain repo. There should be a link in the description or in the pins
From there discussion will happen and a core dev will approve the issue and assign you to it (if you want to work on the issue). From there you're welcome to PR!
We do have contributing guidelines and all that good stuff to walk you through the process
We're also super friendly here, so you're always welcome to ask questions and provide suggestions
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
That's the contributing guide for @stable mountain
All makes sense
thanks
I'm a bit tired, so hellooo to a bit of a philosophical rant.
One of our core ethos, especially for development, is that we do encourage people to learn new things and contribute to open source. @dusky shore is our fun and community bot that's encouraged for first time contributors to get started with.
That being said, our core server functionality (like the !e) does stay in Python. We have some stricter standards in Python because that bot is responsible for administrating the community, but our core devs and contributors are wonderful folks who can help you out
Also, remember to lint before you push 
(really you should lint before you commit)
Didn't lemon make a song with that?
yes!
Do you that that feature would be likely to be approved? I help in the help channels a lot and it's just annoying when you type out a bunch of code but forget the !e at the start. I've seen other people try to edit the !e in to to retroactively execute.
Noice

Thanks Jason!
I do know our bot has the functionality of if we run !e, and then edit it within a time frame, it'll provide the option to re-run the eval with the edits
yeah, that's real handy
my idea is the same but for if you edit the !e in at the start of the message
yeah, that would be a really handy feature, not just !e but it coould be done with all of the commands
I'm not sure how the bot will do with editting in the command since it'll be a different process. Someone a bit more knowledgeable will have to correct me here, but I believe when we do !e the process of listening for corrections only happens once the command is initially invoked. But maybe Python could still listen for the command on message edit
I'm pretty sure you only check when the message is sent
ooh, true, though that sounds trickier, heh.
we can just use on_message_edit, and then call the process commands, like it happens on on_message
So you'd have to listen for commands on message edit
that's my guess, not sure
Well, definitely write up an issue! This is interesting and I'm all for helping people help people...
If it's your first time writing an issue, you can check out the issue template on Sir Lancebot's repo. It'll give you some guidance on what to include
or just blindly steal the format from an existing issue
Alrighty
I will look into writing an issue
sir-lancebot#685
It's in there
thanks
For bot#1498, should I only include the eval command?
What do you mean? If we want to redirect the output of other commands too?
@short snow it would have been better to break up this commit into several. The title doesn't convey what it changes properly either
firstly how should i do that? delete the commit and make new commits?
secondly is that really necessary, i have explained the changes in commit description
Yes, the commit title is important. You go to the body to see more details, but the title needs to convey what was changed
Adding an edit listener is not a refactor
having separate commits for separate changes with a fitting subject is important both when going over the history and with the blame
agree with that, any idea how i would be able to do it
If it's already pushed and reviewed then redoing it would probably lead to a mess in the PR but it is something to keep in mind for the future
maybe i can edit the commit title to make it clear? if that's possible
That will have to redo the commit as any other change, I'm not sure if review comments would be lost or kept with a detached commit on a force push
hmmm, what do you think @cold island ?
You can leave it for now, I'll see what others think
ok
@green oriole Could I trouble you for a re-review for lance's int e?
Yes
That gist was specifically for PRs, not issues
When opening a new issue https://github.com/python-discord/sir-lancebot/issues/new/choose, and selecting feature, it will use the current recommended template
Anyways, I don't know how feasible it would be to listen to commands being added in after the fact. The eval command runs through the following checks and conversions in the regular on-message flow:
@command(name="eval", aliases=("e",))
@guild_only()
@not_in_blacklist(channels=NO_EVAL_CHANNELS, categories=NO_EVAL_CATEGORIES, override_roles=EVAL_ROLES)
async def eval_command(self, ctx: Context, *, code: str = None) -> None:
Now, these checks are not run for message edits, but they will have to be run to add your feature
That's a lot of overhead, because a ton of edits happen (trust me, we have logs lol)
I can't say for certain how high that overhead will be
But I can definitely tell you copying your message and sending it again is not too difficult
This also raises questions about how you make the distinction between an eval that had already been run, and one that has just been edited in
The event does pass in the old and new message
but that means you may end up running the checks twice
so that's doubling the overhead
</rant>
Sure thing!
!remind 30M review
Your reminder will arrive in 30 minutes!
It should be implemented with that idea in mind (meaning, it should be a simple decorator), but the issue deals with eval specifically
I added a categories + channels parameter to redirect_output
@green oriole
Here's your reminder: review.
[Jump back to when you created the reminder](#dev-contrib message)
Hey @thorny obsidian re: https://github.com/python-discord/sir-lancebot/pull/673#discussion_r611223893 sorry I didn't see your answer.
You can run exit() in the container to make it exit which will make k8s restart it, that's quite handy. But due to the fact that str.startswith was used, doing so will just trigger the context reset while it wasn't what you necessarily wanted to do. You can do !int e 1;exit() to bypass this restriction but that's a bit silly.
hello, would you guys agree to add a similar feature to lancebot as 8bitify?
my idea is to take an image, split it in x pieces, randomize those pieces and stitch it back up
Also merged the PR
That sounds interesting, is it something you would be interested in contributing?
yes ill do the whole thing
i have it done already
but i would just have to make it work as a discord command
oh yeah! I removed the starts with check so now the exit() will restart
Cool, can you open an issue on https://git.pydis.com/sir-lancebot first please?
.int e ctx.send("hi")
lol wait a minute for it to deploy
ill try, gotta do smth real quick
.int e ctx.send("hi")
hi
[Captured] <Message id=833009569848492092 channel=<TextChannel id=635950537262759947 name='dev-contrib' position=59 nsfw=False news=False category_id=411199786025484308> type=<MessageType.default: 0> author=<Member id=528937022996611082 name='Sir Lancebot' discriminator='9543' bot=True nick=None guild=<Guild id=267624335836053506 name='Python' shard_id=None chunked=False member_count=178917>> flags=<MessageFlags value=0>>
eeeeeey
Would it be possible/useful to do permission/role validation before channel validation?
int e doesn't need you to await things? 
how FAST do you WANT deployments to be SMH
nope
faster
interesting
just faster
the deployment is the fastest bit it's the docker part that is slow because docker is slow 
Because I can type .int e here and it says I can do it in #sir-lancebot-playground, when I obviously can't, because I'm not an Admin.
it only does so for the last line actually
I don't mind that
@green oriole hi i added the issue with an example
ok
if '_value_last_expression' in locals():
if inspect.isawaitable(_value_last_expression):
_value_last_expression = await _value_last_expression
_eval_context._value_last_expression = _value_last_expression
Alright I guess I'm just going to do it for !eval
random question - is that beautiful open graph protocol github repo preview something that github has done lately? : o
I assume so
Bot#1531 needs some reviews.
Don't worry, we will review it in due time :D
Great
Otherwise Xith doesn't get his weekly lemon delivery
Hey @clever wraith, I forgot to ask, where did you get the code from?
myself
Is it just something you kept locally, it isn't licensed anywhere?
i wrote it from yesterday to today, its nothing special
its not some api or anything like that
just some PIL magic
Cool, all good then
.source 8bitify
Riiight here
thanks
i have a connection to the 8bitify command by now lol
aight, so it works as a discord command @green oriole
basically all of my lancebot stuff has been invoking commands from other commands, so 8bitify is my normal test subject
my command that is
im not really sure what should i do from now
i dont use github so i dont know how you guys add the code there
Have you ever used git or some other version control software before?
ive used git for heroku ig
but i dont really know about that
i can just give you guys the code maybe
If you really wanted to, it might be possible, but I'd also be down to walk you through some git basics
Sir-lancebot has a contributing guide here too: https://pythondiscord.com/pages/contributing/sir-lancebot/
as you wish
also i have another question
And a specific guide for working with git: https://pythondiscord.com/pages/contributing/working-with-git/
im suppose to do all the error handling for my command, right?
Nope, sir-lancebot has its own global error handler for commands
Some of it, yes. For the most, you'd handle errors specific to your code, for example, errors that PIL might throw, but the error handler can format it for discord for example
i have some local stuff here that is relevant only to my own command so ill do it rn
For example, type hinting to int for the amount of slices will raise a BadArgument if someone were to pass foo for it, and sir-lancebot will send an error message saying that converting to in failed
so for the wrong argument types that bot will handle it?
i just have to type hint it?
Yep.
ok ty
You'd need to type hint anyways because of flake8
and my command only takes numbers that you can get the square root of, so would this be allowed to add:
if not math.sqrt(splits).is_integer():
await ctx.send(f'Could not get the square root of `{splits}` :confused:')```
I mean (0.0).is_integer() is True
I would raise commands.BadArgument so that the error handler could catch that and note in the docstring that the number must be a perfect square
what
but it doesnt make sense
anything that has .something is a float, no?
Yes. (0.0).is_integer() will return True. Only floats have that method
!d float.is_integer
float.is_integer()```
Return `True` if the float instance is finite with integral value, and `False` otherwise:
```py
>>> (-2.0).is_integer()
True
>>> (3.2).is_integer()
False
@sleek steppe ok thanks
hello, so i finished my command fully and now would like someone to help me add it
What do you mean add it?
to the lance bot
i assume you already made an issue on the repo?
Yeah they did
yes
OH DANG
sorry
seems that github updated their embeds
It's like a 50% chance it actually shows
kind of annoying
basically make a pr on the repo
how you do that is with git
short statement: git is complicated so we can walk through every step 
@clever wraith what do you have so far?
@clever wraith follow this guide
ok
the code for what the command does and the actual discord command for it
i can also show how it all works in my testing server
You'll probably need to run the PIL and BytesIO stuff in an executor
i presume its running on a lancebot clone?
on my own bot
i mean the whole path to get it from start to finish on lance
i made a testing one
ah
so
yeah
follow the guide
https://pythondiscord.com/pages/contributing/sir-lancebot/
https://pythondiscord.com/pages/contributing/working-with-git/
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
so am i suppose to fork lancebot?
yeah
i think i did it
Follow the guide and test the command to see if it works
i got it in my pycharm i think
the whole lancebot
btw what are environment variables?
not sure what to do here
oh i found them
yeah and it says error during connect: This error may indicate that the docker daemon is not running.
What OS?
windows
Do you have docker desktop running?
prob not
is the ones u get to access when ur pc starts up?
Ah right had to do that the first time I tried using a vm
like while its starting up i mean
Yea, it is
You'll need to enable it for the same reason as a vm, docker engine uses virtualization for the container
And you need to enable that option in the bios
one of the circled settings is that vm thing and i dont even have it
how do i enable it?
In that link, does it explain anything about bios options?
I'm on mobile so can't find you resources myself
has this
so i gotta restart my pc, get in those settings and enable that Virtualization Technology (VTx)?
Yea, exactly
ok ill go for it
If you can't find the option, google the name along with your motherboard name
See you on the other side 👋
soo smth weird keep happening
whenever id go into those settings, my mouse kept getting repositioned in the top right corner and it was all glitchy
i tried restarting multiple times and also shutting down the pc and then booting it back up but same thing
i installed pipenv with pip but when i try to use it, it says its unrecognized
Path, more like pita
In the repo directory, run python -m pipenv
it printed some inctructions here
im doing py -m pipenv run now but it says im missing a command and i bit confused here
That's because you're not supplying a script. If you want to start the bot, you'll have to do pipenv run start.
In @dusky shore, you can find all the scripts in the Pipfile file. Located here: https://github.com/python-discord/sir-lancebot/blob/main/Pipfile#L35-L38
akarys told to move the webhook as cog level attribute that means i would have to add:
self.incidents_webhook = await self.bot.fetch_webhook(Webhooks.incidents)
to the __init__, so i would need to make the function async as it uses await
so the question is, is it ok to make init async?
I don't even think that's possible
The way to go about that here would be to call using an asynchronous caller
something like an asyncio task, or if this is @stable mountain, the scheduler
that fetches the webhook every x minutes?
is that what you want to do, or are you saying that's what it does
no i mean, should i make it fetch every x minutes or just fetch once at runtime
I don't have full context, but I'm assuming if it was updated, you'd need to update the config too
No real reason to fetch it multiple times
the config has been updated, joe had made a webhook in incidents channel, bot#1446
I think you missed my point
There is no need for it to be fetched repeatedly during runtime, because there are no runtime changes that it can adapt to
I'm meh on attachments being included
I think that has potential to be very noisy
for example, some reports may be to do with a question in a help channel and people might attach a code screenshot
I'll check internally though
Looks like it's missing a slash in the base url
yup
I'm trying to pull it but
get just caused the last error in #dev-log
What happens if I just try to override it
Should be able to change it with the web admin panel
it drops me in a user-password login page, but maybe I'm on the wrong site
!d assert
git fetch upstream && git merge upstream/main
while you have your main branch checked out
nope the links are invalid
because it was not updated
not https://docs.pytest.org/en/stable/index.html
I'm talking about the cache that holds the actual content of the symbol
the one that formats the embed
wdym?
ik what defcon is but what is missing defcon
Missing settings
It tries to read them from the redis cache
if they aren't there, it writes defaults, and sends a warning
(It is no longer a thing, but long ago whenever someone would start up their bot in the staff testing server, we'd all get a nice ping)
The cache shouldn't be set on failed items so it's probably just parsing the html weirdly. But I wonder why the python symbol is the moved one
any way to do that on the github browser?
I think you may be able to PR or something?
Doesn't seem possible
Ok found a way
I actually thought "your_username" was an account.
haha it probably is somewhere
if you login on the main page under the navbar and then navigate it should let you in
https://github.com/python-discord/site/pull/373 could use a look at if it's still up to date to also prevent the error in the site side
Your reminder will arrive in 12 hours!
https://github.com/python-discord/bot/runs/2372148113#step:10:41 how should i fix this? even if i set is as None in the __init__ it would fail
very cool github
there's a problem with your approach
you assume the task will be done before the webhook is ever used
which won't always be true
if d.py has any sort of async call on load, that would be the way to do it
otherwise, you're better off checking if the hook exists whenever you go to use it
lemme see that
i went through the duck pond and python news, and they are done in the same way, dunno why it is failing on mine 
You aren't calling the init in your tests
neither of those modules seem to have tests lol
https://github.com/python-discord/bot/pull/1446/files#diff-f74532881e346e2d6fb8a5423b30c4f50511188f90af67cf716a0c4f1d065c23R310 isn't it automatically called here
lol, uhh oh i hate pycharm, everytime i reformat the file, this happens 🤦♂️
Oh, I didn't see the parent class
Note that this will not schedule `crawl_incidents` in the background, as everything
is being mocked. The `crawl_task` attribute will end up being None.
The create task isn't called by the mock
should i just add a line self.cog_instance.get_webhook() in setUp then?
Maaaaybe? Technically that is the behavior your init is doing, but if someone modifies the init without modifying that setUp, the tests will be exhibiting weird side behaviors
Ultimately this will fall down to the reviewer, but it makes more sense to me to possibly monkey patch that create_task
Basically:
Monkeypatch self.bot.loop.create_task to map it to a create_task from your async setup
yeah, we could possibly add a comment to that tho
Basically:
Monkeypatch self.bot.loop.create_task to map it to a create_task from your async setup
I am not exactly sure what you mean by "create_task from your async setup"
The action that gets skipped, but we want called is:
self.bot.loop.create_task(self.get_webhook())
that's because self.bot.loop.create_task doesn't actually do anything
when defining your bot, you can point self.bot.loop.create_task to the create task of a real loop, or optionally asyncio.create_task
You will have to see how that affects the other create_task in that init though
rather than monkey patching self.bot.loop.create_task we could just make a async function to this, which gets called in init, iirc it is the asyncio equivalent of starting a thread.
asyncio.create_task exists
yeah, either could be done i guess?
If I understand you correctly, you want something to call create_task without actually having the bot.loop
in which case, you don't need to roll your own helper for that
right, i will try doing that
Guys @patent pivot is being mean on metricity#3
lol
Lmao joe
Can someone refresh the doc inventories?
refreshdoc
!refreshdoc
(under doc)
!doc refreshdoc
That’s a weird command lol
Thanks
Np
Maybe worth a root alias
Yeah it's weird to avoid name conflicts with symbols
I don't think it's used nearly enough to have a root alias
I wonder if it could be !doc _refresh to avoid conflicts
I agree but it can if someone wants I don't really mind
That works I would imagine but it's ugly if you ask me
why not just a separate command?
Don't remember
That was brought up though
Probably something to do with being unintuitive to separate especially considering it used to all be under one group
tbh i'm not sure being unintuitive is a concern seeing as it's used approximately never
Probably not worth losing much time on it for the same reason
Yeah :🙍
Iirc I laid out both options and said you decide which to pick
Well, maybe it was even your idea not mine
For the few uses it'll be easier to check the help on doc than going over the general help
@patent pivot
Here's your reminder: metricity PR 3 can be merged.
[Jump back to when you created the reminder](#dev-contrib message)
It is tiiiiiime
@fallen patrol :^)
Hey @sand oracle!
It looks like you tried to attach file type(s) that we do not allow (.pdf). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
It's time
merged
it says pipenv is unrecognized
and i installed it with pip
i tried py -m bot right now (py is instead of python for me) and im getting this:
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed```
@clever wraith Do you have in your .env file FAKE_REDIS = true ?
BOT_TOKEN='ODMzMDE0NTQNlcKnKGdYQFrw'
BOT_GUILD=833014638723072020
BOT_ADMIN_ROLE_ID=833090174942052383
ROLE_HELPERS=833090255573876776
CHANNEL_ANNOUNCEMENTS=833090325605515274
CHANNEL_DEVLOG=833090377916874772
CHANNEL_COMMUNITY_BOT_COMMANDS=833090470052626482
USE_FAKEREDIS=true```
this is it
i altered the token so dw btw
.
and this is where its loacated
What does py -m pipenv run start
do?
OOH
its creating smth
some vm env
now its saying im missing module arrow
even tho i installed it
Let's do py -m pipenv install
You did install it, but not in the venv that was just created
ah
got this now
Alright, now let's do the py -m pipenv run start
ok
oh it sent some messages in my server
i think its running
is it ok if a lot of channels are missing?
cuz i just made the required ones
that were in the guide
Oh yeah, that's fine
Nice! I'd suggest you also do py -m pipenv sync --dev and py -m pipenv run precommit
This will get you setup with the precommit hook
its already running rn so should i turn it off and run those commands?
You can do it now, or after you play with the bot a bit to make sure its working
ill just do it now
Is your command setup as a cog?
I mean you said you have code right?
i have the whole code but it was only made to work with my test bot
Is it written as a cog
its just written for a bot
Or a plain command
Alright if you take a look at bot/exts/evergreen there will be a bunch of files in there
yeah already saw
Those are a few commands we have there
should i use 8bitify for reference?
I suggest you copy one of the smaller files and use that as a base
cuz its kind of similar prob
Wait, what issue is this for?
Hmm, I've got a PR open at the minute that changes all of the profile pic modifying code
btw the way i coded it was that i had 1 module for the actual pfp mod and other module for the bot so should i merge them together in one module for this?
It might be easier to wait until that's done, since it'll be easier to slot it in
Hmm, let's get it into a PR, so we can see what your code looks like, and go from there
im not too familiar with all this github stuff, so to get this clear, i should code it into a cog for lancebot and then do the pr?
Did you fork the repo?
yes i have everything already here
Cool, I'd suggest making a branch on your repo, it'll make it easier later
1 sec, let me get a guide
ok
OK, from the root dir run git checkout -b name
Where name is what you want to call your branch
ok, also is the name for me to decide or does it have to be approved
You can call it what you like
ok
Just try to summarise what yours doing in 3-4 words
Doesn't need to be too descriptive
oh
i thought it was suppose to be the name of my command?
or can that be multiple words
cuz i just named it splitify
similar to 8bitify
ok ok
So you've got a branch now Yea?
ye
Alright, make a new file in the evergreen folder
Call splitify or whatever you want it to be called
Yea, put all the cog code in there
Sure
@gritty wind
Here's your reminder: Review site# 373.
[Jump back to when you created the reminder](#dev-contrib message)
pipenv run precommit
git add .
git commit -m "Your commit message"
i just have 1 question
my command requires a perfect square num and i made a little error handler to check that and if the num isnt perfect square it raises commands.BadArgument().
but the thing is that i dont think that error that the user would get from the lancebot would clarify why their provided num was not accepted
this is what i mean
you can specify an error message like raise commands.BadArgument("not a square")
should i do this now?
it says that pipenv was not recognized
python -m pip install pipenv
Try running the commands again then?
which?
^
so i should just skip the first one?
and when i try to add it says: /usr/bin/env: ‘python’: Permission denied
if anyone can help, ping me
