#tools-and-devops
1 messages Β· Page 66 of 1
@deep estuary
This is what I am getting when putting pyenv virtualenv-init into my terminal:
# the following to ~/.bashrc:
eval "$(pyenv virtualenv-init -)"
interesting
what if you run pyenv virtualenv-init -
I assume you have restarted your shell since installing
Yes sir
hmmmmmmm
It also seems to very expansionist, whereby it started to claim that my system python is the one I asked it to install, rather than my initial native version
EDIT: while in the project directory and in my $HOME, the which python command points to the same file. However, when in $HOME once running the python command it shows the system version, while in the project folder it shows the correct one I wanted
I love my job π
My initial thought was that pyenv would create a symlink to my native python binary, but no
Ok upon reading the docs, it seems that an additional .python-version file is created which holds only the python version (duh!) on the folder level (?)
ahhh yeah that rings a bell
So upon removing this file from my home, the versions seems to work correctly, albeit the which command still shows the same thing
lol
That seems to be a good temporary solution and I am too tired to deal with this nonsense any more tonight - @deep estuary you've been a star - thanks!
haha no problem
I'll think dearly about you next time I am dealing with something ridiculous like this π
hmmm
so say i commited a branch
its named ci because I'm bad at names
the main branch has gotten a new commit since i branched off from it, and I'd like to add that commit to my work
is the proper command git rebase main ci
no, the proper thing is a merge commit because its already been pushed
git merge main
yeah
you can git merge main and git rebase to rebase the commit onto your branch and avoid merge commits
yea
and that won't rewrite history??
i had to go into reflog earlier today because i uh, erased 7 commits by doing a rebase and then pushing :)
β¦.why is docker just not.
> docker-compose up
/usr/local/bin/docker-compose: 1: /usr/local/bin/docker-compose: Not: not found
ah
its because this ```sh
% where docker-compose
/usr/local/bin/docker-compose
/usr/bin/docker-compose
/bin/docker-compose
ah wow
that makes some sense but
just memorizes what you said
:)
lmfao
bad @signal cloak
welp
time to deal with docker while i wait for that pr to be merged
docker-compose version 1.21.0, build unknown
lovely.
which pr
modmail
ah
regardless
trying to get docker to working locally to test https://github.com/discord-modmail/modmail/pull/13 tho
and this is a problem.
i ended up just not doing it on a raspberry pi
def run():
a = wifi_var.get()
b = vectom_var.get()
g = subprocess.Popen(["ettercap","-T","-S","-i","wlan0","-P","dns_spoof","-M","arp:remote",f"/192.168.1.1//",f"/192.168.1.13//"])
def stop():
g.terminate()
this is my error
it says
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.9/tkinter/__init__.py", line 1884, in __call__
return self.func(*args)
File "/home/gromax/Documents/python/main.py", line 15, in stop
ro = g.get()
NameError: name 'g' is not defined
what should i do??
read about scopes on functions
!scope
Scoping Rules
A scope defines the visibility of a name within a block, where a block is a piece of python code executed as a unit. For simplicity, this would be a module, a function body, and a class definition. A name refers to text bound to an object.
For more information about names, see !tags names
A module is the source code file itself, and encompasses all blocks defined within it. Therefore if a variable is defined at the module level (top-level code block), it is a global variable and can be accessed anywhere in the module as long as the block in which it's referenced is executed after it was defined.
Alternatively if a variable is defined within a function block for example, it is a local variable. It is not accessible at the module level, as that would be outside its scope. This is the purpose of the return statement, as it hands an object back to the scope of its caller. Conversely if a function was defined inside the previously mentioned block, it would have access to that variable, because it is within the first function's scope.
>>> def outer():
... foo = 'bar' # local variable to outer
... def inner():
... print(foo) # has access to foo from scope of outer
... return inner # brings inner to scope of caller
...
>>> inner = outer() # get inner function
>>> inner() # prints variable foo without issue
bar
Official Documentation
1. Program structure, name binding and resolution
2. global statement
3. nonlocal statement
hey guys im setting my environment variables on a digital ocean droplet
on bash_profile
all the environments are okay except for my mongo uri
export MONGO_URL_PRODUCTION=mongodb+srv://......
i cant print all the others but this one
no white spaces
not sure I follow, are you unable to set the variable?
ah, just saw Chris answer in #devoops-hour-chat π
argh.
I am trying to set password for redis
and connect from django
the first part goes well, but django just refuses to auth
version: '3'
services:
redis:
image: "redis:alpine"
command: redis-server --requirepass mypass
ports:
- "6379:6379"
volumes:
- ./redis-data:/var/lib/redis
- ./redis.conf:/usr/local/etc/redis/redis.conf
restart: always
tested with redis-cli
AUTH mypass works
trying to auth in different ways in django... but no idea what is wrong
always this redis.exceptions.AuthenticationError: Authentication required
what are you trying in django?
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://" + ":mypass@" + f"{DOCKER_IP}:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}
i tried to auth like that
hm, yeah, I'd assume that's correct
and
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://" + f"{DOCKER_IP}:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"PASSWORD": "mypass",
},
}
}
I think I already tried all the different ways
have you tried without the leading : on the first one? sometimes I see that not being implemented well
leading : where to put?
in your first example you would be generating something like redis://:mypass@10.0.0.0:6379/0
which is valid but not always implemented
as per the docs though that looks valid
so
hm
hmm
ops
it works
bwhaha
I get it
I thought redis_lock library when connected
https://github.com/ionelmc/python-redis-lock
attaches itself to CACHES auth by my assumption
it is some problem of auth with django redis lock library basically
basic cache functionality authed as I can see
and it works too now. authentificated. Yay
π
just to be sure I made password from 64 symbols π
it should be enough against brute force
Hi guys
How can I execute command inside Python in command line
for ex. if I execute python then I need to execute x=10 and y=2
In command line
Hey! I'd like to a build a small environment using Docker, and Docker compose alongside with Github actions and such, however.. I'd like to use Django but I'm not sure how I could run the migrations automatically, do you have any suggestions?
Hey Everyone!
A celery & devops related question: currently I'm looking into celery+redis to run a task queue and to run periodic tasks.
This system is setup like this:
- One DB server
- Multiple docker container instances running django
The periodic tasks mainly consists of fetching data trough a web api and putting it into the django DB.
Question: if I have for instance 5 docker instances running, will it trigger 5 times the periodic task per interval? If yes: how do I prevent this?
I think the task would be taken by first celery worker
just make sure you don't have 5 beat task initializers π
if you will have only 1 celery beat, and 5 celery workers, the task would be taken by first free worker in theory
celery beat creates the task
workers process them
So I need a dockery way to only initialize the celery beat in the first instance online?
well, yeah
whatever way to initialize only one celery beat
hehe, it would be your dockerized task creator π
the leader of the group
leader was the magic google word: found out about managing nodes in a swarm
Thanks!
u a welcome
we have a custom manage script for https://pythondiscord.com/ that gets called in docker and runs migrations https://github.com/python-discord/site/blob/main/manage.py
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.
pythondiscord.com - A Django and Bulma web application. - site/manage.py at main Β· python-discord/site
then kubernetes uses this config to wait until the site is responding to requests before cutting over traffic https://github.com/python-discord/kubernetes/blob/main/site/deployment.yaml#L21-L31
site/deployment.yaml lines 21 to 31
livenessProbe:
httpGet:
path: /
port: 8000
httpHeaders:
- name: Host
value: pythondiscord.com
failureThreshold: 2
periodSeconds: 30
timeoutSeconds: 5
initialDelaySeconds: 10```
Oh, wow. Thank you! π
Xonsh shell or subprocess
I have a 132gb flashdrive in my computer w/ not much localstorage left. After changing to linux. How do I free up space by transferring things to the flaskdrive?
hello is there a discord server dedicated exclusively to devops?
not to my knowledge
Hello! Does anyone know of a way to do a blobless / treeless clone with GitHub's actions/checkout ? Some searching revealed nothing beyond custom bash scripts :/
Unfortunately I can't get away with a shallow clone because setuptools-scm needs the commit (or tag?) history to generate the distribution version.
by default it should be fetching the latest commit only
i'm not sure how to pass in the args that would make it truly treeless/blobless though (or if there is a way with the action, there is not an option I can find)
Hmm yeah it doesn't look possible then, not the end of the world, thankfully the repo I'm cloning isn't that big (psf/black) but it would be nice if I didn't have to clone the *whole* repo. Thanks for searching!
I think through subprocess we can only open python shell can't interact within python shell
@deep estuary boop: https://www.dsicommunity.org/
thanks!
some questions here as i understand docker more (and sorry for all these amateur questions, just picked docker up today):
- is it sensible to have separate dockerfiles for running a dev server and a production server.
- if i were to have tests such as cypress running with docker, should i have another dockerfile for that, or should i somehow put it in a docker compose with the dev server
- from looking at some open source projects on github, i saw some people who uses something like api.Dockefile or Dockerfile.api what are those for? and what are the differences?
thanks!
very nice
- Imo, yeah that's fine
- I personally would keep that out of docker and just run it locally, but if you really wanted to, a dockerfile to run tests would work.
- I believe that's just their way of differentiating dockerfile. Like that's their dockerfile for their API, but they might have one for their website too.
i see, thanks for the response!
hey
im using pm2 serve build --spa
but pm2 is still running as a static page server
im getting this error
0|static-p | [2021-07-29T11:45:44.247Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:45:45.497Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:45:46.761Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:45:47.337Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:45:47.653Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:45:47.825Z] Error while serving /home/master/frontend/build/app/home/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/app/home/dashboard'
0|static-p | [2021-07-29T11:46:06.703Z] Error while serving /home/master/frontend/build/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/dashboard'
0|static-p | [2021-07-29T11:46:09.550Z] Error while serving /home/master/frontend/build/dashboard with content-type text/plain : ENOENT: no such file or directory, open '/home/master/frontend/build/dashboard'
pm2 status
βββββββ¬βββββββββββββββββββββββββββββ¬ββββββββββββββ¬ββββββββββ¬ββββββββββ¬βββββββββββ¬βββββββββ¬βββββββ¬ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ
β id β name β namespace β version β mode β pid β uptime β βΊ β status β cpu β mem β user β watching β
βββββββΌβββββββββββββββββββββββββββββΌββββββββββββββΌββββββββββΌββββββββββΌβββββββββββΌβββββββββΌβββββββΌββββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββ€
β 0 β static-page-server-8080 β default β 5.1.0 β fork β 1204 β 2m β 0 β online β 0% β 38.0mb β master β disabled β
βββββββ΄βββββββββββββββββββββββββββββ΄ββββββββββββββ΄ββββββββββ΄ββββββββββ΄βββββββββββ΄βββββββββ΄βββββββ΄ββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ
Quick question about Docker: so I have a container that runs a Postgres database, and uses the host's filesystem to store the database: what happens if I have two of the same postgres container running? Will they share the same underlying database on the file system?
Yes they will. The database data is a volume which in turn is just a file.
Interesting question tho because in theory this could start data races while writing
yep, that's why I'm asked π
Hi all,
Two months ago, our team switched from Java and Javascript to Python.
We love the language, but we had some hard times setting up our dev environment, i.e. some devs had troubles installing tools like poetry on their machines.
In Java land, gradle introduced the gradle wrapper scripts; *nix and windows gradlew scripts that download (and cache) the desired gradle version on the fly when running a command.
https://github.com/houbie/python-wraptor tries to achieve the same for Python based tools.
You just add the shell scripts to your repo, configure your tools in pyproject.toml and prefix all commands with pw, f.e. ./pw poetry install, ./pw jupyter notebook
The optional px script and command aliases shorten your commands; f.e. open your favorite Jupyter notebook with px nb from any subdirectory in your project.
The wrapper scripts make sure that all devs use the same version of tool for a specific project.
It can also help tutorial authors: your audience only needs to have python3 on their path and can skip the hassle of installing numerous other tools.
On the first invocation, python-wraptor creates a tool/version specific virtual environment in ~/.python-wraptor/venvs and delegates the command.
When multiple projects use the same version of a tool, it only gets installed once, and cleaning up is just a matter of rm -r ~/.python-wraptor.
Check out the https://github.com/houbie/python-wraptor code and the https://github.com/houbie/wrapped-pi example project and please share your thoughts...
any idea how to check if proxy is alive in python
requesting some web site looks like not good solution
as an option requesting myself, but it is not comfortable to use in local development
clarification: checking my own squid proxy server
so if additional config changes required, it is possible
oh yes, I guess I could just check is the port is listening
it should be good enough for start
nice, it works.
nvm
π I am facing some issue, unable to push the code to github
lol I have no idea about github too
what error are you getting?
earlier I was unable to do, just now I tried it was successful ig, but just now a discord msg came about my token
yeah, you can't push your token to github publicly or anyoe can login and become your bot
you should store it in an environment variable or secure config file outside your github project
What you need to look up is environmental variables. They are how you handle situations like these
Specifically Google "environmental variables in python"
If it's on a public repo, you are going to have to start over, since git stores history.
On a private repo, it's not a problem but definitely bad practice
Hi, I making a bruteforcer for caesar encryption but I have a problem
alphabet = 'abcdefghijklmnopqrstuvwxyz'
If my input are: HeYhOwArEyOu, the alphabet will not work, but if it is in lowercase it will, so I edited the alphabet by aAbBcCdDeE etc...
It's working but it's print 51 key instead of 25, someone have an idea ?
It should be only fetching the top commit by default. The argument name if fetch-depth if you want to play around with it, default is 1, 0 means fetch everything.
Long time follower of the discord, first time writing. I'm starting a back-end coding educational program in two months. Does anyone have a suggestion on what laptop to buy? (Only for coding, maybe watching netflix at tops).
i like my macbook. joe would probably claim the same. i think going for any laptop with linux / macos is a solid choice
anyone familiar with circleCI ? # This assumes pytest is installed via the install-package step above
how do i do this?
System unit is superior, because it can have at least two normal sized screens ;b
Is there a similar tool for Python like PM2? https://pm2.keymetrics.io/
well if you need three screens then a laptop probably isn't your thing
not really. you should use systemd for this
Laptop screens are always trash
And usually they offer only one additional screen attached
The biggest laptop screen is what, 17 inches?
This is the size of pc desktop screens fifteen years ago
sorry to hear you've had a bad experience with laptop screens. i've been using my laptop for 7 years, and had absolutely no problems with it. i guess it ends up depending which laptop you choose
that said, i don't think that the point of the question was to discuss screen size or number, just which laptop was good for development
No laptop, no problem.
System unit is essentially cheaper too
Since you can choose without videocard with good specs
i'm not sure how "no laptop" is an answer to "does anyone have a suggestion on what laptop to buy", but fair enough
I don't remember seeing similar tools yet.
We usually use as standard gunicorn(for sync)+nginx
@vague silobtw you can use PM2 with any type of apps not just Nodejs, I just don't want to add js stuff to my codebase π
too bad we don't have a tool like this in python
oh I didn't know that's good to know!!! but yeah agreed on the adding js part lmao
Docker compose for the win (for easy run and forget)
Better than pm2
i think the general notion of managing process startup / shutdown with possible dependencies is a good fit for systemd. can also manage logging for you, and restarts the service on failure. starting multiple instances is also relatively easy
javascript is gross
@vague silowhat if you don't have access for systemd? on heroku for example
then the only way is using docker
what specifically are you looking to host here?
Gunicorn fits docker better
It can restart too
And having multiple instances
from how I understood heroku the last time I used it, you deploy one app per ... heroku deployment unit, from whatever that was. I could be wrong though
what makes docker a better fit for running gunicorn than systemd?
I mean pm2 is.... more oriented to be used without docker
But when we essentially need it?
Only for development
I'm just too lazy to learn docker π
how does docker "handle everything"? how do i send gunicorn a reload signal via docker?
btw it's a discord bot + postgres + flask
can you deploy the discord bot and flask in separate heroku units?
I'll just learn docker, never had the time, so maybe now π
also, docker and systemd fulfill very different purposes. systemd, at least pid1, is primarily concerned with managing service lifecycle, whilst docker is primarily concerned with packaging apps in an easily distributable format. running docker images is just part of it
docker exec -it containerID your_linux_command
But why not to reload container ;)
Dunno, compose makes stuff running comfortable
Restart there is just
docker-compose restart
how do I tell docker compose to stop one service if another service dies after startup?
Just one of them? Not all of them from one compose?
Check 'docker ps' and use regular docker commands
so manual labor. excellent
so anyways, the point i'm trying to make is not that docker or docker-compose are bad, or that systemd is perfect. the point i'm trying to make is that there's no one-size-fits-all tool, they all just have different strengths and weaknesses, and thanks to open source software you can choose for yourself which one suits your usecase the best.
Wait a second
There is actually better way
In docker yaml write between services things like
Next container depends on containers...
Hmm, I ll give example
version: '3'
services:
django:
build: .
container_name: django_service
command: >
bash -c "python manage.py makemigrations
&& python manage.py migrate
&& python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/app/
ports:
- 8000:8000
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- redis
celery-worker:
build: .
container_name: celery_worker
command: celery -A fampay_youtube worker -l INFO
volumes:
- .:/app/
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- django
- redis
celery-beat:
build: .
container_name: celery_beat
command: celery -A fampay_youtube beat -l INFO
volumes:
- .:/app/
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- django
- celery-worker
- redis
redis:
image: "redis:alpine"
you are looking for depends_on apperently perhaps
depends_on deals with startup and shutdown order, not runtime monitoring
also see this, i need to head out
!pban 317314122280599554 troll
:incoming_envelope: :ok_hand: applied purge ban to @bold comet permanently.
Lmao
!pban 525274040013946902 Despite being warned and having your advertisements removed countless time, you still continue to spam them
:incoming_envelope: :ok_hand: applied purge ban to @upbeat inlet permanently.
@deep estuary have you ever used wrangler on a raspberry pi?
>>> wrangler publish --verbose
Warning: webpack's output filename is being renamed to worker.js because of requirements from the Workers runtime
:sparkles: Built successfully, built project size is 6 KiB.
Error: Something went wrong with the request to Cloudflare...
Authentication error [API code: 10000
wrangler whoami successfully reports who i am
I have not
ok
well
regardless
I'm not even on the pi anymore
problem is...
wrangler whoami says I'm signed in and who I am
got any ideas?
github-filter-worker/wrangler.toml line 3
account_id = "502aea548379e08369697540cc0bb0d1"```
:)
yeah that will also make things not work
yep changed it to my account and it works
inb4 I just use pydis's worker /s
i should add a WL for that
yea
fixed it by reverting honeycomb :)
yes
i mean i reverted and then resolved the issues
so like
git revert β¦
hm 
very nice
https://discord.com/api/webhooks/${id}/${token}/github?wait=1
was just wondering if i needed to have /github in the webhook lol
hell yea
500 ftw
no, not well apparently
you don't
^
well
so the github config is right
time to see why the code itself errors
darned honeycomb
Cannot read property 'addData' of undefined
I'm still wondering why python-dotenv is not part of the offical library
oh wait you can do the easy thing and just have github pass a secret to the webhook and it has to match what you have saved in the worker :)
yeah i can or i can not
lol
github-filter-worker/src/index.ts line 34
request.tracer.addData({```
Hi! Do you guys have any thoughts on this?
https://kompose.io/
It comes in handy, after learning the whole docker-compose syntax π
kompose is a tool to help users familiar with docker-compose move to Kubernetes. It takes a Docker Compose file and translates it into Kubernetes resources.
lmfao
it was more efficient and effective to set up honeycomb than it was to delete portions of the code :)
looks good
kompose is fun
Since you're probably wondering what I did, @deep estuary, I ended up just using honeycomb for that worker, lol
It's not on any public repo, I only cloned the repo, changed the project id to my workers, and then published it.
lol
Oh, I also spent way too long debugging why it was erroring
Spoiler: HONEYCOMB_API is not the same as HONEYCOMB_KEY
i make website in django i already host after..........I am facing big issues on Websurfer ISP.
I'm just buying Hosting Domain.
Everything is ok but I canβt open my website from Websurfer ISP
From my mobile network it can access like Ncell , NTC, World link and other network but can't access from
Websurfer ISP
Any Solution Please..
Hey!
I'm just exploring Kompose, and came across something that I don't really undestand.
If I specify the service type to be LoadBalancer, shouldn't it automatically expose the IP of the service?
Because the Kompose docs says: kompose.service.expose defines if the service needs to be made accessible from outside the cluster or not.
So, I'm not sure whether I should set it true or not, or that the LoadBalancer sets it automatically true.
https://kompose.io/user-guide/
if you use a load balancer that provisions a public IP it should be fine whatever, might want to set it to expose to true to be sure
Alright, thank you! π
I can see what we use for the LB here
hmmm
as far as I can see expose is more important for NodePorts
give it a whirl though!
Yeah, in the example they used NodePorts , but not exposed the service's IP, so that's what confused me π
dont know where to ask - so here will do , is there a way tou use a python module to intercept usb data ? using W10 and Ubuntu i want to eavesdrop on a UPS ( power backup ) -- if power fails do a shutdown to Raspi , that thing , this thing ... bla bla
hey @deep estuary , how did you configure the settings in honeycomb for the github proxy worker?
this page, specifically https://ui.honeycomb.io/python-discord/datasets/worker-discord-github-filter/definitions
(use the correct org name if that isn't what you use lol)
!Remind 2h
content
!remind 2h this
Your reminder will arrive <t:1627854495:R>!
!remind 2h bored, might as well
Sorry, you can't do that here!
I legit hate you sometimes @rancid schooner
@deep estuary
Here's your reminder: this.
[Jump back to when you created the reminder](#tools-and-devops message)
what, huh?
i can't set . for those values
like
i can set it to trace
but not to trace.trace_id
what about this page? if you would be so kind
https://ui.honeycomb.io/python-discord/datasets/worker-discord-github-filter/schema
how to i install github repo with git?
!remind 8h this
Your reminder will arrive <t:1627922371:R>!
Are you asking how to clone a repository?
Hey! I have a question about Kubernetes.
I think I'm trying to understand the whole picture.
When I deploy an app to Kubernetes, it will schedule to run the app containers in pods on a Node, that's fine. But where does the concept of "replicas" come into the picture?
I thought Kubernetes has a self healing mechanism by default. Or is it for nodes only? Bit confused what happens when only a single Pod fails and not a whole Node.
Replicas is just the number of instances of your app running
so if you have a web app with 3 replicas then 3 pods will be created
If you have health checks then failing pods will get restarted
How do I set health checks?
This page shows how to configure liveness, readiness and startup probes for containers.
The kubelet uses liveness probes to know when to restart a container. For example, liveness probes could catch a deadlock, where an application is running, but unable to make progress. Restarting a container in such a state can help to make the application mo...
I see, thank you! π
Though you can even automate the amount of replicas with scaling rules
lol
@deep estuary
Here's your reminder: this.
[Jump back to when you created the reminder](#tools-and-devops message)
!remind 4h this
Your reminder will arrive <t:1627940993:R>!
lolol
uh
since you haven't sent yet (thankfully) also the triggers config kinda thing would be helpful too
@deep estuary
Here's your reminder: this.
[Jump back to when you created the reminder](#tools-and-devops message)
rip
I think he's gone..
yeah
i wonder who the new server owners is gonna be /s
lol
lol, I'm on holiday
ah lol
well
i figured it out anyways lol
actually added an extra value so i get info on the github users too
found a bug as well
have a good one lol
I have a P90 trigger over 1s
P90 is liiike
if you took all request durations and lined them up and removed the top 10%, the average of the remaining points
looks about right
its slightly different
i added the app.sender at the bottom.
That gives the advantage of showing who actually triggers the most events from github :)
i triggered 100 events in the past 8 hours
you can do that without
jeez
lol
it's the way that github treats fields from github
I think its intentional.
I mean no, not bug, intended behaviour, but not intended in our favour
I did ask
It's not a bug, nor is it something intentionally filtered, just the way that github hooks work
ah
the reason i thought it was intentional is because slack and github webhooks cannot be sent to threads
hello, I'm new on git(hub) and i don't understand well somethings
It only for training to git, not a real project
have two branch, master and bet
two files, main and bet
i accidentaly commited in the wrong branch
and remodified files after
tried this to fix it but now i'm completly lost
pls pin me
you can fix it a handful of ways, but the question is what exactly would you like to change?
i also encourage you to use this command: git log --graph --oneline --decorate . it can give you a very useful high-level overfiew of your repository
it sounds like you have two branches, main and bet
these are not files
every git commit is a snapshot of your files. a branch is just a label that points to a specific snapshot of your files
so your options are:
- change where the branches point
- copy commits from one place to another
isn't it like, change played on the last ones, so it doesn't contain all of the info at once?
you can fix pretty much any git mistake that way
nope, every commit is a true snapshot. git calculates the diffs on the fly. internally they use some clever algorithms to de-duplicate data and prevent your repo from becoming huge.
a lot of people assume what you said, but that's now how it works. that's how "patch-based" version control systems work, such as darcs and pijul. but those aren't exactly popular. and they aren't git.
(also I'm just here because poetry is taking a long time to resolve my dependencies because I cleared the cache because I wanted to see what would happen)
it just for testing so i don't exactly know exactly what i want to change, just go in bet branch with my last change and eventually make my last commit to come with me
git is great
can you be more specific? it sounds like you made a change on the main branch, but you wanted to make the change on the bet branch?
master branch
main is the file
:)
ah
i don't like or trust these git cheat sheet things
they encourage non-understanding
case in point: i think that's one of the worst ways to fix the problem
why?
either cherry-pick the commit, or just swap around the branch pointers with git branch -f
if you have conflicts you have to resolve them one way or another, either during stash apply or cherry-pick
like i said , i'm just starting and i'm lost
cherry-pick literally copies a commit and makes a new commit with a new parent
jeez poetry took 300 seconds to resolve dependencies
i don't undestand why it act like this
@heavy knot this happens because the version of games.py that is in the stash is different from the version of games.py that is on the master branch, and the differences cannot be resolved automatically
ok then. the version of games.py that is in the stash is different from the version of games.py that is on the bet branch.
ok, i try somthings
please don't try random things
let me read your screenshot
it is very difficult to read a screenshot
what does git status show? @heavy knot
ok, good
do you physically see games.py in your files right now?
and do its contents look correct?
ok
"deleted by us: games.py" means something along the lines of "there is no file named games.py in the current branch, but you created this file through a merge or stash pop/apply"
so you can git add games.py and proceed as before
ok, i need to do somthing now, i will see it if work just after
the "would be overwritten" message happened because games.py did not exist in the bet branch, so switching to bet would delete games.py, and git did not want to let you do that
if you did git add games.py main.py before git checkout bet, you might not have needed to perform the git stash operations
ok, i undestood, and thanks
no, it would have added them to the index aka "staging area"
it would not commit them
the index exists separately from the commit that your branch points to
the index is basically a special commit a special snapshot of your code that is ready to be turned into a commit, but is not a commit yet
yes, now you can git commit
you might want to add __pycache__/ to your .gitignore file
my gitignore file for python projects always has at least these entries:
__pycache__/
*.py[cdo]
*.egg-info/
Is there a way to clone a repo without any git stuff at all, only the actual code?
I'm not looking for --depth as that still keeps it as a git repository
I don't want a repository involved at all, just code
I know I can just rm -rf .git but I'm curious if there's a better way
I personally would just rm the git folder
so now it work
the other way is to download a zip from github, if its hosted there
Okie
do the .gitignore already exist or should i add it
github itself provides the ability to get a zip or tarball at any commit
you need to create it
otherwise you can do git clone --depth=1 --single-branch then rm -rf .git
I've been doing that for a while, just curious if there's a better way. Thank you!
yeah, git itself doesn't have the ability to let you do this
Make it into an alias and you won't even know :)
the file can be .gitignore.txt ?
No, it has to be .gitignore
so .gitignore.gitignore ?!
if i create a text file and replace the name by .gitignore, it should work?
need to go eating
yes that is fine
just make sure it is only .gitignore, not .gitignore.txt
if you're struggling to save a file as .gitignore on windows I think the trick is to save it as .gitignore.
and then the trailing dot disappears
or something....
.gitignore works fine for me on Windows (11)
afaik the default notepad wont let you save a file named .gitignore because it thinks it's extension only
and doesnt have a "name"
Notepad worked fine for me as well π€·ββοΈ
π€· maybe I'm just wrong then
i remember being in emotional distress because I once had to rdp into a windows server and save a dotfile there
and something wouldnt let me
ah, yes: https://stackoverflow.com/a/12298593
a last question, the tutorial that I follow in not clear on that point: how to merge branches or to bring back commits from a branch
pls pin me
use git merge to merge. what do you mean by "bring back commits from a branch"?
... to master branch
when it work ?
need to be executed from master or other branch
@tawdry needle
i just downloaded docker and linux on my windows pc. I made a project from the linux terminal for docker, now how to open this project from IDE from windows?
if you have changes on the bet branch and you want to incorporate them into the master branch, do
git checkout master
git merge bet
Ok
not quite sure if this is the right place but i wanted someones help with git/github
recently installed and set everything up on a clean machine
created a new repo and cloned but every time i pull i get:
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
now that's fine and all but this is on a brand new repo
why do i need to rebase?
for every new repo?
read the warning message carefully
git wants you to set some settings. the defaults changed a few years ago and they want people to make an explicit choice, they don't want people to rely on the defaults.
oh okay
it also tells you which one the default is
i haven't ever seen it before but i guess my machine hasn't update git in a hwile
or you have the setting already set
in my opinion you should use the default, i think the warning is unnecessarily scary and the only people who want to change that setting are people who already know about that setting
that's why i asked cause i was worried i did something wrong
but it's good practice in reading git's helpful but dense warnings and hints
i'm not that good with git so even though i read it i assumed i did something
newbies tend to see a wall of text and freeze up
cause i had never seen it before
with git, the best thing you can do is get up, take a deep breath, walk around for a minute, then come back and read the message π
the first 3 steps are necessary btw, otherwise the 4th step doesn't work
so thought maybe i had also changed something in the background to cause this
haha
thanks git is really scary to me for some reason, and it feels like an endless wall of CLI options
thank you for answering my worrying self, glad to know i hadn't done something without realising
i'll set it up and happily get on with my day thank you!
thanks git is really scary to me for some reason, and it feels like an endless wall of CLI options
because it is an endless wall of CLI options. the underlying system is pretty straightforward and kind of elegant, but the CLI is huge and complicated and definitely has a learning curve
GUIs are generally even worse, and in my experience aren't helpful unless you already know the CLI
lol i watched a video by corey scafer ages ago and it left me feeling better about it
but there's so much out there
and i'm fine with the normal workflow
cause it's just me on my own projects
but when something goes wrong i haven't a clue lol
it helps a lot if you understand how it works under the hood. it's so simple that once you learn it, you're going to get annoyed at the CLI for being so complicated
lol
i've read a little bit and watched a few videos, comparing to svn or non distributed systems
and it made sense
and simple
but i have yet to read up on rebasing and anything else outside of commit/add/init/pull/push
so the concept is simple lol
but resources around git have just scared me away from learning more lol
https://git-scm.com/book/en/v2 this is the best git resource
thank you, i'll definitely have a read through as i know it's something i need to know
you need to read it slowly and carefully, but it is the best single resource, other than the manual pages. there are also a handful of very useful and high quality stackoverflow answers
as a rule of thumb, the longer the SO answer, the more useful it is
always read the comments too. beware answers with arguing in the comments
100% i always like to read opposing arguments, get a lot of out of it like reading bad reviews on good products
π
good
thank you again for answering earlier
So I forked this repo on github, and cloned it to my machine
Is there any way I can check to see if my fork is up to date with his repo from the git bash? Do I just need to set the upstream to his repo?
yes setting an upstream remote and the git fetch should be fine
you can just do git pull to sync local w/ the repo
I had this
what does it mean exactly, because i don't know when and where i created a conflit, and how to fix it
The reflog
This means that git cannot automatically merge two versions of this file
You need to manually select which code you prefer
but i don't see where the conflit was created
and how do i do that ?
You have a name of the file - games.py
Run git status please
As you can see games.py is not ready to be commited
Open this file
You should see something like
<<< ...
XYZ
=== ...
ZYX
>>> ...
yes, i see it
So you need to manually select which code you prefer (maybe both?) and then git add games.py and git merge --continue as far as I remember
I choose by deleting the other part ?
Some editors have pretty visual window for that, if you don't have any you just delete the code which you don't want (with <<<, ===, >>> parts)
Save and commit
The commit message is okay
so i write commit okay ?!
Just close the opened file
and now it's good ?
Looks okay for me
just a little last question, what does --continue
In git merge --continue?
yes
The third syntax ("
git merge --continue") can only be run after the merge has resulted in conflicts.
So when you have merge conflicts you resolve conflicts on your own
And just tell git to "continue merging"
ok, thanks for the help and explanation
π
anyone help me to encode py
I'm having trouble mounting my sqlite database folder as a volume for my docker container (the project is a discord bot).
For obvious reasons I want my sqlite database to be persistent and before I was using docker I was just running the bot on my PC and my database's folder was just in the same directory and I know that your supposed to be able to mount a folder in your build dir as a volume which would appear in the same place in the container.
It's been a week or so, so I don't quite remember the steps I took to try and mount my database's folder but I just remember not being able to get it to work. Sorry if I'm explaining this poorly.
can anyone help me with installing talib in python visual studios?
i have been at this issue for the whole day
it says it is installed but it wont import to visual studio
Aren't you using docker-compose?
yes
anyone has experience deploying on digital ocean droplets. I just started a new droplet and the memory is constantly at 30% with nothing installed. is this normal?
version: '3.8'
services:
web:
build: .
volumes:
- ./any_folder_or_file_name_for_relative_path:/absolute_path_to_folder_or_file_with_sqlite_database_inside_the_container
30% of what? if your total is 512mb or 1gb, then it is quite normal
how to share a folder between two containers in docker-compose
with consideration that a new file could appear in this folder during runtime
as an easy solution I see so far... just tying volume in both to the same filesystem where I run docker compose
I am just not sure, is it possible to tie volumes directly between containers, skipping the third member in this chain?
Well hello there. To start off i want to say that i am totally new to this topic. But lets get to the problem. Me and my collegues now use github. There we are working on a python project runninh on an ubuntu server. But we still need a proper way to run our program. Also we want to get updstes we make to easily run on our server by just a button press. I have read alot about deployment etc. But i still cant really get my hands on it. I would really appreciate any help
docker-compose is the easiest choice
not promising the graphical button, but update would be quite easy in one command
git pull && docker-compose up -d --build
And would it be possible to do that with github actions?
oh yes, I think it is surely possible
then it would be with graphical button
you are right)
I just did not reach that stage yet%
Ok so then im gonna learn docker ig
sure. it will help to make graphical button anyway later
because those both technologies basically use docker
Well another question is it possible to run multiple programs like that with docker?
clarify in which way they are multiple
So we have 2 totally seperate projects we are working on. Both running on the same server
It would be all good to run them both
as long as they are
- not having the same container names
- aren't having conflicts in final exposed to be outside of containering system ports
Well those programs are already runnibg at the same time so they shouldnt conflict
:D
I run dozens of containers on just my pc π
So then i would setup 2 docker containers one for each program
to have full sandbox for testing
basically yeah, but at the same time docker-compose allows multi containers for one program
if the program needs dependency, redis, celery, nginx, or even postgres
we can put them in docker-compose file to be run at the same time with your web application container
(the octopus in the picture named docker-compose)
Well its not a web application
Guys, is it possible to create a Streamdeck with python and tkineter?
Looks like a dead channel
I'll leave my question here anyway
How do I request access to a group in gitlab?
And also can I put them as a reviewer when making a merge request?
Dead channel indeed
Hm?
See above
I am not using GitLab π¦
How about this? https://docs.gitlab.com/ee/user/project/merge_requests/
Hey all, hoping this is the channel for it - wanting to set up a multi-user environment for analysis, automation, and ETL tasks but operate in an org with strict Windows-based security. Is there any place that I could go (reddit or similar) to post my full question and get some feedback?
stack overflow
Hi does anyone use coc for neovim?
Why not use lsp when they are supported by default in the nightly build?
hi i'm very new to git and github (started a few hours ago) i'm trying to collaborate with a friend of mine. so i cloned a private repo of his to my pc with git clone
i made a few edits to one of the files, and then i git add . and git commit it too
when i try to git push it, it gives me the following error:
error: src refspec master does not match any
any help is appreciated, thanks
Try git branch and see if you have a branch called main
You probably renamed yours to master
That means you have uncommitted changes
Use git commit -am "commit message"
This will add all files to staging area and then create a commit with commit message as the commit message.
hi, so earlier i was doing git commit origin master and it wasn't working, switched master to main and it worked
thanks @leaden tartan and @supple venture
devops confuses me a lot
could someone tell me in general what it is
like im see these graphs online but it is still confusing
Ah that was it, I was wondering how it is telling master when your git branch shows main. No problem
this explains it better than I can https://aws.amazon.com/devops/what-is-devops/
thank you, ill give it a read
hey guys, i am really new to programming and am trying to make a web app, i am building the application front end in svelte and backend in fast api. i have noticed that svelte needs nodejs to run and fast api requires uvicorn, so my question is that, while deploying my app will my app require both node.js and uvicorn for frontend and backend seperately, in which case wouldn't i be better of using nodejs for backend too in order to reduce the load on backend since i can avoid running uvicorn completely and run backend and frontend both on node.js itself? sorry if this is a noob question, since i am new to the scene i havent got much idea about anything, any help is appreciated.
Is there any way to make PyCharm save input and output from the debug console to log?
have you try this: https://www.jetbrains.com/help/idea/setting-log-options.html
How do you typically install a version of python on a docker image? Locally I tend to use pyenv, this is on mac OS, is that the typical approach within a docker image too?
seems that it might be a bit clunky, is deadsnakes used instead of this?
so im wondering if i wanted to install 3.9.1 specifically, rather than 3.9.6 or whatever
Not that experienced with docker, but wouldn't you just get the image with an older tag? for example one of https://hub.docker.com/_/python?tab=tags&name=3.9.1
i'm using an ubuntu base image and installing python, not using a python image specifically
i installed with deadsnakes, but then i have python as python3.9 instead of python π€
i can create an alias to alias python="python3.9", this feels pretty fragile tho (I'll have to update it when using 3.10 etc)
Pyenv does work on mac fwiw
Could also build from source i suppose. You're using a macos docker image? Seems unusual
Svelte only requires node.js on your development machine, not on the server. It compiles your svelte code to plain old .js files, which you can put in a "static" folder, alongside your css files and images.
To serve the static files: During development, you would typically use your backend framework's dev server to serve both the backend functions and the static files. In production however, you would let the http server (eg nginx) deal with static files directly rather than send requests for them to your python app: http://www.uvicorn.org/deployment/#running-behind-nginx
So, choosing to use python or js for the backend is nothing to do with performance, it's just a question of preference. If you're new to programming, you may want to do the backend in js so you don't have to learn two languages at the same time. Python is nicer to work with though - maybe we're biased around here ;). Svelte is pretty cool btw, good choice!
I tried serving the compiled files using a python http.server but it just showed a directory structure, I think it might be because I am using svelte kit and during compilation it uses an adaptor to specific platform, currently nothing is available for any python platform, the 2 main ones are for node js and to make a static website, but static doesn't work for me so I tried node adapter and it says that the output is a fully contained node app, I checked the build folder and ran it using node and it worked fine, however you are correct that it only has js files so I do not know if I can serve it with ngnix, ps: it does not have index.html in the build??, BTW I learned python too and built most of the backend in fastapi, and I liked how simple and straight forward many things are π
xD, good luck
I had pull requests which I.... continiued for year until they were accepted%
or became a part of graveyard
this is my own project lolol
well, then no problem
yeah
thing is...
104 conversation
I had over 67 unresolved comments earlier
now its 20 lolol
why was that so tiny lol
fixed
lol
so uh
most of them were big changes
55 of those commits were from a different person
Noooo sorry, other way aroundπ local is Mac, docker Ubuntu
I might try pyenv, wasn't sure if it seemed overkill given there's only one version to use, so was curious what was typical. Pyenv is fine though
Is there a way to seperate dev dependencies and production dependencies by a tool?
both pipenv and poetry allow this
alternatively if you maintain a requirements.txt you can include requirements-dev.txt in your repo too
or another filename of your choice
it's not overkill at all in my opinion, it's a great tool
yea i like it, wasn't sure if there was some other approach for docker or something
some noob question - how to get rid of:
/usr/local/bin/python3 /Users/xxx/Downloads/sublime/python/web_scraping.py
xxx@Mac-mini-xxx sublime % /usr/local/bin/python3 /Users/xxx/Downloads/sublime/python/web_scraping.py
from visual studio code's terminal and leave only the code output part? Just like its by default in sublime text when using "Build"?
found it earlier, its dependent on marshmallow
note: this is entirely topical, since configuration variables have to be set depending on environment :)
and marshmallow has an SQL Alchemy bind
I have been pydantic from a while btw, and coudl you open up a bit on seems better than python-dotenv
which means we would be able to easily write models and have them loadable from env or database without much if any extra work
ye, see above
!pypi marshmallow
interesting, better than python-dotenv, similar to pydantic
ye, that's what I was thinking
And by wrapping marshmallow, we can have very nice structs
It's kind of the "original"
Pydantic is like marshmallow+attrs at the same time
You might want to use attrs with slots=True for that
Other related art:
https://desert.readthedocs.io/en/stable/
https://mashumaro.readthedocs.io/en/latest/
https://pypi.org/project/dataclass-factory/
What Python tools do I need to develop a 3D game?(except the ursina library)
Hey, I am trying to set up verified commits in Git using GPG key.
These are the steps I have followed:
https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/generating-a-new-gpg-key
https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account
Now when i want to sign it as the following link suggests:
https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/signing-commits
I get an error which is:
error: gpg failed to sign the data
fatal: failed to write commit object
When googlin' I found this on SO:
https://stackoverflow.com/questions/41052538/git-error-gpg-failed-to-sign-data/41054093
Only the answers provide a bunch of info which I don't really know whats wrong or right.
The thing I also do not understand is the whole GPG(1 & 2).
I am setting it up in Linux (Raspberry Pi).
If you don't have an existing GPG key, you can generate a new GPG key to use for signing commits and tags.
To configure your GitHub account to use your new (or existing) GPG key, you'll also need to add it to your GitHub account.
You can sign commits locally using GPG or S/MIME.
@brazen imp GNU Privacy Guard aka GnuPG aka GPG is an implementation of the PGP system. GPG is so common that a lot of people use GPG to mean PGP (it doesn't help that the names are so similar). GPG 2 is the current version of GPG.
so my initial question is: did you actually install GPG?
Thanks for the explainer!
Yes, otherwise i could not create the GPG key
fair enough
and you see your key in the output of gpg --list-secret-keys --keyid-format=long?
Yep, that results in 1 key
and do you also see that key in git config --global user.signingkey or git config user.signingkey?
hm
you went through the troubleshooting steps in that stackoverflow post?
might also be worth making sure there isn't accidentally some whitespace in your git config
Well, the thing is when i try to set the gpg2 as main and run that gpg2 command it says that gpg2 isnt found.
I also find it tricky when they ask to install new stuff or delete folders.
I did try this:
run echo "test" | gpg2 --clearsign, to make sure gpg2 itself is working```
but that didnt work; resulting in gpg2 command not found
And since i try to on my Pi I would suggest that the newest software is on it
@brazen imp maybe on your system gpg is GPG 2
i can't remember what it is in debian
When i remove the 2 it works lol
brew is for Mac right?
I also noticed that I had to use my noreply github mail instead of my primary mail. Is this correct?
Note: When asked to enter your email address, ensure that you enter the verified email address for your GitHub account. To keep your email address private, use your GitHub-provided no-reply email address. For more information, see "Verifying your email address" and "Setting your commit email address."
which vps is better in case of storage? Galaxygate or vultr?
Okay, I'm not sure if I dreamt this up or not. Is there way to have pyenv work directly with pipenv or Poetry? I could swear that one of those two had a built in way to work with pyenv
Deep breaths
AARGH
i dont get it 
now i get that a private mail will be published with commiting
wth
Well, almost fix lol
but i dont get it
Why would you give up as global your no reply email?
nvm.
I fixed it :)))))
@stable cloak pipenv has built in support
Poetry doesn't
But you don't need the intergration for poetry
For poetry, just run pyenv local 3.8.11 3.9.6 or whatever versions you need
Then you can use poetry env use 3.8 and poetry env list
Gotcha, cheers
pipenv should find pyenv-installed pythons on its own
you were probably thinking of that
Yeah I think so
and pipenv will offer to install if they aren't found @iron basalt
what does git prune do?
https://git-scm.com/docs/git-prune usually not something you need to do
https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain worth reading this chapter if you want to understand the low level stuff
well
git complained and told me to run it
See "git help gc" for manual housekeeping.
warning: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
weird, never had that problem before. maybe just run git gc?
i ran git-prune.. Β―_(γ)_/Β―
it's not a dangerous operation, unless you were actively trying to undo a rebase or something
ah
pls answer
how about just finding few github repos with used ursina and checking what is used there.
as alternative in the case when no one was able to answer
okay, thanks
I remember seeing tutorial where in few steps minecraft...ish thing is made in ursina
repo for that could be cool to see
All right.
Who deault with payment gateway systems (if I named them right)
Stripe and e.t.c.
are there some weird requirements with them
like required residency in country X?
Sometimes in my commits message, I like to include ` backticks to highlight functions/vars etc. But when i do that zsh takes it as an eval command for example "Add documentation for `my_function`" so zsh evals my_function
how can i not make it do that
use core.editor instead of -m
Hey! I'm using pre-commit and I want to ignore a dir by using exclude but when I commit a file in migrations dir, it's still running hooks. How can I solve this? Here is my .pre-commit-config.yaml
default_language_version:
python: python3.9.6
repos:
- repo: https://github.com/psf/black
rev: 21.7b0
hooks:
- id: black
exclude: ^migrations/
args: ['--line-length=79']
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
exclude: ^migrations/
i always get nervous with unquoted strings in yaml
markdown must kill you then
Does postman provides good documentation for API. If yes why when doing some research, I found always that swagger and openAPI and few other are always more recommended.
It is a documentation that must be prepared for a front-end developer to ingrate the services in front.
I could do that but is it possible for general cases, like when piping something to a file, etc. to not eval that selection in zsh shell
actually, use single quotes
?
postman does support openapi, i personally would go with openapi for interoperability
Thanks. What about generating docs with postman and from postman collections without using openapi
i haven't done it myself, i've mostly used postman for testing (with the newman test runner), but nowadays my org uses cypress for that purpose
i know its difficult
Any tips where do i start with managing ML models?
Preferebly some local frameworks maybe?
<@&831776746206265384>
!rule 5 HI @midnight briar, we will not help with that
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Good day everyone, I am wondering how you all approach integrating your front-end with your back-end source without putting everything in the same project. For instance, looking to use React on a small portion of my site. How can I keep my React code in another project, but have easy access to development?
So what I mean by this is, say I have my main website thats FastAPI etc. I want to serve React on a particular route, but don't want the raw tsx files etc in my FastAPI project. Whats the best way to be able to keep them in separate projects but develop against it? I'm working with React and right now doing oauth so I'll need a server to help broker the response
I understand for deployment I could just copy the build results... Is there a workflow that you've found works for rapid development?
I typically use a submodule approach.
I've heard of those (git submodule I'm assuming). I'll need to look into it more
does it add it as a dependency? It wouldn't pollute my project with the code, right?
No its just one or more git projects inside another
I'd share a link but it's a private repo
no worries
so it does look like it commits it
I can see this is still some separation though
ok
It's a fairly easy concept
is it easy to develop on, or you have to commit/push each change to test?
also looking for QoL on dev'ing haha
Elaborate?
I change a source file in the React project. Do I need to commit and push it for the backend to recognize the change?
No you have to just push it to the remote
But yes you have to update the parent git project to recognize these new commits
ok
for use in a pre-commit script I'd like to use Python to write a cross-platform compatible check to detect files that should have the +x mode set, e.g. various scripts with shebangs, *nix binaries for various architectures
mimetypes.guess_type() seems worthless for that, it says none for all curl-aarch64 etc. binary files I gave it, it detects foo.sh as application/x-sh but when renamed to foo it says None, so it seems to just guess based on extension
GNU file utility in linux would be perfect, but it doesn't exist in Windows
I found some library for telling me if a file is "binary", as in it says a JPEG is a binary, so that doesn't take me very far either
googling for "executable" gives me checks for "if the executable flag is set"
basically I'd want results similar to grepping this output for executable
that's cygwin file if you're wondering
most search results for "python elf" are some malware analysis things
some python-libmagic thing exists, but it crashes on install, hasn't been updated in 5 years
python-magic is more recent, installing works, import magic quits the python interactive shell
seems to depend on some separate binary libraries that can't be installed easily via pip so not a starter
@rich remnant have you looked at pathlib and os yet, both of which are part of the stdlib?
please be more specific, what part of pathlib or os do you think offer detection of the contents of files?
!d pathlib.Path.stat
Path.stat()```
Return a [`os.stat_result`](https://docs.python.org/3/library/os.html#os.stat_result "os.stat_result") object containing information about this path, like [`os.stat()`](https://docs.python.org/3/library/os.html#os.stat "os.stat"). The result is looked up at each call to this method.
```py
>>> p = Path('setup.py')
>>> p.stat().st_size
956
>>> p.stat().st_mtime
1327883547.852554
!d os.stat_result
class os.stat_result```
Object whose attributes correspond roughly to the members of the `stat` structure. It is used for the result of [`os.stat()`](https://docs.python.org/3/library/os.html#os.stat "os.stat"), [`os.fstat()`](https://docs.python.org/3/library/os.html#os.fstat "os.fstat") and [`os.lstat()`](https://docs.python.org/3/library/os.html#os.lstat "os.lstat").
Attributes:
and how does stat() tell me if the file is actually a binary ELF executable without the +x mode set?
or foo is a #!/usr/bin/env perl script with no +x set?
Read the os.stat_result
I am pretty familiar with stat()
One of its attributes is st_mode which I think is what you want
I've now several times specified I don't want to know if the +x mode is set
I want to know the if the contents of the file are indicative of it being an executable
because I want to write a pre-commit hook that makes them +x when the developer adds something to the repo and forgets to +x it
no worries π
Afk
this looks almost hopeless enough to just delegate the problem to pipelines to automatically run file on a predictable Linux environment and commit a +x change when appropriate
but I don't really like that option
the libmagic source is apparently only available via ftp://, ftp support has been dropped from browsers a while ago 
oh cool https://github.com/file/file there's some mirror of their .. CVS repository
@rich remnant I Also found this https://github.com/joeky888/fil
I think I could work with that, thanks!
oh hm
custom implementation of the detection, seems a bit unreliable
maybe I could use the logic in it to just detect ELF binaries and then write some custom shebang detection to go with it
Any Pylint (or other similar tools) experts in here?
how would you go about catching errors like these:
def func(arg_one, arg_two, kwarg_one="default"):
pass
func(positional_one, keyword_one)
In this case, the user is "forgetting" to specify arg_two, but the linters would pass this since both positional args are filled. Any suggestions on how to catch this?
I could imagine this being fixed by not allowing keyword arguments to be specified positionally like above, but how would I do that?
oh there's annotation for explicitly kwarg or positional args
so afaik just change it to
def func(arg_one, arg_two, *, kwarg_one="default"):
pass
and for the reverse https://docs.python.org/3/whatsnew/3.8.html#positional-only-parameters
@rich remnant Thanks, that would fix it yes, But I hate how it looks haha
unfortunately nobody seems to have come up with an alternative syntax Guido would've approved so we're stuck with his quick thought from 2012 https://mail.python.org/pipermail/python-ideas/2012-March/014378.html
hey guys, may someone help me please. I know linux in not python but probably someone here uses linux, I want do install linux in my windows 10 computer but I don't know the best way to do it
we have even #unix channel for that
anyway, I recommend using rufus to make USB installer from downloaded linux distro
i went with just Ubuntu, quite friendly OS.
some people would disagree with me though, but that's totally because somepeople aren't satisfied with GUI
but for developers GUI is a really secondary thing to use in my opinion, so... ubuntu makes the job quite well in providing easy to use console installations
ok thx
Install Linux as in replace Windows, or in addition to Windows?
If you want to dual-boot it will likely be nothing but a pain, you need to disable secure boot etc. for Windows to get Linux to boot, and Windows will happily try to make your Linux unbootable every time there's a major update which is a few times a year
If you want to replace Windows you still need to disable secure boot and prepare for a lot of pain with hardware support etc.
Running Linux in a VMware/VirtualBox VM is super easy though, assuming you have Hyper-V disabled and so e.g. don't use WSL2, if you do you're pretty screwed - Hyper-V is the least compatible worst performing hypervisor available for this kind of things and basically incompatible with VMware and VirtualBox, and when in rare scenarios it's technically compatible those other hypervisors run at laughably slow speeds comparable to pre-hardware accelerated virtualization making the VM practically unusable
hey guys, I want to create a conda env in docker. This is my code
conda init bash &&\
conda create --name layoutlm python=3.7 &&\
conda init bash &&\
exec bash &&\
echo "source activate layoutlm" > ~/.bashrc &&\
pip install -r requirements.txt
when I run the container and do pip freeze, the requirements are not installed.
How can I solve it ?
say somebody committed their API key to a PR on my project, how could I completely remove that commit from git's history and remove all references to it, so it can't even be checked out?
Hmm, probably you cannot do it, just tell this person to revoke the API key
oh, so there's no way to permanently remove commits?
I believe you can rebase and force push, but it will break everyones clones
Some commits can be still available, even without being part of any branch
yeah, that's the problem, so git doesn't actually provide a way to remove the commits completly?
sort of not really
force push would only happen on a specific version that's in that person's fork though, so it shouldn't be a huge issue
Github still keeps the commit
Your strat is contacting github and asking them to delete the commit
Some Stack answers: https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github
yeah, that would probably work
But honestly just reset the token.
they are quite eager to not have credentials in the repos
yeah, that makes sense, thanks for the suggestions
Not true.
?
Depending on the branch, force pushing is not always a viable option
Oh wait I misunderstood nvm
This token should be treated as compromised
Yes
π
git reset --soft HEAD~1 to remove the last commit
--soft so that the difference stays (but it is not git added yet)
to completely remove it you can use git reset --hard HEAD~1
HEAD~n is how many commits back do you want it to go
As far as I remember I tried this method on GitHub and commits were still in the history


