#tools-and-devops
1 messages Β· Page 9 of 1
https://pythondiscord.com/pages/resources/guides/asking-good-questions/ there is also local guide how to ask questions in a good way, also recommending for reading
A guide for how to ask good questions in our community.
Is anyone here good with image processing and selenium?
we will never know unless you ask you actual question π
Sorry, the problemβs already fixed
But Iβll keep you in mind for the next inevitable bug in my code ππ
I've spent the last couple weeks on a side project to help devs navigate and understand complicated codebases. You can check it out at https://mabbu.app/. Any feedback would be dope π!
Quite funny and graphically attractive
Probably very useful as resume project, but practically useless
The visualizations looks similar to a tool called CodeScene. I can see that it can be useful for reasoning about code and the hotspots. Are you aiming to do something in the style of CodeScene?
A bit worrying is that your twitter account seems to have been shut down due to violations, what happened? π€
I'm currently developing an API on my local computer and I'm looking for a guide on how to containerize it using Docker and run it on my VPS. Could you provide some guidance or point me to a relevant tutorial?
if you have any further ideas please share with me
Which package are you using to build it?
and what stops you?
here's a description for FastAPI
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Should be helpful for other packages as well
Yoyo, if I can for sure, what's the matter?
Not sure how to proceed with this; I have an application that uses both Node.js and Python
I wanted to place them both inside a container, but I'm not entirely sure how to go about it; am I supposed to contain them separately or just squeeze them inside a single container? How would the communication between them work?
I've been entertaining just placing them under separate containers, but I have zero idea how that would work
I've googled it and it says that I should do that, but I wanted a second opinion
It heavily depends on the architecture of the app and how the modules can communicate
As of now, my Node consists of the D3 data viz lib, as I'm doing some stuff with graphics and so on
Python is Django to deal with API and general backend
Python feeds data to Node, Node returns graphics, Python delivers to Frontend
Do you need more context?
It seems each module can be independent so yeah it might be possible. You'd need to make your application modular so that API calls can be made between the containers.
Ic, I'll research a bit more about how I can make this happen
There's not that much to it.
FROM python:3.10
WORKDIR app
COPY myapp.py .
ENTRYPOINT ["python3.10", "/app/myapp.py"
example container specification to run a python program
FROM python:3.10
WORKDIR app
COPY myapp.py .
COPY requirements.txt .
RUN pip3 install -r requirements.txt
ENTRYPOINT ["python3.10", "/app/myapp.py"
with your dependencies.
Anybody experienced with initializing embedded python environments in c++?
Not sure if there's a better channel that fits this use case. Let me know
it's normalish. yes, you can change it.
Hi everyone! I hope this is the right channel to post this. 
I'm looking for feedback for a tool we have just published. The tool is an AI-powered vscode extension, only available to analyze Python code. How it works is that it analyzes code using a graph-attention-mechanism which also stores contextual information of the code in the NN.
We then pass those detected problems along with their contextual info to an LLM, in hopes to generate context-sensitive descriptions for the problems, and code recommendations to help instantly solve them.
The tool was just released and I'm looking to learn as much as possible about its use cases and value through providing it to python users. It is of course free. The link to the tool is here: https://marketplace.visualstudio.com/items?itemName=Metabob.metabob
Any feedback would be appreciated and very helpful!
Hi, I need a help with linux server related stuff.
Basically, i deployed a discord bot on aws EC2, with tmux to keep it running in the background after exiting the session. But i made a mistake. I thought that killing the tmux session would kill the whole processes inside it, but it didn't. So now I have 4 processes running the same application/program. How do i fix this? I want to delete all the unnecessary background processes that i was supposed to delete. OR, i would like to just remove all the application processes without ruining the server. Please help, thank you!
This might not be the right channel, but i was contemplating between asking it here or in networking.
i figured i can just kill a certain processes, but there is more than one for each running application. and i don't exactly know which processes to kill even if i do it manually.
ps aux command shows running processes and their ids and names and commands that launched them
Kill them. Find needed processes and kill
If u a merciful, u can send them SIGINT signal to ask nicely to finish. And only if they don't react, kill them with SIGTERM signal
https://www.baeldung.com/linux/sigint-and-other-termination-signals
Found guide on signals and different ways to exit process
First or second column of ps aux column is process Id i think, which is needed to kill
If you get to use htop you can use that, select multiple processes and kill them all right then and there
oh yeah, I was using htop, but i don't know what are all the processes that i need to kill..
thanks btw!
hmm somehow, sending kill SIGINT signal to one main process that i was running ended up deleting the rest. i don't know how. but i guess my problem is fixed now
thank you guys! @rapid sparrow @edgy relic
nvm it seems like the background processes comes back after i run it again, well, i'll figure it out, i think i'll just try deleting it one by one with htop while they are running
thanks a bunch!
Does anyone use Python CLI tools which are annoyingly slow? E.g. I find the AWS CLI annoying, it never responds in less than about half a second.
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Okk okk 
gcloud is also python based. Depending on the command it can take some time to answer yep.
Indeed, gcloud is quite slow to start, over half a second!
@rapid sparrow @edgy relic killing processes didn't work. what works tho, is reinstalling tmux, and now it works fine. you guys don't need it but i just think it's nice to let you guys know hehe. again, thanks for the help.
a vscode theme i am working on
i am still working on it, probably gonna interchange the variable color with string
Hi everyone,
Running into probably what was a typical issue a long time ago for most
Already tried to follow the guides at https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls but no luck.
Can anyone help? π¦
Don't be pervert. Use ssh keys for auth. It is good default
I want to.
But I don't know how π
The guides are too "complicated" for me
easy shortest guide for most simple setup
- install git bash, which comes with this https://git-scm.com/downloads
- open
git bashterminal - write
ssh-keygen, enter, agree to all defaults(enter/enter, whatever amount of enter key presses). (key should be created at ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub paths) - open
~/.ssh/id_rsa.pubwith notepad, copy from it content. - open github account, your profile settings -> SSh keys and GPG -> add SSH -> paste the content of
~/.ssh/id_rsa.pubinto it
proceed to use
git clone with SSH path provided by github. git clone <ssh path of repo>
and for repositories which were already cloned, you can overwrite/fix them with git remote set-url origin <SSH path as in screenshot for repository>
for linux git bash terminal step can be skipped. you can do it in any regular opened terminal instead, proceed straight to ssh-keygen step
git bash is for windows only
P.S. ensure to do instruction from the user which intends to use it, and not creating folders on your own. otherwise you can screw up file/folder permissions. and without admin rights.
All went smoothly, but still can't do a "git push origin master" π¦
I'll have to try and find someone next to me or do a screen sharing or something
we can't help you without knowing your error
Got different after I did the remote
Try running the suggested command
have you tried reading the error? Type of problem
I didn't even see it completely sorry.
Yeah seems to be working π π π
Although it keeps throwing the warning anyway
Delete file known_hosts and try again
Working perfectly!!!!
Thanks a lot Darkwind π₯³
that may work here but don't adopt that as a general thing to do when you get that error
:incoming_envelope: :ok_hand: applied timeout to @heavy knot until <t:1684510794:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
Hi, does anyone know which virtual machine I can use to run MacOS in Windows?
Do you men which virtualization software to be able to have a macos VM in windows?
Yeah, that's what I meant
Whatever you want... VirtualBox is pretty easy
@nova pawn Heya sorry, but we don't allow these sorts of unapproved advertisements in our server
It is not ad, I post in help section, then someone ask me to post it here
I'm just ask for contributors in this project
I'm not sure why they'd point you here, and being a place for asking for contributors just isn't really something this server is a place for
Its still advertisement of your project though, so I'm still gonna ask that you delete it
How it is an ad if I sell nothing!, also the project not owned be me
I delete it any way
Pretty much any virtualization software yep. Depending on your need you could also have a macOS runner (GitLab) or a macos image for your actions (github)
adΒ·verΒ·tise
verb
verb: advertise; 3rd person present: advertises; past tense: advertised; past participle: advertised; gerund or present participle: advertising
describe or draw attention to (a product, service, or event) in a public medium in order to promote sales **or attendance**.
"a billboard advertising beer"
**seek to fill (a vacancy) by putting a notice in a newspaper or other medium.**
"**for every job we advertise we get a hundred applicants**"
h
Similar:
publicize
make public
make known
give publicity to
bill
post
announce
broadcast
"Meryl coughed briefly to advertise her presence"
You don't have to be selling something to "advertise" such as the job example. "For every job we advertise" They aren't selling something, they are actually buying / spending money in this case (an employee's time)
@rapid sparrow is there a command prompt version of Docker that carries less space than the GUI docker?
will be available to get started as docker version docker run and etc commands.
see for structured course into docker (CLI oriented)
I use Windows. I don't have Ubuntu.
technically Ubuntu will be available for you with WSL2 (if you are on some kind of win10+)
you can't use in a normal way Docker without Linux. you will end up with some kind of virtualization if on windows (for example using WSL)
Docker at the moment OS architecture depended. All images/open source solutions used under the hood use linux for it
Ahhh. This makes more sense why Linux is the preferred OS for software developing.
also, consider switching to Ubuntu/Kubuntu/Linux for Web development. i think it is prefered OS for web development
not for software development, but for web development it is certainly prefered (if you plan doing backend or devops at least)
some people prefer linux for all software development though (me included ^_^)
I thought software development and web development can be used interchangeably? Because I would be seeing job postings that are titled "Software Developer" and in the job description they list things like HTML, CSS, React, JavaScript and etc.
see the beauty of Kubuntu 22.04 LTS. ^_^ GUI heavy, but really nice to use Ubuntu with KDE plasma
no. this is just a poor kind of HR job role writing.
There is more to software development than web development
desktop / mobile / embedded developments are kind of totally not related to web dev, yet they are software development
Yeah I have used Ubuntu before but on a virtual machine.
My Laptop's hard drive VS my external hard drive
60GB? π
Downloading Docker takes up 8% of my Laptop's hard drive.
And I can't even run Docker from my external drive
It's been at least a decade since I've seen a windows laptop with such a puny drive. Aren't 256GB drives like $20 now?
I have no idea.
Definitely time for an upgrade... https://diskprices.com/?&condition=new&capacity=-1&disk_types=internal_ssd
Comparison of all hard drives and SSDs on Amazon, sorted by price per TB
I am trying to build my first docker image or whatever you call it and this is what popped up on my terminal.
=> [internal] load build definition from Dockerfile 2.1s
=> => transferring dockerfile: 101B 0.3s
=> ERROR [internal] load metadata for docker.io/library/node:apline 13.9s
------
> [internal] load metadata for docker.io/library/node:apline:
------
Dockerfile:1
--------------------
1 | >>> FROM node:apline
2 | COPY . /app
3 | WORKDIR /app
--------------------
ERROR: failed to solve: node:apline: docker.io/library/node:apline: not found
my Dockerfile code
FROM node:apline
COPY . /app
WORKDIR /app
CMD node app/app.js
typo: should be node:alpine
Works like a charm. Thanks a lot!
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-docker latest e2dd4b9ab339 About a minute ago 180MB
This is really cool. I feel like a DevOps Engineer.
with this disk dize, you will have very limited options to work with docker 
it consumes additional memory on each open source docker image load
it consumes additional memory on each docker image build
it is possible of course to wipe all the time with --rm, down --volumes, docker system prune --volumes and etc
but it is not going to help a lot
Linux is kind of more space efficient system, with ncdu installed and sometimes used to clean system, you could survive for more time
i still used 250 gb even on linux though
60 gb is not going to last long
pypi packages alone will consume all this space quickly if not erased
Hi guys. I have an issue with working with docker. currently following a tutorial. I have an image built but getting a: docker: Error response from daemon: unable to find user nonroot: no matching entries in passwd file. Whenever i try to start the image in a container. I'm thinking of clearing the build cache and building the image from scratch. But doesn't still seem to address the issue of the "user" not being found. What is the best approach to solve this?
looks like incorrect docker installation
let me send the docker file for the build
wipe and reinstall again, official instruction contains instructions for that
FROM golang:1.19-buster as build
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
###
FROM scratch
ENV GIN_MODE release
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /app/api-golang api-golang
USER nonroot
EXPOSE 8080
CMD ["/api-golang"]
okay, would do this then
clarify, do you get the error when
when it reaches USER nonroot
or when u launch docker image build π€
Yes it does. When i build the image i get no errors. Only when i start a container for the image
okay. USER command may be not creating user then.
try creating user with manual command and then activating USER
you know adduser command
Error response from daemon: Cannot restart container api-golang-main: unable to find user nonroot: no matching entries in passwd file
for linux yes
wait a second
do you have rootless docker?
kind of new to docker so i don't get what you mean. But since i'm creating the containers and the builds i should have root docker as well i'm guessing. Or am i missing the context of what you mean?
i mean, did you install docker on your own?
did you install default docker version?
or rootless docker modification
checked our images
FROM public.ecr.aws/docker/library/python:3.8-bullseye AS builder
# Setup user
RUN useradd --system --user-group nonroot --create-home --home-dir /home/nonroot --shell /bin/bash
# Switch to unprivileged user
USER nonroot
we create user manually first ^_^ you are missing user creation step
yes i did
i was using ubuntus docker.io previously but had to install docker desktop edition and then had to download the docker-ce as well
but i had this done for a different image like from the previous file and the container started successfully. Would send the dockerfile for the other container working
FROM node:19.6-alpine
WORKDIR /usr/src/app
ENV NODE_ENV production
COPY package*.json ./
RUN --mount=type=cache,target=/usr/src/app/.npm\
npm set cache /usr/src/app/.npm && \
npm ci --only=production
USER node
COPY --chown=node:node ./src .
EXPOSE 3000
CMD ["node", "index.js"]
i think you're right
but i'm still kind of confused why this file worked even though there's no adduser or useradd to create a new user
- you could have launched
docker run -u root ...with user override - you could have launched old version of container before you added user (that will happen if u launched container with specific name --name=smth)
(compose automatically assigned container name,docker compose down --volumes --remove-orphansto stop and kill compose containers)
in order to make sure you aren't using old verions
you need to stop and kill previous existing containers
docker stop container_name
docker kill container name
(there is version that kills all)
and then rebuild docker image
and only then run
i added the useradd command and rebuilt from the cached build i had previously. Firstly, it didn't invalidate the cache which i thought it would since i changed the dockerfile from the top so it looks something like this:
FROM golang:1.19-buster as build
WORKDIR /app
RUN useradd -u 1001 nonroot
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
###
FROM scratch
ENV GIN_MODE release
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /app/api-golang api-golang
USER nonroot
EXPOSE 8080
CMD ["/api-golang"]
However i do have previous built images but i didn't specify a user whilst creating them. But it might have something to do with what you said
When i try to do a RUN ls after the --from=build i get a ERROR: failed to solve: process "/bin/sh -c ls" did not complete successfully: exit code: 1. Please can anyone point out what is wrong with the file
remote all commands below RUN ls, and RUN ls itself too. build image
docker run -it --rm image_name bash write to enter debug and check what u see
i get docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown.
ah, i see why
I tried doing this. The error starts from the FROM scratch line. Ls results in a no file or directory found
FROM scratch
does not contain shell or bash
u need to use some other image or to install shell/bash, or don't use shell after FROM scratch
okay. Even if that is the case. The build completes but when i try to do docker run -it api-golang i still get the no such file or directory but that still kinds of makes sense since you said there's no bash in scratch. But i'm not able to make use of the api
it unclear at which path you are located.
WORKDIR is not specified for scratch
CMD ["/api-golang"] is absolute path
you copied to relative path
CMD ["./api-golang"] is correct one
I updated the file and it looks like this:
# Pin specific version for stability
# Use separate stage for building image
# Use debian for easier build utilities
FROM golang:1.19-bullseye AS build
# Add non root user
RUN useradd -u 1001 nonroot
WORKDIR /app
# Copy only files required to install dependencies (better layer caching)
COPY go.mod go.sum ./
# Use cache mount to speed up install of existing dependencies
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
# Compile application during build rather than at runtime
# Add flags to statically link binary
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
# Use separate stage for deployable image
FROM scratch
# Set gin mode
ENV GIN_MODE=release
WORKDIR /
# Copy the passwd file
COPY --from=build /etc/passwd /etc/passwd
# Copy the binary from the build stage
COPY --from=build /app/api-golang api-golang
# Use nonroot user
USER nonroot
# Indicate expected port
EXPOSE 8080
CMD ["/api-golang"]
But still the same issue
https://github.com/GoogleContainerTools/distroless
# Start by building the application.
FROM golang:1.18 as build
WORKDIR /go/src/app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 go build -o /go/bin/app
# Now copy it into our base image.
FROM gcr.io/distroless/static-debian11
COPY --from=build /go/bin/app /
CMD ["/app"]
use distroless for minimum sized image golang runners, less headache will be
debian distroless matches debian build image. zero issues will be
let me try this. But i'm actually following a tutorial. Don't know if this would complicate following it but i might be able to find my way around
Scratch is a special zero weight image, as the most foundation image. part of docker special syntax pretty much
i don't know details how to utilize it tbh. it is used to build other stuff. for this reason it should be most challenging to use.
I used as smallest Alpine images (which will conflict with Golang build in debian if u don't disable CGO at least)
and distroless debians (as more easiest choice)
i would not care a lot and just used Debian slim though (69mb) π but distroless is best next choice to me for more optimized weight of image (20mb)
Alpine is even smaller though, just 5mb. tempting to use (but i don't like additional comlications)
i think debian slim is around 112mb or so. the image created by scratch is around 16mb
wrote image sizes, 69 slim, 20 distroless, 5 alpine
would try out distroless now
alpine image with shell and other stuff, 5 mb. scratch is supposed to be 0
in the meantime at my work we use 1 gb sized images xD (python libs are heavy)
don't know if i can change:
RUN go build \ -ldflags="-linkmode external -extldflags -static" \ -tags netgo \ -o api-golang
To then include RUN CGO_ENABLED=0 go build -o /go/bin/app as thisRUN CGO_ENABLED=0 go build \ -ldflags="-linkmode external -extldflags -static" \ -tags netgo \ -o api-golang
u can add env var as this before command
ARG CGO_ENABLED=0
in its optimized form or its base form?
okay
base/final form which nobody will try to optimize (i don't to deal with it too)
why are you not trying to optimize it? Is there any related implications with optimization?
too much code and dependencies. not very worthy the effort in comparison to other more pending/priority tasks
python is not very friendly to optimize in terms of docker image size in the first place (very hardly compilable)
both doesn't that become an issue overtime. With the container being bloated
there are other way more important pending issues π (code base and amount of microservices is huge)
makes sense. I guess that's where compiled languages shine. But since python uses C as base. What about having C on the container. Wouldn't that handle interpreting
till it later becomes a pending issue later in the future i guess
this is easily solvable issue with smth like "increase docker registry size / set policies for automated cleaning"
not really important in comparison to other more pending issues
okay, i get what you mean
This is how my dockerfile looks now:
# Pin specific version for stability
# Use separate stage for building image
# Use debian for easier build utilities
FROM golang:1.19-bullseye AS build
# Add non root user
RUN useradd -u 1001 nonroot
WORKDIR /app
# Copy only files required to install dependencies (better layer caching)
COPY go.mod go.sum ./
# Use cache mount to speed up install of existing dependencies
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
# Compile application during build rather than at runtime
# Add flags to statically link binary
ARG CGO_ENABLED=0
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
# Use separate stage for deployable image
FROM gcr.io/distroless/static-debian11
# Set gin mode
# ENV GIN_MODE=release
WORKDIR /
# Copy the passwd file
COPY --from=build /etc/passwd /etc/passwd
# Copy the binary from the build stage
COPY --from=build /app/api-golang api-golang
# Use nonroot user
USER nonroot
# Indicate expected port
EXPOSE 8080
CMD ["/api-golang"]
and i get a ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount1107096260/Dockerfile: no such file or directory
throw user change away. distroless image does not have anything for user to use
plus u create user in image Debian building, while changing user in Distroless
user does not even exist, because it is created in previous image
they aren't transfered to changed multilayered next image
okay
still the same issue
https://github.com/GoogleContainerTools/distroless/tree/main/examples/nonroot github of distroless has link for nonroot users though
perhaps it is still important
or you mean i shouldn't copy /etc/passwd
would uncomment it then
https://github.com/GoogleContainerTools/distroless/blob/main/examples/nonroot/testdata/user.yaml
they give hint to use nonroot user of uid 1002
it got written. Now about running it
Its still not working
but i'm not getting ano such file or directory error any longer
guess how much info it gives me? zero ^_^
Its not giving out any errors but the api is not accessible
how do you launch it? what show logs?
it has no logs. But when i do docker container ls, i get cf14ec5e95bd api-golang-main "/api-golang" 4 minutes ago Restarting (133) 22 seconds ago
How do u launch/run it ^_^
What shows docker logs cf1
Have u tested your application works without docker image?
Added logging records?
i did docker run -it --rm api-golang-main i also did docker run --rm api-golang-main. When i do a docker container ls i can find the image but no longs. And then i ran it finally doing :
docker run -d --name api-golang-main --network my-network -e DATABASE_URL=${DATABASE_URL} -p 8080:8080 --restart unless-stopped api-golang-main
cf14ec5e95bd51d5354cf603ddf835d8007dd0ec73af1c4e7f5b4a248248d59f
its three different containers. A react container with nginx, a node-api container and then this golang api container. The two works except for the golang api
The 502 is from the golang
cf14ec5e95bd api-golang-main "/api-golang" 4 minutes ago Restarting (133) 22 seconds ago
seems to indicate a reboot loop?
do you know what's exit code 133?
are there absolutely nothing when you do docker logs cf14ec5e95bd?
absolutely nothing. Please ping on reply
do you know what's exit code 133?
post output of docker inspect cf14ec5e95bd - and redact anything sensitive
no i don't let me check. Sorry for the delay in response
hey this is it: https://paste.pythondiscord.com/aximunilok
nothing interesting as far as i can see.
except maybe line 155? not sure if DATABASE_URL env var is populated or not..
i would try not using gcr.io/distroless/static-debian11 as base image first, just to rule out that's the issue, go for a regular debian image instead for now
@earnest forum ultimately i can't replicate the issue nor can i immediately spot anything interesting, i think the only path forward for now is to understand what exactly does the exit code 133 mean, and fix the underlying issue.
it is because the container i'm using for the node api which is different from the golang api is getting data from the db
have tried running the api without a multi stage build and it works without it. The issue is when the multistage build is implemented. So basically the same issue with distroless and scratch. Except for distroless. I don't get a no such file or directory error
Like I said, I would try not using distroless and use an actual fully fledged debian base image, just to rule out this being an issue with distroless.
I gotta sleep now. Good luck
Thanks. Its working with the initial base debian distro. I'm kind of following a tutorial which makes this kind of a todo because in some way it would invalidate completing the tutorial
Plus i'm using the github files made by the person who made the tutorial. The api works whilst he was making the tutorial so its either there's an issue with the file or with something i'm doing
thanks for the help though
What everyone's favorite continuous integration tool.. and what's the main reason why you favor that particular tool over others?
I KNEW I would still need help with code lol. Working on something with ChatGPT, and I can't seem to resolve an issue with the terminal window I added not echoing what would go in the terminal. I'm on Linux. well the coding machine is Linux lol It suggested changes to the code to make it run on seperate threads, but it still appears to not work as intended. https://paste.pythondiscord.com/donenameli
understood. though re. " some way it would invalidate completing the tutorial"
i would argue successfully debugging this (through whatever means) goes beyond completing the tutorial, because you gain experience debugging random stuff that have gone wrong for some potentially random reason, which is quite valuable.
i probably missed this from the previous thread, i only skimmed it, do you mind providing a link to the tutorial / the files?
that way i can potentially replicate your issue and have a look on my end.
though i am pretty sick at the moment, so no promises there.
Yes i admit that. I think i have more indepth experience than i did yesterday working on debugging this issue
i can send you the files. The tutorial is 4 hours long. But the files for the tutorials are available as well so i can zip and send. Give me a min
this a link to the repo that can be cloned: https://github.com/sidpalas/devops-directive-docker-course
also i think i found what the issue is. As much as the "/app" directory does exist in the base build. What i found out just recently is that there is no /api-golang directory in the /app directory so that is really where the issue is coming from
which is mainly why switching between scratch and distroless had no effect
can you please explain what this line is doing:
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
not really a go guru, but it's probably compiling relative to current dir and build a binary called api-golang
the ldflags and tags are unknowns to me
the reason i asked that is if its building it then the api-golang dir should exist after that line is ran through in the build process. But it doesn't exist
right, api-golang imo should be a executable binary instead of a dir
you have CMD ["/api-golang"] at the end of your dockerfile, which means /api-golang should be something executable, a binary there would make the most sense, and working backwards that RUN directive should generate a executable binary called that
and in my previous passing experience with go, that command indeed should do that.
okay but even if its building a binary. I should be able to see the binary name api-golang after that line right? Currently that is not the case, which is either its not creating the binary or the binary is not meant to show up and i added an extra "ls -la " incase its hidden in the dir but its not there still
sure
# Pin specific version for stability
# Use separate stage for building image
# Use debian for easier build utilities
FROM golang:1.19-bullseye AS build
# Add non root user
RUN useradd -u 1001 nonroot
WORKDIR /app
# Copy only files required to install dependencies (better layer caching)
COPY go.mod go.sum ./
# Use cache mount to speed up install of existing dependencies
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
# Compile application during build rather than at runtime
# Add flags to statically link binary
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang
RUN ls -la
# Use separate stage for deployable image
FROM scratch
# Set gin mode
ENV GIN_MODE=release
WORKDIR /
# Copy the passwd file
COPY --from=build /etc/passwd /etc/passwd
# Copy the binary from the build stage
COPY --from=build /app/api-golang api-golang
# Use nonroot user
USER nonroot
# Indicate expected port
EXPOSE 8080
CMD ["/api-golang"]
I had to switch back from distroless when it didn't solve the issue
am i correct in assuming https://github.com/sidpalas/devops-directive-docker-course/blob/main/06-building-container-images/api-golang/Dockerfile.8 is the "model answer"?
With distroless, i don't get any errors. Not in the logs and its just restarting
no, the .8 for golang is more built upon and i haven't reached that part in the tutorial. you're looking for the .6
understood. let me have a look see now.
okay
could you confirm how are you building the image?
docker build -t api-golang:t4 .
output of find . | grep go please
where do you need me to add this. in the docker build command?
just in the same place wherever you run the docker build command
okay
./go-workspace/pkg/mod/cache/download/github.com/kr/pretty/@v/v0.1.0.mod
./go-workspace/pkg/mod/cache/download/github.com/kr/pty
./go-workspace/pkg/mod/cache/download/github.com/kr/pty/@v
./go-workspace/pkg/mod/cache/download/github.com/kr/pty/@v/list
./go-workspace/pkg/mod/cache/download/github.com/kr/pty/@v/v1.1.1.mod
./go-workspace/pkg/mod/cache/download/github.com/google
./go-workspace/pkg/mod/cache/download/github.com/google/gofuzz
./go-workspace/pkg/mod/cache/download/github.com/google/gofuzz/@v
./go-workspace/pkg/mod/cache/download/github.com/google/gofuzz/@v/list
./go-workspace/pkg/mod/cache/download/github.com/google/gofuzz/@v/v1.0.0.mod
./go-workspace/pkg/mod/cache/download/github.com/google/go-cmp
./go-workspace/pkg/mod/cache/download/github.com/google/go-cmp/@v
./go-workspace/pkg/mod/cache/download/github.com/google/go-cmp/@v/list
./go-workspace/pkg/mod/cache/download/github.com/google/go-cmp/@v/v0.5.5.mod
./test/example_test.go
Its a lot of outputs but just copied a bit of it.
Go is being downloaded and i can confirm that. But the issue is really with the api-golang binary i think
what i did
cp -r 05-example-web-application/api-golang/ /tmp/api-golang
use your dockerfile
cd /tmp/api-golang
docker build -t api-golang:t4 .
and it builds correctly
add a gibberish line COPY --from=build /app/saodifjasdoifjsdaoij fawoeifjaweo
and it doesn't build as expected
so we can conclude
in COPY --from=build /app/api-golang api-golang
/app/api-golang definitely exists in build
the api-golang at the end is my interest now
since you have WORKDIR / it should be /api-golang, so CMD ["/api-golang"] should just work
i am proceeding to actually try to run the image now, will see what happens @earnest forum
are you certain about this because i can confirm its not in the /app dir. I added a sleep to the compile time which made the go binary recompline and made the RUN ls -la run and there's no api-golang binary in that dir. I also made a video for the output of the build if you need me to send. But i don't think i can send on here
The output is almost at the end of the video. You can check to verify as well. I think its an issue with the binary except the ls command isn't meant to output/show the binary
i am fairly sure
RUN ls -la api-golang-nope this fails
but RUN ls -la api-golang works
this implies it's there
issue is just ls -la doesn't print output in build time
but you know ls -la doesn't print out errors it only returns a blank output if it doesn't exist
would try it now though
blank output and non-zero exit code which breaks docker build
true about this, it returns "no such file"
yeah, the binary does exist. I did RUN ls -la |grep api-golang and it did return the binary
docker build --progress plain -t api-golang:t4 .
--progress plain is maybe needed to get that progress output
so the binary not being created is ruled out as the reason for the error. Then the issue is somewhere in the scratch file
indeed!
docker run \
--env POSTGRES_PASSWORD=foobarbaz \
--publish 5432:5432 \
postgres:15.1-alpine
docker run -d --name api-golang-main --network host -e DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres --restart unless-stopped api-golang:t4
had a super quick go at it, this works
β― docker logs api-golang-main
2023/05/24 09:47:27 DATABASE CONNECTED π₯
i have to go now, got an interview to attend, will be back in a few hours!
okay. Thanks for the help though. Then the issue is from my files
its up now and not restarting. The issue then has to be with starting the built container from another folder. In the module 08
okay, i can verify its working on the other module but can't access it. Might be an issue with my firewall though that's trival
Finally have it working. Thanks a lot
and i learnt a lot as well
that's awesome to hear! glad it worked out
couldn't have done it without you. What i specifically found out was whilst connecting the db to the golang api, the db wasn't exported into the shell so that was either causing the issue or whilst i was running the run command. I was expecting both the --name to be the same with the name at the end of the command. But When you sent this code. I saw you added a tag at the end of the command which i then tried and that kind of worked for me and allowed me to debug other issues with it
and hope your interview went great
Hey there i wanted help in dual booting is this the right channel?
I have a Dell laptop with 128 gb ssd and 900gb hdd of which i rarely use the hdd except for storing some file. Since my pc isn't powerful enough to run VMs while maintaining the performance, i want to dual boot it with windows 11? Any idea which Linux will run better along with win 11 elementary zorin Ubuntu or pop? And also do i need to disable secure boot? Can I install without a usb?
oh i was the interviewer and it went meh :\
the db wasn't exported into the shell
smells like network issue? i used--network hostto make use of the postgres i spun up with docker easily
i think you tried something similar with--network my-network, i just assumed you did it correctly, but it's worth asking nonetheless: did you start postgres on that network as well?
another comment is i don't really know what you meant by that thing re. --name
here is a quick explaination
docker run -d --name api-golang-main --network host -e DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres --restart unless-stopped api-golang:t4
^--- container name ^- use host's network, so localhost:5432 within the container is actually localhost on your PC, not just from the perspective of the container
docker run -d --name api-golang-main --network host -e DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres --restart unless-stopped api-golang:t4
^--- image to spin up, you want this to be the same as the image name (including the tag) you have used in docker build -- if you just say "api-golang", it's going to resolve to the latest image of "api-golang" you have built or "api-golang:latest" - N.B. This might be wrong, but that has been my experience
docker build -t api-golang:t4 .
^-- the image you have built, should be the same as the final arg above, "api-golang" is image name, "t4" is the tag
yeah, i had a network created. So its easier to segment services listening and connected to the backend from services listening and sharing resources in the frontend. The issue was, i had to export the DATABASE before i could use main. Main since i was running the build in the module 08 and the Dockerfile is in module 05
yes, i finally got it now. Thanks a lot for the help though
Are you mainly focused on devops of web dev in general or a specific niche in web dev
wrong channel, ask in an off-topic channel instead
hmm weird - -e DATABASE_URL blah should just expose that env var in the container automatically.. π€
i am a generalist in a start up, the "point me to a problem and i go solve it" sort of person (though i was hired as a data engineer/data scientist)
the database is on a different container running postgres image. And its binded to postgres's host dir so pgadmin4 has access to it
but i guess you must have forte where you shine more
ah okay, i think i understand where your issue is now. i just had a look into the Makefile in moudle 08 and what you said makes sense now.
yeah - just generally backend/data stuff, not a big fan of frontend
Yeah, that was mainly the issue causing it
Same also, but its not kind of paying off for me as a freelancer focusing on the backend only
mind popping over to some off topic channel? would like to ask you about your experience being a freelancer
sure
Oki ty
Not sure if this is the best channel for my question but here goes: I have a script running and I suspect there is something wrong with it and can't close it or I'll lose the state. The problem is that I don't expose the state via logs or anything else. Is there any way to inspect an already running process and see what values the variables have?
https://pyrasite.readthedocs.io/en/latest/CLI.html
you can inject code to get it to print its internal state for you to save (or just save directly to disk)
# /tmp/testing.py
import time
x = 42;
def main():
global x
while True:
x += 1
time.sleep(5)
print(x)
if __name__ == "__main__":
main()
# /tmp/inject.py
print('from injected', x)
python /tmp/testing.py
pyrasite 122381 /tmp/inject.py
replace 122381 with your PID
POC
the repeated 83, 84 are generated with the same mechanism - i just didn't put the 'from injected' in print before.
note: you need to enable ptrace for this to work - please understand the implication before enabling it
hello fellow python enthusiasts, i need help with my coding school project. I'm coding on visual studio code (i'm kinda new in coding) i want to make an app just like soundpad on steam, but just free version (I hate when i can just start 10sounds in free soundpad demo), i made everything but i don't know how to do that others in vc could hear my sound effects
import pygame
from tkinter import *
from tkinter import filedialog
from PIL import ImageTk, Image
import os
def selectFolder():
global songs
songs=[]
songPath = filedialog.askdirectory() #narsymas
fileList = os.listdir(songPath) #nuskaitymas
for song in fileList:
if ".mp3" in song:
songs.append(f'{songPath}/{song}')
print(songs)
playSong(0)
def playSong(index):
global title
pygame.mixer.music.unload()
pygame.mixer.music.load(songs[index])
pygame.mixer.music.play()
songTitle =songs[index].split("/")[-1] #nerodo title
title.config(text="songTitle")
def nextSong():
global index
index = index+1
if index>=len(songs):
index=0
playSong(index)
def previousSong():
global index
index = index-1
if index<0:
index=len(songs)-1
playSong(index)
def play():
global playing
if playing:
pygame.mixer.music.pause()
else:
pygame.mixer.music.unpause()
playing= not playing
songs =[]
index=0
playing = False
window = Tk() #informuoju, kad bus GUI
window.geometry("400x400")
pygame.init()
pygame.mixer.init()
frame = Frame (window, width=200, height=200)
frame.pack()
#paveiksliukas
image = Image.open("empty.png")
resize_image = image.resize((400,200))
img = ImageTk.PhotoImage(resize_image)
Label(frame, image=img).pack()
titleLabel = Frame(window, width=400, height=50)
titleLabel.pack()
title= Label(titleLabel, text="klangbund (Λsoun(d)bΓ΄rd)")
title.grid(row=0, column=3)
frame2= Frame(window, width=200, height=100)
frame2.pack()
playButton = Button(frame2, text="β΄", command=previousSong)
playButton.grid(row=0, column=0)
playButton = Button(frame2, text="βΆ", command=play)
playButton.grid(row=0, column=1)
playButton = Button(frame2, text="β΅", command=nextSong)
playButton.grid(row=0, column=2)
playButton = Button(frame2, text="...", command=selectFolder)
playButton.grid(row=0, column=3)
window.mainloop()
This looks very much like what I needed but it's complaining about ptrace being disabled. π¦
What if I can restart the script and modify it, is there a simpler way to just get a Python shell into it?
put where u wish breakpoint() in its code. it will open debugging python shell at this moment of script
pdb google to find out commands
you can use print(variable)
list current code to see and etc
Any other way? I don't want the script to stop.
launch code in thread then. then u can safely stop main thread from its execution
you need to make it thread safe for proper data accessing though just in case
if u use python backend django, it has python3 manage.py shell integrated shell for this purpose already
How exactly would I do that?
check Python Expert Programming 4th edition book
https://www.amazon.com/Expert-Python-Programming-practices-programming/dp/1801071101
Chapter regarding concurrency shows good examples how to launch in threads code
for thread safety, u need to google if your data is thread safe
and putting mutex for each one for its access if it is not thread safe. Wrapping in some class that gives access to data objects only if mutex lock is entered
https://superfastpython.com/thread-mutex-lock/
# create a lock
lock = Lock()
# acquire the lock
with lock:
u need to ensure, both threads access same lock instance for access
essentially pseudo algorithm of idea looks like this
from multithreading import thread
class GlobalStorage:
def __init__():
lock = Lock()
def __get__item:
with self.lock:
get_data
storage = global_storage()
script():
code
storage["abc"]
run():
thread(func=script).start()
breakpoint()
you enter debugging shell, script starts and uses storage
I mean I know how to launch a thread. And good point on safety although maybe the GIL takes care of that. I'm just not sure how exactly I'd be using this setup.
How do I enter a debugging shell or attach to it or whatever?
breakpoint() does it for you
u just need to run it interactively as user directly
Gah, this feels annoying to set up.
usually people just write unit tests and use visual debugger of IDE, that allows to stop program execution at any step
That is very true but in my case I'm running this on a remote VM. π
IDE have ability to connect remotely to VM too and use it as environment. vscode at least can do it.
Plus people install monitoring systems, have proper logging to monitoring productional/staging usage of app
Hey I'm trying to do this simpler and easier, not the other way around. π This is not some enterprise solution.
what stops you from running it locally though ^_^
It's a long-running process and I turn my laptop off and take it places. π
Basically it's just polling a website. But I suspect something is broken and I want to see what.
supposed to be done by having proper logging to application
(and running unit tests xD preferably automatically in CI of github actions for example, on every commit)
Running unit tests for a script like that? π
if u use it for prod and it has problems, then it needs unit tests. potentially they were needed before you deployed it π
if it polls smth, it needs tests for sure
it will make easier maintance
less effort to upkeep
less effort even to develop
I only intend to ever use it for a few days.
nothing is more permament than temporal π
"we can always improve it later" is another popular one
Logging is kinda difficult because the webpage is kinda large.
What I do log is whether I found what I was polling for or not. If I log everything that happens, I will no longer see this.
b"'PyGILState_Ensure' has unknown return type; cast the call to its declared return type\n'PyRun_SimpleString' has unknown return type; cast the call to its declared return type\nHistory has not yet reached $1.\n"
I guess in theory I could use plain gdb? Though I have no clue how to use it.
Or... with VSCode, I don't suppose I could start it remotely, then shut my laptop down and reattach to the process tomorrow?
yes, i did mention that you need to enable ptrace, do you understand the implication and do you see the message on how to enable it?
also are you on linux?
Yeah the VM is linux. Let me re-read what you wrote.
when it complains about ptrace is disabled, it shows you a oneliner to enable it
Yeah I enabled it and then got the SimpleString error.
what is "the SimpleString error"?
b"'PyGILState_Ensure' has unknown return type; cast the call to its declared return type\n'PyRun_SimpleString' has unknown return type; cast the call to its declared return type\nHistory has not yet reached $1.\n"
use pyrasite with --verbose
try the fix here https://github.com/lmacken/pyrasite/issues/76
Without --verbose it just gives me nothing. This was with verbose.
I don't suppose there is a python command that'd give me a Python shell that I could put somewhere within my code? And then some command in the shell that'd return back to execution?
there is, consult how django does it, darkwind pointed you toward the same path i believe
Not sure what the fix is in that issue.
nothing happens when I try to attach to a running python process with pyrasite-shell. when running pyrasite --verbose <PID> hello.py I get: b'0x00007f02ce561ff7 in ?? ()\n' b'\nwa...
double check you have gdb
I do.
Ah great, it also took my script process with it.
π±
why donΒ΄t just use pdb? it's CLI but does the work π€·
The point is, that this breakpoint must be conditional - only when I want to debug it. Otherwise, just run normally.
oh, i thought you wanted to recover states in a currently running script without restarting.
It's too late for that now. π
if you just want a conditional breakpoint, maybe something via signals
indeed π±
A python shell sounds more user-friendly, if that's possible.
unit tests are more dev friendly :cough: :cough:
How would I even test this? I'm not sure what's happening.
covering code, bit by bit until you discover your problem ^_^. start with code that has least dependencies to other code and increase coverage
assert that each small part of code, works as expected according to expected logic
replacing third party APIs with Spy classes or Mocks for faster and predictably testing
getting better logging on your way too ^_^
why do you want a python shell within a running script?
there are valid reasons for it, i just want to make sure it is so in your case
debugging logging is supposed to be outputing variables for working program
logging is better than getting a shell for read-only things.
as for write, establishing a proper interface to mutate states is often better than getting a shell and then setting variables
Are you about to tell me to develop an API for my 20 line script?
not necessarily. e.g. have a config file, in the script periodically check the last modify timestamp and mutate state if sensible
import signal
import code
def signal_handler(signal, frame):
print("Signal caught! Dropping into Python shell...")
code.interact(local=dict(globals()))
signal.signal(signal.SIGHUP, signal_handler)
import time
x = 0
while True:
x += 1
print(x)
time.sleep(5)
if you want to pursue the python shell way
it's your choice ultimately, i am just saying i wouldn't do it that way.
This looks way easier. My script is a throwaway hack so it feels like this is a better choice.
Looks like it does exactly what I wanted, thanks guys!
Though say I have a long-running process I want to debug with... say pdb? Would I use a similar approach or something else? It would also be a log easier if I could use some UI like VSCode (or even better - IntelliJ).
VSCode/IntelliJ's debugger is heavy weight, there are a lot of performance concern if you use them.
personally i don't know how to interact with it so i can't comment.
you can probably consule VSCode's source to see how their debugger works, and how it attaches itself to a running process (one that's altered by the debugger i assume, otherwise i can't explain the performance degradation) - all this is too much work for something so simple though, i would just be content with sticking to pdb using similar mechanism
Going through large arrays with just plain pdb sounds like a huge pita.
there is interact in pdb
but i have yet found a way to resume from that shell, perhaps you can enlighten me when you find out
bah, it's just Ctrl-D, doh.
i am sure i have tried that, i can't remember under what condition it didn't work now, i assume it's either i am using ipdb or something about stdin is messed up at the time
Catching up with the discussion about running code here (might have missed out on some things, though), but this kind of problem is what REPL Driven Development can solve. In Python, it isn't as sophisticated as in Clojure (where you actually connect to a running app and can query and even modify the program while running) - but you can evaluate your code from the editor, and start off the app from its entry point. From there you should be able to "live inspect" the code and what's happening. Might take you a bit on the way to find problems in code.
Example:
(running code from the code editor, changing a submodule, re-running a function)
What tool is this?
This is just my code editor that I have set up to run IPython (that has a couple of very useful features) as a shell.
I have written about how to setup your editor here:
https://davidvujic.blogspot.com/2022/08/joyful-python-with-repl.html
why are mine diff than the one in the course (mine on right)... 
thats not the problem, look at the terminal
its not the same...
how π
wdym
but when i try "name.py" it doesnt work
the file name would still show next to it untitled
oh...
bro im so embarrassing tysm
ok mr/ms petey the english teacher
how can I send a mouse click to a headless application?
Tools/Devops seems like the place to ask about Selenium - I'm doing a fresh setup on this dev PC, installed selenium, grabbed latest chromedriver, how do I point selenium to that path? It is in the root dir of my project
What sort of headless application? Normally that's not possible
See the accepted answer here: https://stackoverflow.com/questions/40555930/selenium-chromedriver-executable-needs-to-be-in-path
os.path.exists('chromedriver.exe')
``` evaluates to true but when doing
```python
with webdriver.Chrome(executable_path='chromedriver.exe') as driver:
still results in:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
im using a tool to make a game client not render the graphics and have it be kinda headless, but I need to send a mouse click into the application
idk if it would be considered actually "headless"
but I basically need to directly send a mouse click into the program, without using my mouse on the screen
I'm getting the feeling something else might be going on, I tried using chromedriver_autoinstaller and it is still returning the same exception, that or the autoinstaller doesn't work
Got it, figured out the issue
hey has anyone developed github actions workflow before ?
any idea how to develop them interactively ? coz to run them you need to push to your repo each time, and pushing to remote is not a good way to debug the errors in your workflow....
I want to bind two Traefik endpoints to a single Docker container's different ports. With these labels:
labels:
- traefik.enable=true
- traefik.http.routers.recommender-db-http.entrypoints=http
- traefik.http.routers.recommender-db-http.rule=Host(`db.host`)
- traefik.http.routers.recommender-db-http.middlewares=to-https@file
- traefik.http.routers.recommender-db-https.service=recommender-db
- traefik.http.routers.recommender-db-https.entrypoints=https
- traefik.http.routers.recommender-db-https.rule=Host(`db.host`)
- traefik.http.routers.recommender-db-https.tls.certresolver=letsencrypt
- traefik.http.services.recommender-db.loadbalancer.server.port=7687
- traefik.http.routers.recommender-db-ui-http.entrypoints=http
- traefik.http.routers.recommender-db-ui-http.rule=Host(`ui.db.host`)
- traefik.http.routers.recommender-db-ui-http.middlewares=to-https@file
- traefik.http.routers.recommender-db-ui-https.service=recommender-db-ui
- traefik.http.routers.recommender-db-ui-https.entrypoints=https
- traefik.http.routers.recommender-db-ui-https.rule=Host(`ui.db.host`)
- traefik.http.routers.recommender-db-ui-https.tls.certresolver=letsencrypt
- traefik.http.services.recommender-db-ui.loadbalancer.server.port=7474
I have these errors:
msg="Configuration loaded from file: /traefik.yml"
msg="Could not define the service name for the router: too many services" routerName=recommender-db-http providerName=docker
msg="Could not define the service name for the router: too many services" providerName=docker routerName=recommender-db-ui-http
msg="Could not define the service name for the router: too many services" providerName=docker routerName=recommender-db-http
msg="Could not define the service name for the router: too many services" providerName=docker routerName=recommender-db-ui-http
msg="Could not define the service name for the router: too many services" providerName=docker routerName=recommender-db-http
msg="Could not define the service name for the router: too many services" providerName=docker routerName=recommender-db-ui-http
Is it even possible to do with Traefik?
you should have a manual trigger option
you haven't defined the service for your http routers
Damn, thanks, it worked
Day 12 of Magic:
Understanding the difference btw Docker & VMs:
@rapid sparrow thanks found this but couldnt get it to work lol
I would try this instead thanks !
has anyone worked with adb or uiautomator?
next question please
Hi guys having issues with a docker container following a tutorial. Every other container is working but whenever i run the api-node container, it stops and this is what the logs show:
node:internal/fs/utils:346
throw err;
^
Error: ENOENT: no such file or directory, open '/db.crt'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Object.<anonymous> (/usr/src/app/db.js:13:12)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Module._load (node:internal/modules/cjs/loader:972:12)
at Module.require (node:internal/modules/cjs/loader:1157:19)
at require (node:internal/modules/helpers:119:18)
at Object.<anonymous> (/usr/src/app/index.js:1:25) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/db.crt'
}
Node.js v19.6.1
This is what the index.js file contains:
const { getDateTime } = require('./db');
const express = require('express');
const morgan = require('morgan');
const app = express();
const port = process.env.PORT || 3000;
// setup the logger
app.use(morgan('tiny'));
app.get('/', async (req, res) => {
const dateTime = await getDateTime();
const response = dateTime;
response.api = 'node';
res.send(response);
});
app.get('/ping', async (_, res) => {
res.send('pong');
});
const server = app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
process.on('SIGTERM', () => {
console.debug('SIGTERM signal received: closing HTTP server');
server.close(() => {
console.debug('HTTP server closed');
});
});
And i'm using a docker-swarm file to run it. For every other services in the docker-swarm, its all working except for the api-node. This is what the docker-swarm file looks like:
version: '3.7'
services:
client-react-nginx:
image: sidpalas/devops-directive-docker-course-client-react-nginx:5
deploy:
mode: replicated
replicas: 1
update_config:
order: start-first
init: true
networks:
- frontend
ports:
- 80:8080
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/ping"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
api-node:
image: sidpalas/devops-directive-docker-course-api-node:9
init: true
depends_on:
- db
environment:
- DATABASE_URL=postgres://postgres:foobarbaz@db:5432/postgres
networks:
- frontend
- backend
ports:
- 3000:3000
healthcheck:
test: ["CMD", "node", "/usr/src/app/healthcheck.js"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
api-golang:
image: sidpalas/devops-directive-docker-course-api-golang:8
init: true
depends_on:
- db
environment:
- DATABASE_URL=postgres://postgres:foobarbaz@db:5432/postgres
networks:
- frontend
- backend
ports:
- 8080:8080
healthcheck:
test: ["CMD", "/healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
db:
image: postgres:15.1-alpine
volumes:
- pgdata:/var/lib/postgresql/data
environment:
- PGUSER=postgres
- POSTGRES_PASSWORD=foobarbaz
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
networks:
- backend
volumes:
pgdata:
networks:
frontend:
backend:
const { getDateTime } = require('./db');
Is theapi-nodeservice able to access this.dbfile?
its the only thing i can think of being the issue. I already made a different build of the project but that wasn't for production. This is for production and i'm actually pulling the image from the tutor's docker repo. And the db is running in a postgres container. The previous build i have made which doesn't include as much details as the production build works without that issue
Hey, not sure if this is the right place for this, but I have a question. I have a well established project that is multi-platform that I would like to build a better installer for on windows. Currently, we have an innosetup installer, which installs python, pip installs my projects, and then uses nssm to install a service.
We also have an updater built into our web app that handles pip install -U itself and restarting the service.
This obviously is not anywhere near a standardized way to install a service (or a python application) on windows, let alone code/installer signing. Is there a way to use for example pywin32 to create the service (doing this either way), and also create a signable msi/msix without using something like pyInstaller first which would make my updater almost surely not work well? Putting my app on the windows store would be optimal, but not a requirement.
!rule 6 was your spam approved?
<@&831776746206265384> could you verify if it is approved spam? for many days multiple messages across multiple discord servers
It wasn't, thanks for the heads up
What channel is for discussion on visual studio code; I don't know why after updating, all my settings including my workspace.json file has been reset ?
that would probably be #editors-ides
Hello!
I just wrote CI/CD pipline in gitlab.
its simple Django application, and in pipline I have 3 stages, 1 - runs tests, 2 - pushes the app to docker repo, 3 deployes to digitalocean. And deployment is working fine, but docker container seems stopping after last stage of pipline is done. In digital ocean console I have installed docker, and after I run pipline, if I run 'docker ps' it does not show any running container. I generated SSH key locally, and I connect to digital ocaen ubuntu console via ssh key
Can some help me figure out, why container is not working after pipline is done, and so I cannot access the web app via ipv3 0.0.0.0:5000 obviously.
if I add 'docker ps' in pipline script, at the end, it normally outputting docker container info as expected in gitlab jobs logs
here is my deployment stage script which I wrote in gitlab pipline
stage: deploy
before_script:
- chmod 400 $SSH_KEY
script:
- ssh -o StrictHostKeyChecking=no -i $SSH_KEY root@0.0.0.0"
docker login -u $REGISTRY_USER -p $REGISTRY_PASS &&
docker ps -aq | xargs docker stop | xargs docker rm &&
docker run -d -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG &&
docker ps" ```
try running at server docker logs 77cb (after it already died)
or whatever latest ID of container you had running
ok
do you know, how to get current container ID?
each time I run pipline, its generates new container, tried this one 'CONTAINER_ID=$(cat /proc/self/cgroup | grep "docker" | sed s/\//\n/g | tail -1)' but did not work
you can set a name to it, docker run --name i-will-never-change-my-name
docker ps current container id in first column
or yes, u can assign fixed named as told above
but I am deleting running containers each time I run the pipline, will it still stay same?
so, the command will be docker run --name i-will-never-change-my-name -d -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG && ?
u can request logs by Container ID or by Container Name
container name u can have same one as long as you docker rm deleted previous one named in same way
then u can freely run new one as --name same_name again
oh so, when running the docker, and giving to it a name, and than using the name to log it, I see
note that you can't have two containers running with same name
docker logs i-will-never-change-my-name &&
docker ps " ```
this the script that I run
and output is showing nothing, no container is running for some reason
if you want to keep listening to container output, donΒ΄t use -d and you wonΒ΄t need to do docker logs
ok, removed -d and docker logs, and run the pipline
it will block the shell, just in case...
so better running it manually at server
and better with -it flag in order to have it interactable properly (if u remove -d)
can I run it manually in gitlabs server?
optionally, you can redirect output to a file, but you wonΒ΄t be able to see. You then will need to read the log file π
at which u wished to run it
CI infrastructure exists to run scripts deployment. but it is not valid target for deployment itself.
u are supposed to target some external infrastructure outside of it
connect this external infrastructure and test it there
it is common having staging copy of low powered infrastructure for such testing purposes
can you explain it more deeply?
CI infrastructure should be containing only CI agents.
For example if u use public Gitlab runners, they run on some dedicated machines made for this purpose only and nothing else
if u use self hosted runners, u should have dedicated servers that have running Gitlab agent and nothing else.
For your application infrastructure to deploy something.
U should have created separate specific server. For example virtual machine in cloud provider. It should be having assigned its own ip address / DNS whatever.
if u wish having in CI deployment script straight to server
then your CI should be having in simple situation... SSH key with access to application server
it should connect over SSH to this application server and deploy into it.
as simple newbie friendly recommended choice... i usually recommend using Ansible for this. Because it is idempotent solution (u can rerun it many times to achieve same result. U can continue any script rerun even if u had previous one interrupted)
hmm, I removed the -d and the docker logs
stage: deploy
before_script:
- chmod 400 $SSH_KEY
script:
- ssh -o StrictHostKeyChecking=no -i $SSH_KEY root@64.226.124.177 "
docker login -u $REGISTRY_USER -p $REGISTRY_PASS &&
docker ps -aq | xargs docker stop | xargs docker rm &&
docker run --name i-will-never-change-my-name -t -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG &&
docker ps " ```
but now looks like it stuck, its waiting me to enter something
So your CI CD could be having next workflow:
CI workflow -> Builds docker image and saves to docker registry under some tag
CD workflow -> Runs ansible script, which connects to application server, where removes previous deployment and runs docker module to raise container
well, that is telling your Docker image inside has command to just enter python shell and nothing else. (instead of application run as it supposed to be having)
about the deployment, I am deploying it to digital ocean, are saying about it?
yes
u a already connecting over SSH to your server ^_^
fix docker image. write appropriate CMD run your app command into Dockerfile
btw, now its showing the docker ps, in digitalocean console
the docker container details
btw, I have all cmd commands in docker-compose files, does it changes somethinkg form having cmd comands in dockerfile?
it depends on how u write it.
CMD python3 app.py will make it usually called over shell in the same way as in docker-compose file, when u add it as command: python3 app.py
CMD ["python3", "app.py"] is different, since it calls something directly without shell
(That is assuming u did not override anywhere entrypoint and it is default one equal to null, which u can observe in docker inspect your_image_name)
do I run docker isnpect your_image_name in pipeline?
@worthy agate recommendation to read btw this book
why in pipeline π¬ debug locally at your own PC
ok (
thank you
is the fact that I dont have the python commands in dockerfile, may cause issue that I cannot deploy and run the project in digital ocean?
it can be anything. it is just most likely reason. (clarification: u a missing something that launches application in a prod way, not exactly python commands)
your main problem is lack of ability to debug docker locally
other problem is just consequence of it
debugging docker without local access for debug is a bad idea
get local linux shell for your dev PC (Kubuntu 22.04 LTS is nice distro), install docker, debug docker image locally. push fixed code. proffit.
okay, I will stop trying to deploy for now, and will read the book
but before going to it, want to ask, when I run my app in local docker, it works fine, do you think that issue is still in docker?
run in same way you launch at your application server
u told me there is difference. u run with compose at dev, and with direct docker cli command at application server
run at application server with compose
or run at dev server without compose too, to have properly matching environments
I have Ubuntu 22.04 , is it going to be fine?
pretty much. it just has different GUI from kubuntu
Kubuntu is 20% cooler having GUI xD
as multi window terminal by default
at console level they is no difference though
so the difference is only in GUI, right? between Kubuntu and Ubuntu
if yes, I think I will keep using ubuntu
yes, zero difference otherwise
okay
thank you very much for helping me
now I have to go back to learning routine ))
Yeah the pipeline should just build the image. Interactive programs can be a problem. like installing tzdata you will end up using the environment variable so it doesn't get stuck waiting for you to enter the country code and timezone
hi i am trying to use github and git and how do i make the git clone not make a folder on clone
it will make a folder
also how would you use git clone on a private repo
there is a way but i can't remember how
there might be, but why
for it not to make a folder on clone
what does that accomplish for you compared to having it make a folder?
because i'm using a template and editing it and it needs to be in the working directory
not in a folder
couldn't you just give it the proper path to the template file?
yes but no
google indicates that to just have it use whatever current folder is, you do git clone <repo> .
but do you know how to git clone a private repo without ui?
depends on where you are cloning it from. Long story short you have to be authenticated. authentication options include username+password, ssh key, or other platform specific access tokens.
ah good to know
how would i use an access token?
I believe github switched to requiring an access token or ssh key for auth not too long ago
yeah user and password was removed
ok
$ git clone <repository> <path>
You should be able to just put a . after your URL to clone into your current folder
Same way
Windows, MacOS, or Linux?
Linux
It would ask for Auth as it a private repo
Correct. But that doesnβt change how you use it.
I can't provide Auth it has be with the url due to no console ac
Access
Checkout https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
Itβll walk you through creating your token, and at the very bottom of the page you can click through to βcaching your credentials in gitβ, and that will show you how to store it.
What
What are you trying to do?
Thatβs what GitHub removed support for
It miiight work with a PAT
But you might need SSH
So confused now
What are you trying to do?
Why donβt you have a console?
I figured out that https://token@github.com/user/repo.git works
That doesnβt look right, but if it works then alright then
What do you need help with then?
i think that is it other then pufferpanel and templates lol
with adding git a requirement witch you can't help with

unless you can lol
Probably not
Iβve never hear of that
well thank you adios
None
hwel
NaN
hey guys what do you use for the script to auto restart whenever there are any changes, I have to manually quit and restart everytime i introduce some changes
I usually do nodemon (node) but I know there are other alternatives other there - https://stackoverflow.com/questions/49355010/how-do-i-watch-python-source-code-files-and-restart-when-i-save
got it thanks β€οΈ
for some reason, I am running a discord bot and whenever running command it detects change in the script and restart it.
Hi ^^
I would like to analyze project with SonarCube and have some problem with visualizing coverage.
Here is the part of the sonar-project.properties I've set:
sonar.sources=./my_package/
sonar.tests=./tests/
sonar.coverage.reportPaths=coverage.xml
Before running sonar-scanner I've installed pytest-cov and created coverage.xml with pytest --cov=./gspread --cov-report xml.
Unfortunately, after running sonar-scanner in sonarqube I still see coverage 0%.
The structure of my project is:
my_project/
----my_package/
----tests/
I run sonar-scanner from my_project directory. Can anybody help me? Maybe I'm doing something wrong. I'll appreciate every hint on this ^^
I solved it, somehow sonarqube wasn't able to launch to coverage.xml, but simply running sonar-scanner Dsonar.python.coverage.reportPaths=coverage.xml worked
@rapid sparrow sorry for pinging you
but i finally deployed the app to digital ocean). Thanks man!
Have not done reading the book yet, half of the book left to read
u a welcome. good that u read this book ^_^ must have for any backend dev or devops (and even frontend devs should read it too, since they touch backend to get fuller understanding of web development anyway)
basically good book for any person who is in web development. (QA too then)
Which book?
docker deep dive
Is there a book like docker deep dive for kubernetes?
Yes, there is. From same author as docker deep dive
https://www.amazon.com/Kubernetes-Book-Version-November-2018-ebook/dp/B072TS9ZQZ
Mega best seller. And already republished each year.
Thank you.
this looks like (the beginnings of) a question for #1035199133436354600
no such file or directory
is merging branch A into branch B the same as doing the opposite? if so whats the difference?
(specifically with Bitbucket)
the merge commit remembers the order of the "parent" commits, so e.g. git log --first-parent will show something different
that's all I can think of, though -- in particular, I'd expect the resulting tree to be the same
so stupid me merged master into feature-branch, should I just leave it like this? and can I proceed to delete the feature branch?
uhh i think the order is quite significant, merging A to B is equivalent to adding A's commits to B - in other words A (master) doesn't receive B (feature-branch)'s commits so you'd be erasing your work if you deleted B without merging it back
what are you trying to achieve?
if you want to bring commits from master into feautre-branch then this could make sense.
it was a mistake
got it, so I merged the feature-branch into master
thanks guys
yeah -- a merge commit, like any other, can be "thrown away". So if you hadn't published your accidental merge, just create another commit that's more like what you want.
please don't advertise here.
Is there a tool/linter that will report cyclical imports?
i remember there is actually tool like that
https://github.com/thebjorn/pydeps pydeps it is i think
hmm I was hoping for something more like a linter that would report errors into a code editor (like vscode)
I'd try https://www.asmeurer.com/removestar/ -- I don't think it's designed to do that, exactly; but it might well do it as a sort of bonus
Tool to automatically replace βimport *β in Python files with explicit imports
Thanks for the help!
Piggy-backing off the merge question, I often merge master into a feature branch, run tests/CI, then if everything checks out, I merge that back into master. I assume that's a suboptimal workflow/idiosyncrasy I have developed. Is there something more typical? Maybe rebasing the feature branch onto master first?
I don't see anything wrong with that.
yes, there is
git checkout fetature_branch
git fetch origin master:master
git rebase master
rebasing is an alternative; it has the benefit that the resulting history looks cleaner.
with rebasing master to feature branch u have cleaner git commit history.
no extra merging commits will be in feature branch
and u will be able to merge back to master with single merge commit
well, that's the case regardless.
(merging commit is desired to be in master for easy revert of the merged PR, but u don't desire multiple merge commits from same branch/PR)
Ahh, thank you; up till this point I had accepted multiple merge commits as a fact of life.
Actually I have never seen the colon syntax in master:master. Could you explain that? π
u can do even further. u can enable in your github settings for Merging with Squash and using it as main merging strategy. (in general perferable choice for merging from feature branches ^_^)
it will merge your PR/branch as one commit into master
u can do same manually with running
git rebase -i master and replacing for every commit except first one pick to squash. Save it, and it will make feature branch rebased/squashed into single commit as well
uh. that's command i use to fetch master without checking it out and running pull on it.
it means... fetch from origin master to local master
under the hood each git runs on local and remote repos that it syncs with your commands
we just pointed it more explicitely in this case, to avoid switching to master for fetching it
so we could rebase latest remote master to feature branch
Gotcha. My work's policy in theory is to squash from feature branches, but usually that's only for a sprint branch to master. I will definitely set that up. π And the syntax explanation makes sense, thanks. I often just do git fetch without getting more specific.
hello peeps
I am deciding which python language server I want to run with
should I be using https://github.com/python-lsp/python-lsp-server or https://github.com/microsoft/pyright
I am also wondering if there are other tools I should integrate into my ide (nvim)
rn I am using https://github.com/psf/black
should I also use https://github.com/davidhalter/jedi and at what point do i need to worry about conflicts
apparently python-lsp-server implements jedi
I've been using python-lsp-server for a while and it seems OK
I assume that pyright is awesome, since Microsoft know how to do programming-language stuff, but I haven't actually tried it
my issue with pyright is that it's only a subset of pylance functionality which Microsoft is privately licensing
I set up python-lsp-server with nvim and it works great. I only chose it since it worked without issue with nvim-lspconfig (https://github.com/neovim/nvim-lspconfig) whereas pyright didn't. I like that plugin since it gives standardized and simple configs you can link to in your lua or vimscript config file for neovim.
Hello, we managed to develop ourselves into a very... creative branch configuration and now i'm just very unsure how to get this done in the first place:
There is a private repository X containing main and demo, which are branches that have diverged pretty substantially from another; demo stemming from main. There is no way they'll ever be merged again and development common to them is just handled via cherry-pick. This feels extremely incorrect, and if someone has a better scheme to handle this, i'd be happy to hear it, but that's not the main question.
There is a public demo repository Y which is a snapshot of X:demo at a certain commit. This snapshot has been created by copypasting the entire repo, deleting .git to get rid of the commit history (and then, as this wasn't bad enough already, of course, making some more changes. These changes however were almost only deletion of code that will very likely never be touched by any commits in X again and may as well get deleted there). We would like to steadily update Y:main from X:demo, but ideally without dragging commit history, dates, objects and author names present in X into Y before this "snapshot" commit into Y. Now my question is: how could that be done?
[X]
| O --- O --- O --- O --- O --- O <-main
| '-- O --- O --- O* --- O+ --- O++ <-demo
[Y]
| O** --- O --- O {? --- O+ --- O++} <-main
O** created from copypasting O*
How to get the changes introduced by O+ and O++ into Y without leaking other commit info from X into Y?
It would be possible to just recreate the entire Y repo if necessary.
Off the top of my head (not tested):
In Y, add X as a remote. That will let you diff between them and create a patch that you can then apply to Y:main. There's probably a more elegant way than creating a patch file but I'm not sure.
I'll just try this cause no damage is done as long as i don't run push, but my fear with this is that it may fetch many things from X into Y; the things in main shouldn't go public yet
It will be a diff between whatever branches you want. So you could diff between X:demo and Y:main
That would result in everything in X:demo to be pulled into Y:main if it's not already there. Stuff in X:main won't be used since that's a different branch than what was given to git diff
The problem is that demo in its early stages still contains elements of main we forgot to weed out properly.
I guess it may be a really good idea to create a new public_demo branch in X, i'm gonna maybe experiment around that
Thanks for the input; even though there's no conclusion it's given me some new ideas
If it's entire files you want to exclude, I think git has ways to do that when running a diff.
If you want to exclude specific lines/blocks of code then I am not sure
Hey peeps, what are your favorite hooks to use with pre-commit?
My pre-commit runs black, ruff, isort, mypy, codespell, interrogate.py, and then my tests with pytest
As far as some of the "default" hook repos are concerned, ```yaml
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=no] - id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:- id: python-check-blanket-noqa```
Other than that, just black, flake8, and isort
Maybe I should start running tests before commiting... but I feel like that can take too long and would become annoying
I tried it once and it was a bit annoying on commits I wa nted to run linting on but knew tests wouldn't be affected
In the very unlikely chance anyone gets value out of it:
After trying stuff out for an entire day, corrupting and redownloading repos, i now effectively have a local repository setup to track X/demo on an unpublished Y:demo branch and resigned to just cherry-picking from it into Y:main. This involved git remote set-branches origin main, git remote set-branches private demo and git remote set-url --add --push private __DO_NOT_PUSH__ to prevent ever accidentally pushing back from Y somehow. The commits aren't the same, so the histories are completely different but the repo's contents are absolutely equal as indicated by git diff. It works.
Hi, I'm tinkering with schedule [^1] to run some cron jobs. How do you guys run schedule itself as a daemon job that starts automatically at startup?
I'm on Mac + Linux. I don't want to use launchctl or systemd to be honest. I'm thinking of crontab with @reboot attribute. But this forces me to use crontab which ruins the whole reason why I chose to use schedule in the first place.
which ruins the whole reason why I chose to use
schedulein the first place.
if the reason is having the scheduling logic be in Python itself, then yes, the code that launches the scheduler needs to be launched as you mentioned.
I've recently done something similar, but using a cron-like library in a program deployed to Kubernetes (which takes care of the launching (and re-launching) part for me.)
BTW, I've seen apscheduler getting recommended as a Python library for this as well.
My machines doesn't run 24/7 and I want to keep them light so Kubernetes is not a good choice (way overkill).
But working with CronJob resources on Kubernetes is truly a good experience.
oh no, I'm not saying you should use k8s, no
just giving some context with a recent experience
Is there a tool that can tell me which dependencies in my requirements.txt are unused in a package so I can prune them?
I've used https://github.com/fpgmaas/deptry in the past for this
it can highlight both unused deps, and missing deps
I'll give that a try, thanks!
so I just had to resolve a conflict to merge the fature branch to master, so I did a git pull origin master modified the code, git add ., git commit, and then when I do git push origin feature_branch it says: Everything up-to-date and the commit dosent show up in the commit history, why??
in tihe output of git status it says: interactive rebase in progress; onto <commit hash>,
what am I supposed to do to exit from it?
Hello all! Looking if someone can help me with a Python script for Maya. I am not a scripter, just trying to make quality-of-life tools for myself. Basically I am making a one-click export, I got it working for individual models, but when exporting a group it only exports the group with nothing inside. Not sure what's going on, I tested just normal export selected and had the same issue, so I am not sure what I am missing. SOS, thanks in advanced!
Seems like this might have more to do with Maya than with Python but if you think there might be a problem with the code itself you could share it in a help channel #βο½how-to-get-help
Why do you run both isort and ruff?
Sebastian Ramirez also does that which confuses me
What do you feel is lacking in pyright?
(not related to Python) Miro newbie question : how can I switch to viewer (read-only) mode on a specific board for not accidentally modifying any visual element ? currently I have editor permission on a board, after few minutes of google search, I know that I can turn on presentation mode, however I still can modify things.
Hi ! i'm using poetry as a package manager and since i upgraded it (Poetry (version 1.4.0)) the command poetry install is really verbose by default and i'm looking to change the default verbose setting. Can someone help me pls ? ty
(ping me if answer)
Lack of familiarity tbh, just want linter warnings to be fixed and imports to be standardized and didn't know ruff can sort imports :)
me neither
hey so i am looking at how i should manage python environments and omfg this is too much. wtf should i even be using these days? pyenv? venv? virtualenv? conda? poety? just use the installer from python.org? i am losing my mind lol
use the simplest thing that works.
start with "requirements.txt" and pip.
if you're building software for your employer, they might have standards; you'd have to follow them.
But if you're just doing stuff for yourself, keep it simple.
this is just for me learning python in my own time
unless you actually want to learn pyenv, venv, virtualenv, conda, or poetry ... stay away π
those all solve problems that you either don't yet have, or don't yet know that you have.
ha fair enough. for now i just installed python with the pkg for mac on python.org and it works
true although i read about some issues people run into with homebrew updating python as well so i just went with the official install
Is there any tool or command of a larger tool (eg a linter) which can list all the direct dependencies in a project?
We had a situation recently where a direct dependency had not been listed in the dependencies but everything had been working because it was also required by a different direct dep and so was still being installed eventually.
We would like to avoid that sort of oversight if possible
Start with a clean environment > pip install requirements.txt > pip freeze output
That doesn't solve the issue though.
- package A is required by our code
- package B is required by our code
- package A is also required by package B
We would have a working project with a requirements.txt that only contained package B.
yes but pip install will install all dependencies
and pip freeze will list everything what was installed
therefore you will have reproducible environment
!pypi pipdeptree is probably what you're looking for, although im not sure how it determines top-level dependencies
pipdeptree also shows only installed packages. Only output format is different
ah right
are there any benefits in using absolute paths in production (on code that runs in cloud)?
I feel like its always a mess to find the "absolute shared path" and concatenating it to the other part of the path, and many times it differs from your local enviroment, so testing the code locally without modifying it a bit is many times impossible, what do you guys think?
absolute paths are just a headache in my experience
With docker and k8s we use absolute paths. I don't know if it is a best practice or not
https://12factor.net/ sometimes can be used, but make sure they are always set via Environment(Or CLI args) variables as options xD
By default your application should be dev friendly to work at any dev PC (which means relative paths unless specified otherwise)
A methodology for building modern, scalable, maintainable software-as-a-service apps.
I have a bunch of separate Python packages in the same repo that depend on each other. Each package is managed by Poetry. How can I set up my build scripts such that when I build a downstream package, only the upstream packages that have been changed are rebuilt?
CI pipeline in Github Actions for example
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
Each package building triggered on changes in its own folders
on:
push:
paths:
- '/package_name/**'
e.g. let's say I have A -> B* -> C -> D*. (An asterisk indicates that the package was modified)
Right now, each time I build D, I have to rebuild A, B and C to make sure they are up to date. But I only want to rebuild B and C.
Is there a way to do all this locally? (all of the packages are in the same repo so I may need to update multiple packages in the same commit to keep them compatible)
You may ask why that is the case. Originally, everything belonged to the same package, but the code has expanded significantly since then, so I am transitioning the codebase to a polyrepo. The current state is like an intermediate step where the modules have been decoupled to form their own packages
yeah makes sense, I think you should use relative paths whenever possible
Hint: Polylith has that feature, checking what parts of the code are changed (using git tags) and will report which projects/artifacts that should be deployed. The diff command: https://davidvujic.github.io/python-polylith-docs/commands/
Yeah, but my code isn't there yet, so I wonder whether there is a way to get that working for the meantime
The polylith source code accomplishes that through AST parsing and analyzing the imports. Maybe you need something like that?
I should have mentioned this earlier: each package has both JS and python components (basically frontend/backend), so I would prefer something that works on them jointly
Would hashing the source files be a solution (somehow)? Comparing to a previous value.
I don't want to build my own change detector xD
i use task (https://taskfile.dev/) for most things, and there is a section there that seems relevant (https://taskfile.dev/usage/#prevent-unnecessary-work)
Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.
That sounds promising (especially since I am currently using Makefile to coordinate the setup/build/test processes for the JS and python components within each package)
I will take a look, thanks!
i like taskfile.dev too. But secretly started to think about magefiles ^_^ https://magefile.org/
all power of static typed golang language boilerplated into makefile instrument. that sounds nice to me.
Mage
yeah i was the one who pointed you to taskfile before π
Hello people,
I have an scrapy project:
For that scrapy project I need python2.7, 3.6 and 3.8. So everytime I switch versions I need to switch of virtual environments and every virtual environment has its own packages installed.
My question is, can I make 3 docker containers ONLY with the packages installed in every virtual environment, and connect from the outside ?
I mean running scrapy crawl nameofthespiderfrom the outside and having 3 docker containers as environment (depending on which python version I'm using) . Instead of making source venv2.7/bin/activate or source venv3.6/bin/activate or source venv3.8/bin/activate connect through docker.
Thanks
Nope, docker image always will contain full filesystem. However it is layered...
So you can build base docker image with only OS (or use pre-built ubuntu/alpine available).
Then you can build three more docker images, both will have same base image in FROM
This is if you want to use docker for multiple python versions management. For local development you could use pyenv instead.
@thorny shell @elder solstice hi
But Its a mess installing every Python package from the requitements.txt because of incompatibilities and when a new team member arrives to the company as well.
My idea was to have 3 updated Docker images on the dockerhub that every member of the team can use and connect to any of them depending of the version that is using.
with preinstalled packages?
How much packages you want to preinstall? I have experience with 500 anaconda packages in one environment, at this point dependency conflicts start to bother us.
I believe each project should have it's own environment and it's own (minimal) requirements.txt
or poetry's pyproject.toml
Everytime a package is added or updated, to update the Docker image in the Dockerhub and every member of the team has It updated
Will developers use local docker to work with it?
"I mean running scrapy crawl nameofthespiderfrom the outside" -- scrapy will have to be installed inside container image as well.
For me it's not quite clear what is "outside". They will run container from "outside" (outside = their local host system), and they can override default ENTRYPOINT/CMD if they want... Or even run /bin/sh as CMD. The CMD binary should be built inside image.
Maybe use mounts/volumes, but meh... Are developers actually willing to do that?
Yeah with mounts or volumes It Will solve my problem
There are two possilbe workflows:
- local debug / local development - personally me would prefer just to use pip, with caching proxy to speed up downloads (although downloads are still cached locally)
- good cicd pipeline - should build a new docker image with the application on each commit - run everywhere: dev, test, stage, prod environments
what is the project?
Just a library i wrote for work
Can I make a Dockerfile without installing Docker?
Somebody is asking me to send them a dockerfile so they can run my web application with it
π€·
if they expect you to create a working Dockerfile, that will probably be hard unless you have Docker installed.
I hate Docker
Takes up too much god damn space
DL a 7 GB application just to ensure a dockerfile is working properly for them to use. Unreal.
Well the dockerfile is made. They never said to build an image for it.
lol, how do you know it works as intended if you didn't even build and test it? Sounds like the person expected that you were developing this to be containerized, and it sounds like you weren't. But you sent an untested dockerfile over anyways. Should have just told them its not developed for containers
Thereβs also Podman if you have issues with Docker, with basically the same API & features.
heh. sounds like a sensible request any infra dev would make
your app is may be overbloated
or... your dev PC is too... weak, consider upgrading it ^_^. I had no problems to use docker with having even just 250 GB initially as my whole SSD drive! for 2 years! (That was linux though which is very efficient in terms of disk spendings. I still needed to use ncdu program from time to time to find what is taking spaces)
you can cleanse docker cache at any moment with running
docker stop $(docker ps -a -q), stop everything
docker rm $(docker ps -a -q), remove all containers
docker system prune --volumes -a will cleanse all possible cache of images
Can I achieve the exact same task of isolating the packages and libraries and connect to It from the outside (my local terminal) with dev containers (vscode extension) or dev environments (Docker Desktop feature) ?
Hi there! I practice karate and I'm planning to create a ranking system in Norway since it currently doesn't exist here, although it is common internationally. I envision a ranking system where organizers of national karate tournaments in Norway can input the results into a program or website, and based on that, generate an updated leaderboard. Do you have any tips on how I can get started or what I need to know?
I'd search Google for other leaderboard projects -- I imagine some exist.
Then see what tech they use, and try to understand it.
Taking me so long to figure out how to containerize my app
Itβs taking longer than actually finishing my app
Actually sick of this containerizing crap
- Containerization is not too hard for basic use cases once you handle it at least once
- Please, stop with so much ranting and negativity. If you want help β you can ask for help, and I'm sure people here will help. Otherwise I'd ask you to keep this to yourself.
I keep getting errors
That is not a reason to rant β that's a part of the profession.
That is not a reason to rant β
Thatβs your opinion
Listen, I am not trying to argue. I am pointing out that this channel is not for ranting. It's for people helping other people with specific problems.
ERROR: failed to receive status: rpc error: code = Unavailable desc = error reading from server: EOF
The error that I received from my terminal
Will you help?
I will not. However, If you share the dockerfile with us, I am pretty sure someone will.
Dockerfile.dev
# Fetching the latest node image on alpine linux
FROM node:alpine AS development
# Declaring env
ENV NODE_ENV development
# Setting up the work directory
WORKDIR /cth-controls
# Installing dependencies
COPY ./package.json /cth-controls
RUN npm install
# Copying all the files in our project
COPY . .
# Starting our application
CMD npm start
On which command, build?
Print us output of docker version
Looks like possible incorrect installation
docker version
error during connect: this error may indicate that the docker daemon is not running: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open //./pipe/docker_engine: The system cannot find the file specified.
Client:
Cloud integration: v1.0.33
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:53:15 2023
OS/Arch: windows/amd64
Context: default
Hehe. The error is there and clear. Your docker daemon is not available (but it should be for it to work)
Therefore incorrect installation
Is it Docker Desktop installation u followed?
I just restarted my laptop and it showed that error. I opened Docker desktop and this is what it shows now.
docker version
Client:
Cloud integration: v1.0.33
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:53:15 2023
OS/Arch: windows/amd64
Context: default
Server: Docker Desktop 4.20.1 (110738)
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:52:17 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
That is better
I've always had the Docker desktop on when I was trying to build my docker image
Okay, i have your answer... Which will take long to print from phone
Docker works in ideal way
https://docs.docker.com/engine/install/ubuntu/
If u install Docker Engine at linux
It is fully CLI version. That uses no virtualization. Docker client and docker server-daemon work natively. Daemon grabs current Linux OS core/kernel and reuses it for its operation. Zero additional overhead.
Requires having printed OS Linux in your docker version for client and server. (For correct functionality without any problems at least)(WSL i heard can run real Linux in WSL2?)
But u a running smith like Linux imitated by windows core for Client (Frankenstein)
While Docker Desktop installed creates a SECOND virtual machine with Real Linux running inside
So when u execute CLI docker, it is connected remotely from your Windowsish (os arch Windows) Linux 1 to this virt machine (Real Linux 2 - os arch Linux) containing docker server inside to use it (thus it kind of remains not available fully at current OS u a because u speaking with it only remotely)
Tldr: all problems from u using Docker Desktop at Windows, instead of Docker Engine at Linux.
We can assume, that when u enable Docker Desktop, it brings online this remote virtualized real Linux #2, and that is why it starts to work
With real Docker at Linux it would have worked locally via docker.sock and had no such complications and problems
- Install Linux as dual boot (or main OS)
- find WSL to run real Linux (via virtualization to achieve OS arch Linux printed)
- create normal virt machine with Real Linux
- use remote server with real Linux
Any option will work
Then install Docker Engine, and everything will work fine
Continuing to use docker in the way u a using right now will bring you only new problems in a future. Docker volumes, essential part will not function correctly too, since they still be activated at second remote OS
TLDR: U should have installed Linux, instead of using Windows
Well I must say thank you for putting in the effort in helping me troubleshoot the issue that I have been experiencing.
I was able to containerize a simple Hello World app on my Windows laptop though. I am not sure why I am not able to do so with this case.
@rapid sparrow are you trolling?
Only half joking.
DevOps engineering tools for infrastructure as a code approach in web development are natively supported by Linux only.
They are meant to make deployment to Linux servers first, nothing surprising that they work correctly only from Linux
For Windows and MacOS only very very limited partial support is present in some of tools
Considering that Docker is OS depended tools and its ecosystem is rich and supported for Linux only, u will never get the same level of usability anywhere but in Linux
Preferably with PC CPU architecture in amd64. Arm64 started to grow in server usage popularity but still has unresolved kinks and level immaturity.
So even if u install Linux to modern MacBook with M processors in arm64, u will still experience some troubles in ecosystem and software. Magnitudes less troubles than using another OS than Linux though
I'm pretty sure he wants to run an equivalent of hello world so what you're saying doesn't apply for his specific case.
He wants node server in development mode started at least. That already reuses ecosystem of Node.js public docker images (which in its turn reuse Alpine Linux images according to his code, which in its turn requires running Linux OS kernel). Everything i said above is already applying
I am sorry, I do not run windows so I might be less knowledgeable in this:
Can't he run a regular node server in docker on windows?
short story, no. he can't.
Docker technology is OS depended and CPU architecture depended.
Windows ecosystem of Docker is very close to zero (official node.js is not present too there)
in Windows he has choices only to use
- Regular VMs of Linux
- using WSL with Windows Linux, that in end with Docker Desktop will require him second Linux virtualized with proper kernel (still requires real linux in the end running)
- using WSL2 may be possible to have Linux kernel running fully for the WSL virtualized OS (it is still overhead in virtualization to have a second OS running)
or he can skip all those problems and just install Linux to dual boot.
There are no other options... actually there will be options but they are in beta test
in some distant future (give it 5 years), Docker will migrate may be to be built on WASM (currently in beta available), that is OS and CPU architecture independed
then it will be possible running Docker ecosystem (if other developers, maintainers of all ecosystem will migrate too), in other OSes
what!? where can i read more about this WASM switch? that's a proper TIL for me.
https://docs.docker.com/desktop/wasm/
they have it as adds on all docker hub repos π already possible to build and run
there is also an option to use Buildx for silmutenous build of docker images in different CPU architectures. not sure if possible to run Buildx building from Windows for Linux OS. it is very fragile and creates overhead to create multiple docker images though. Wasm has no such disadvatnage (U can build one WASM docker image to run everywhere)
i find it fascinating that people are doubling down on the JS ecosystem, like WASM and whatnot, when JS as a language is.... let's just say sub-optimal in design.
as far as i read about WASM, it is supposed to be an analog of assemble instructions that is OS independed and possible to run everywhere.
it is not directly tied to JS
although i hear that JS is very tied to running WASM at least in browser (due to its mature ecosystem, that is already secure and mature) (not sure if i got it correctly though)
anyway, i still find fascinating that we can run something like mature Rust frontend frameworks in wasm of browser now
https://github.com/yewstack/yew
https://github.com/leptos-rs/leptos
hmm. interesting, the vibe i got a few years ago is that everything is compiled down to javascript, maybe i understood wrong.
as far as i underthand, wasm in browser is compiled back to javascript too.
to reuse browser ecosystem of maturity and security for javascript
you know.. i don't care to which language it is compiled in the end (be it assemble or javascript) as long as i am not impacted significantly in performance, weight of user dowloaded files and any memory and etc problems
as long as they managed to provide making front in something not javascript during development, it is already fine to me
Docker wasm is probably runnable without js though, since it is not run in browser
Ok I think I have set up the builds properly. However I am running into the following problem, not sure whether that's solvable by Task:
Basically I have a dependency chain like so:
A -> B -> C
\ /
----
Now, I have set up a Taskfile to build each of them. In B's Taskfile, I include A's Taskfile such that A is built before B. Likewise for C.
Since the build for A is quite expensive, I have specified sources in A's Taskfile to avoid unnecessary builds.
However, the problem is that B stores A's checksum in B's own .task directory, and the same thing applies for C. As a result, after I update A, when I try to build C, the following happens:
[Given that A has been updated:]
C:builddepends onA:build.A:buildcomputes checksum and finds it to be different than that stored inC/.task. So, the task is re-run.
C:builddepends onB:build.B:builddepends onA:build.A:buildcomputes checksum and finds it to be different than that stored inB/.task. So, the task is re-run again.
The result is that A is being built twice even though it only has to be done once. What can I do so that it only builds once?
- I have tried using
run: when changed, but that appears to only work if the task is called from the same Taskfile. In my case, it is called from two different files (BandC) so it doesn't apply. - I guess I can remove the transitive dependency (
A -> C). But this may lead to the build breaking ifBno longer depends onA. This solution would not be maintainable for more complex dependency graphs.
oops. that's my bad, i wasn't aware of this limitation.
having just one root level taskfile will fix this for sure, but it's quite bad because it's not co-located with the packages
on top of the root level taskfile no-go "soution"
there is one hacky solution
export PACKAGE=a; mkdir -p .task/checksum; find ../$PACKAGE/.task/checksum -type f -print0 | xargs -0 -I {} bash -c 'cp {} ./.task/checksum/$PACKAGE-$(basename {})'
this yoinks the latest a checksum into the current directory's .task/checksum with the correct a- prefix, this would skip a's build in b directory for example
there is also this issue: https://github.com/go-task/task/issues/852 - no traction thus far
there is also this issue: https://github.com/go-task/task/issues/852 - no traction thus far
Yeah I've seen this, unfortunate that it doesn't have more visibility
export PACKAGE=a; mkdir -p .task/checksum; find ../$PACKAGE/.task/checksum -type f -print0 | xargs -0 -I {} bash -c 'cp {} ./.task/checksum/$PACKAGE-$(basename {})'
Hmm... interesting
it made a lot of assumption though.. not fit for production usage at all
but the principle of copying the included taskfile's .task/checksum seems to work
yeah so perhaps I can create a "checksum repository" that syncs together the checksums stored across different packages...
instead of this not-very-readable shell command, I can call a Python script that writes the given checksum, and Python will propagate the checksum to the other packages
push based might be a bit hard, because you would need to know ahead of time what consumes packge A
pull based is probably easier, i.e. package B know it needs package A and grab that itself
Ok I think I got this figured out.
I will add a Python script python checksum_repo.py put <key> <checksum> that updates the entry with the given key with the given checksum, returning 1 if the entry is updated as a result (otherwise 0).
Then, in A:build, instead of the default method: "checksum", I will use status: ["python checksum_repo.py put <key> {{.CHECKSUM}}"] to determine whether the task will run. Given this, the above example will trigger the following:
- [Given that
Ahas been updated:] C:builddepends onA:build.A:buildcomputes{{.CHECKSUM}}that is different from the stored one, so the command instatusreturns1, prompting the task to be re-run. (Note that this also updates the repository with the new checksum.)
C:builddepends onB:build.B:builddepends onA:build.A:buildcomputes{{.CHECKSUM}}again, but this is the same as the stored one, so the command instatusreturns0. The task is no longer re-run.
sounds really solid!
really neat usage of {{.CHECKSUM}} (to which i didn't know existed)
might start using this in my project now.
i think there might be an opportunity of building your package A and dumping it into /repo-root/A/dist/{{.CHECKSUM}}/output and have B read from that, this could potentially mean you can maintain a few versions of package A without needing to rebuild, if you hop around versions a lot that might make a difference in dev experience
Thanks! For my use case, I only need to maintain one version atm, but I will keep that in mind π
hmm, this might be an edge case, but since Task can execute tasks concurrently, I need a way to block the script if another instance of the script is currently writing to the file
noqa
hmm I have implemented this but there is a problem, in that {{.CHECKSUM}} is only available with method: checksum. This means that if I specify status in this way, the task will be rerun if the checksum changes and/or my python script returns a non-zero value. Not sure how can I remove the former condition
Don't tell me I have to pass the globs to python and have python calculate the checksum internally...
Maybe I can have a dummy task that stores the checksum to {{.ROOT_DIR}}/.task and read it in the real task?
This is kinda ugly but it works
tasks:
build-python-checksum:
internal: true
dir: './python'
sources:
- '**/*.py'
status:
# This makes it so that `build-python` is aware of the new checksum during a dry run
- echo {{.CHECKSUM}} > "{{.ROOT_DIR}}/.task/checksum/{{.TASK | replace ":" "-"}}"
build-python:
deps: [build-python-checksum]
dir: './python'
cmds:
- echo "Do the actual work"
# Only update the stored checksum if the task is successful
- python "{{.REPO_DIR}}/tools/checksum_repo.py" put "$(pwd)/build-python" $(<"{{.ROOT_DIR}}/.task/checksum/{{list .TASK "-checksum" | join "" | replace ":" "-"}}")"
status:
# Avoid side effects
- python "{{.REPO_DIR}}/tools/checksum_repo.py" check "$(pwd)/build-python" $(<"{{.ROOT_DIR}}/.task/checksum/{{list .TASK "-checksum" | join "" | replace ":" "-"}}")
Dear god, now I am sorry I led you down this path π₯Ή
I am travelling at the moment, so I can't even look properly, but I felt like making a change for task to automatically pull included task file checksum should not be that hard π§
What SSH client y'all using? I'm on Windows trying to get into my AWS EC2 ubuntu instance but it's messing me around so I'm looking for an alternative to PuTTy that can use the .pem file instead of requiring me to convert it to a .ppk
are you sure Windows doesn't have an ssh client built in?
Even if it does, I doubt it'll easily allow me to specify the .pem file for auth
well I think the Linux version lets you specify a .pem, in which case I'd expect the one on Windows to do so as well
PS XXXXXCE:C:\Users\xxxxxxx [2023-06-20T08:41:40-07]> ssh -V
OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
lgtm
it's roughly the same program.
well that's annoying...
permission denied (publickey)
whatever tf that means... Obviously "publickey" is a super useful and descriptive problem statement π
that means the private key you're using isn't allowed by the remote host
I just generated the damn thing in AWS... this is why I hate server admin. This shit never makes any sense
Even AWS itself can't connect to this thing...
Stupid af
no worries xD
I just realized that I have to pass in sources as a variable to achieve what I want (I want to use the above task as a base, and have the actual tasks pass in the output of their dependencies as part of the source files)
so I think I'll just roll my own checksum generator
something like this
from __future__ import annotations
import hashlib
import glob
import os
from pathlib import Path
import click
@click.command()
@click.argument('sources', type=str, nargs=-1)
def calc_checksum(sources: list[str]):
"""
Calculates the combined checksum of the `sources` defined in a Taskfile,
printing the result to standard output.
"""
# This is based on: https://github.com/go-task/task/blob/main/internal/fingerprint/sources_checksum.go#L86
# However, the implementation is different so they might not return the same hash
pathnames = {
pathname
for source in sources
for pathname in glob.iglob(source, recursive=True)
if os.path.exists(pathname)
}
filepaths = {
Path(dirpath) / filename
for pathname in pathnames
for dirpath, _, filenames in (
os.walk(pathname) if os.path.isdir(pathname) else [(os.path.dirname(pathname), [], [os.path.basename(pathname)])]
)
for filename in filenames
}
h = hashlib.md5()
for filepath in sorted(filepaths):
h.update(filepath.name.encode())
h.update(filepath.read_bytes())
print(h.hexdigest())
if __name__ == '__main__':
calc_checksum()
not sure how robust this is
I hope I'm not shooting myself in the foot by doing this lol
So now I have this
tasks:
build-python:
dir: './python'
vars:
SOURCES: '{{.SOURCES | default ""}}'
GENERATES: '{{.GENERATES | default ""}}'
# Cannot use checksum as a variable, perhaps due to the variable being only evaluated once even when included multiple times?
cmds:
- echo "Do the actual work"
# Only update the stored checksum if the task is successful
- python "{{.REPO_DIR}}/tools/checksum_repo.py" put "$(pwd)/build-python" $(python "{{.REPO_DIR}}/tools/checksum_calc.py" {{.SOURCES}} {{.GENERATES}})
status:
# Avoid side effects
- python "{{.REPO_DIR}}/tools/checksum_repo.py" check "$(pwd)/build-python" $(python "{{.REPO_DIR}}/tools/checksum_calc.py" {{.SOURCES}} {{.GENERATES}})
which appears to be simpler than that one
the new vscode plugin for github actions is cool
Not sure if this is devops exactly so feel free to direct me to another channel.
I have a python web service written using aiohttp, which logs to stdout using the built-in logging module. I'd like to funnel these logs into some kind of web dashboard, so that I can inspect errors, see usage stats (ideally with fancy graphs), etc. I'd like something open-source and self-hostable, that can run on the same local box. A lot of the solutions I'm seeing (e.g. grafana) seem kinda heavyweight. Does anyone have recommendations for something more simple and lightweight?
I don't need any fancy features, I just want a step up from staring at lines of text in stderr lol
Is there anyone with a good knowledge of pyinstaller around here ? I'm losing my mind trying to bundle my app into an exe and can't seem get help when i make posts :/
well, you just made the post a few minutes ago, so your best bet is to wait a moment :D I will check it out
If you want error reporting specifically - look into Sentry or Glitch
I want both errors and general metrics tbh
is Grafana Loki too much?
You can get performance metrics with it too
have you used Glitch? I have been meaning to check it out
It's a fork of sentry IIRC
@potent cedar Grafana Loki is not that heavyweight. But if you think it's overkill for a single server, you probably end up reading & analyzing logs via tail and other UNIX utilities. For graphs you could use Graphite / Collectd+Sickmuse / Monitorix / Munin/ Vanilla RRD at your choice
I was looking at it and it sounds kinda heavyweight but maybe it would be fine
sentry seems to have a weird not-FOSS license even though the source is available
right
they say it's a "reimplementation"
lnav is great for analyzing logs locally
not sure if it supports plotting metrics
glitch is looking interesting, reading the docs now
But I would advice to use Grafana if you have resources, because it is an industry standard, especially for metrics (not quite industry standard for logs though)
glitchtip is MIT
the thing is, the actual service I'm monitoring is designed to be ultra lightweight (it's using like 40MB RAM right now) so it would pain me to spend more resources on monitoring than actually running it lmao
haha, sentry is quite heavy, not sure about glitchtip
I think any OOTB solution is gonna be heavier than that
Prometheus is lightweight, have some built-in web UI, it's jsut not very convenient in comparison with Grafana
glitchtip says min requirements 512MB RAM, hmmmm
maybe I'll roll my own logging dashboard lol
https://glitchtip.com/documentation/install Honestly their sample docker-compose looks better than one from sentry
Sentry one is a nightmare
if you want the lightest possible thing, install systemd-journal-gatewayd and put it behind nginx with basic auth or a VPN
if you run your service under systemd you already log to journald
oooh neat (I will be running under systemd, once I get my act together and write a unit file)
iirc this is just to stop people from creating direct competitor of sentry (SAAS version) using their source code.
I mean, I get why they do it, but I don't want to use software written and maintained under that mindset
i am hosting sentry myself, it's a really complicated stack to say the least.
and their latest major version is slightly broken for months, so just be ready for some frustration if some things don't go your wayπ€·ββοΈ
Sentry 9 was still usable. After that they added like 3 new databases and I couldn't even run it anymore because the Clickhouse thing needed CPU instructions I didn't have
In vscode with the standard Python extension, when I autocomplete a method definition on a class i'm building which is inheriting from a Protocol/ABC, it is generating an import at the top of the file for the param types from the method, but those types are defined in the current file, so it makes no sense and causes re-definition errors. Anyone know why and/or how to stop it?
I even have "python.analysis.autoImportCompletions": false in my settings
`dlopen failed: couldn't map "/storage/emulated/0/main-tigercodez-all-in-one-tool/dist/pytransform/_pytransform.so" segment 1: Permission denied
[Program finished] `
How can I solve this ?
Hey folks, any idea what can cause "ERROR: Could not install packages due to an OSError: [Errno 22] Invalid argument" when installing a local wheel? For instance when running "pipenv run pip install .\file\tables-3.7.0+gpl-cp310-cp310-win_amd64.whl"
it specifically fails at this stage:
Collecting numexpr>=2.6.2
Using cached numexpr-2.8.4-cp310-cp310-win_amd64.whl (92 kB)
Installing collected packages: packaging, numpy, numexpr, tables
ERROR: Could not install packages due to an OSError: [Errno 22] Invalid argument
hard to say, can you make it more verbose and report back what it says?
i.e. add -vvv in the pip install
ah thanks for the tip
ERROR: Could not install packages due to an OSError.
Traceback (most recent call last):
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\install.py", line 449, in run
installed = install_given_reqs(
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\__init__.py", line 72, in install_given_reqs
requirement.install(
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_install.py", line 800, in install
install_wheel(
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\install\wheel.py", line 731, in install_wheel
_install_wheel(
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\install\wheel.py", line 591, in _install_wheel
file.save()
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\install\wheel.py", line 388, in save
with self._zip_file.open(zipinfo) as f:
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1530, in open
fheader = zef_file.read(sizeFileHeader)
File "C:\Users\Eric\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 744, in read
self._file.seek(self._pos)
OSError: [Errno 22] Invalid argument
so it seems to fail while trying to unarchive the wheel?
perhaps the wheel is corrupted, it's tracked with git
could you cd into file directory and install tables-3.7.0+gpl-cp310-cp310-win_amd64.whl without all the \?
i have a feeling this is an issue with \, just a guess.. i don't use windows, but i recall it's usually \\ or something.
same issue here
if the path was wrong it would show the path as the wrong argument I think
the weird thing is that it does download the subdepdendencies it seems like numpy and stuff
very confusing
oh right, i missed that.
can't be related to this right...? https://stackoverflow.com/questions/74906148/error-could-not-install-packages-due-to-an-oserror-errno-22-invalid-argument
Yeah I've tried it but same result, this would fail immediately when opening the file
so I suspect the file might be corrupted, will ask my client
potentially, but if you managed to install wheel from another random library then it's less likely. perhaps something to try now?
good idea, it definitely works
so the wheel is just weirdly corrupted
thanks for your help
π
@surreal ridge oh hey clem
Trying kubernetes for the first time
Decided to do a fresh install on my os and now I'm feeling curious bout it
π welcome in one of the deepest rabbit holes haha
Don't go full on Kubernetes btw, except if you have mulitple VMs at hand (at least 2)
You can still learn about it, but you can't really use its full potential running it in a single VM
There are simpler distributions like Minikube that will be easier to deploy
Do you now have your own server? If you want to take the full k8s route, I'd recommend getting an hypervisor (again :))
Well, I have gotten my hands on a small laptop that I'm now using as a makeshift server :v
So hey
Perhaps I can do something with it
What's makeshift?
Yeah even on an old laptop you can get proxmox - at least you'll be able to spawn VMs on-demand
Sweet, I'll go all in then
Nothing better than diving into the ocean while barely knowing how to swim
Steep but honestly very satisfying: being able to spawn VMs on-demand, play with them etc starts to feel like magic
In a nutshell proxmox is exactly like VMware or virtualbox except it's an OS as a whole
you install it on your host (laptop) and Proxmox will come with a GUI that will allow you to create VMs by just uploading any ISO you'd like
I followed this, but it was 3 years ago: https://www.dlford.io/how-to-home-lab-part-1/
some stuff might be outdated but I found the explanations to be nice
double check that your laptop CPU supports virtualization btw
That's pretty much the only thing that can really block you here
Yup, finished checking
it does support virtualization
I'll see about installing it later
ty clem π«Ά
@surreal ridge
Let's have it clarified that minikube spawns multi node/VM cluster for u. No need for virt other tech
Also, the most superior virt tech is Vagrant in this specific usage case (if not to use minikube), because it is VM as a code similar to docker containers
Recommending starting journey with book docker deep dive to docker first
What do you use to track you task in small personal teams (like 2-3 people)? Jira is too big for this and Trello is too simple. I'm also kind of sick of Attlassian, so I want to try somethin new. I found Linear and ClickUp, wdyt?
Integration with GitLab would be big plus
why not gitlab itself? Doesn't it have a sorta TODO list thing?
surely one of those is what you're looking for
exactly
, if you consider gitlab issues as jira tickets, you pretty much have jira in gitlab
yeah, voting for Gitlab/Github issues. They are actually meant for this. one Issue is one task -> Bug fix / or feature request or whatever
You can join them into Milestones to have defined goals(set of tasks) for next release, with watching this green bar filled and getting filled with satisfaction you are going in right direction
Assuming u will mention #Number of issue in your git commits, commits will be autolinked to relevant issue ^_^
How are those compared to independent tools I mentioned?
