#tools-and-devops
1 messages ยท Page 79 of 1
Yeah. Tht machine will have skme rev shells n privilege escelation stuff. The double base64 is just to annoy em tbh lmao. Imagine the code obfuscated. They will have to figure how to decrypt the rsa key. I tried to make it as simple as possible
May i ask wdym
ergh. The code just has too many times repeated base64 encoding decoding. 9 times. It should happen only two times in the code.
too much of repeated open file/read code as well.
And most importantly the code in part two is just terrific student level interface, Could u use normal tool to make CLI interface? Like inbuilt argparse, or preferably click which provides the best CLI interface experience, with automated most comfortable... standards similar to other CLI tools in Linux, and inbuilt help support to navigate which commands exist and which parameters they take
Then usage of program will be up to Linux CLI comfortable standards, which will make the code really easy automatable for any tool
Like program.py key generate
Ofc i could do tht.
That code is meant to be for ppl with almost 0 exp
Thts why there are so many file opennings and calls to those base64 methods
To not make the user jump back n forth
Now, applying argparse or any cli lib isnt hard so i can do tht
click is the best, but requires third party library to install, really easy to eye due to decorators usage, quite pleasant code in result
argparse is default inbuilt one, not requiring any library, that's the advantage it has.
Ik used argparse lots of times before
Never used it. Remember using another kne but idk its name
click is part of flask package, i think
Got it installed for an example iss tracker project
I will remakecit using 2 methods. Encrypt / decrypt
Functions*
it's an indepedent package. flask uses it for its cli
Anyone know where I could ask some docker/jupyter questions?
Here
I am setting up a docker container with the JupyterLabs and trying to set up an accessible drive, using windows 11 & WSL
I canโt seem to get anything to work and suspects itโs because I am a moron
By accessible drive, do you mean that you want to set up a mount/volume for the container?
Yeah and that be accessible from the desktop
I can navigate to the WSL volume but no data related to my container there either
In other words, a directory that can be accessed both on your host machine (Windows) and inside the container?
Yes
Then what you need is a bind mount. You can use the --mount option with docker run to specify the mount. Is that what you've been trying?
Or --volume, either way. Just different syntax
Ok I donโt think thatโs what I was doing, I will look into that
Thanks mark
does anyone know how to use the tweepy v2 api streaming class?
hi guys. how do i change the package install to a custom enviroment on mac os? So that everytime I !pip install package it goes to the custom enviro
I like to use pyenv to manage environments on my mac
but there's other options too, and people seem to be opinionated about it ๐
there was a recent talk at pycon on pyenv https://www.youtube.com/watch?v=-YEUFGFHWgQ Talk - Calvin Hendryx-Parker: Bootstrapping Your Local Python Environment @wise cave
Hi everyone!
I was just offered a promotion from Support into a DevOps engineer role. Anyone have any solid resources for getting started? I'd like to have an edge once I begin my training for the new role.
Does anyone know any online sprite cutting tools like Alfredโs sprite sheet unpacker?
invalid syntax error help me ?
@heavy knot ask in a help channel, not here #โ๏ฝhow-to-get-help
shut and up ?
Is there an existing tool to look at older Python files (like ones for 3.4) and find what they need to have changed in them to work on newer Python versions like 3.9?
Not looking specifically for those version stuff, but a tool that tells you what you need to fix when going from version 3.x to 3.y
!pypi pyupgrade
hi all, i have a question regarding Github. On my page, it shows that I have 16 repos but I actually only have 7, where did the rest of them come from?
Is there an issue with pip rn? I'm getting
WARNING: There was an error checking the latest version of pip.
In my terminal, but that's all I'm getting. I have an internet connection and I can install packages just fine, and pip is already up to date, so I can't think of what else would be causing this?
I'm on windows on py3.10.4 if that helps
how are you running pip? py -m pip?
I only see 7
pip and py -m pip ๐คท
Hey @open forge!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
https://paste.pythondiscord.com/ikohawayes this is pip debug if its worth anything
on your side? It's 16 on mine...
debug output looks fine. you could try increasing the verbosity of pip install to see if that gives anything meaningful
alright, one sec
could be private repos?
When I increased the verbosity it managed to upgrade pip what the hell
one sec let me see if the issue is still there
no i dont have private repos
oh I'm a dumbass I forgot to include -U when I did py -m pip install -U pip but I did include it when running pip install -U pip
My bad ๐
have you contributed to any repos?
other than yours I mean
also since when did pip use and vendor rich?
contributing to repos counts as 1 repository towards my page?
apparently. mine shows 14 but I've only got 7
ah sweet
so...it's not a glitch or?
a cursory search on the webs indicates it's a bug? not sure though
hmmm...alright well as long as everything's there, it should be fine, though I'll try to find out about it still
Thanks so much for the help too ๐
lmfao bro you dont know basic python syntax and you ask help for that?
Is it possible to use pre-commit in a nox session without installing the tooling separately ?
Looking at this for example : https://github.com/cjolowicz/cookiecutter-hypermodern-python/blob/main/{{cookiecutter.project_name}}/noxfile.py#L113-L134
the linters etc used in pre-commit are installed with session.install - but this is typically something that pre-commit does itself if it's not been setup, so I'm wondering why this is necessary, seems as though it's duplicating what's already in the pre-commit config.
ping me if you respond please
ah maybe it's because this is set to local only https://github.com/cjolowicz/cookiecutter-hypermodern-python/blob/main/{{cookiecutter.project_name}}/.pre-commit-config.yaml#L2 , hrm, tho i'm not sure why that would be done
%7B%7Bcookiecutter.project_name%7D%7D/.pre-commit-config.yaml line 2
- repo: local```
Indeed if it's local then pre-commit won't use its own venv for that hook. The only reasons that come to mind are:
- They prefer to manage dependencies here. Maybe consolidating them into a single location.
- The Python version may affect the versions that get installed. Not sure how flexible pre-commit config is regarding dynamically specifying a Python version.
Number 2 indeed seems to be the explanation. I skimmed through the article that repo is based on
There is a problem though: The sample configuration pins Black to a specific version, and so does Poetryโs lock file. This setup requires you to keep the versions aligned manually, and may result in failed checks when the environments managed by pre-commit, Poetry, and Nox drift apart.
.pre-commit-config.yaml lines 1 to 2
default_language_version:
python: python3.10```
But that's not dynamic
I'm usijng pyinstaller with a .spec file
and i got these hiddenimports
a = Analysis(['entry.pyw'],
pathex=['C:\\Users\\ME\\PycharmProjects\\pythonProject\\projectFolder'],
binaries=[],
datas=[],
hiddenimports=["mss", "numpy", "win32gui", "cv2", "win32con", "win32ui", "winsound", "tkinter", "requests"],
but i'm getting ModuleNotFoundError: No module named 'requests'
and i did pyinstaller --clean entry.spec
what am i missing?
So while using black, isort, and flake8 with a project containing Cython *.pyx files with Cython syntax for some commands, black and isort will seemingly work fine, but flake8 will throw false positives since it's not built for handling Cython code
Is there a flake8 alternative I should be using for checking Cython code?
And on a similar note, is there anything I can use with VS Code for handling Cython? I found this VS Code plugin called Language-Cython found on the Visual Studio marketplace, but it makes me apply the language to the file every time I open a *.pyx file
That sounds more like an issue with your global or virtual environment not having the requests library installed
it turned out that requests just doesnt work with pyisntaller
i changed it to urllib and it worked fine
Wait
So with RubyGems
Bundler and Gems will manage package versions AND the dependencies for the package version seemlessly
unlike with venv, if I downgrade a package in my gemfile.lock in Ruby
all the dependencies all the way up the graph are downgraded by Bundler/RubyGem
seemlessly
but my global Ruby Version will have the latest dependency
is that right?
Is it just me or is that much better than Python?
Not necessarily. In Python, I believe pip gives an error if constraints cannot be resolved. For example, your program depends on a feature in library A>=2.0, and A depends on B>=2.0. If you downgrade B to 1.0, then A>=2.0 would no longer be satisfied. If A were to be downgraded to work with B==1.0, then your app would break because it relied on a feature in A>=2.0.
Hey guys, I'm in a selective process for a company, and in the test instructions they say Use of Docker is NOT required but *greatly appreciated*.. The project is mostly a jupyter notebook using pandas. What do they mean by this?
Like, have a container for the app? How would that even work?
I get it if it was supposed to be made in Django or Flask or whatever, but this makes me confused
I am not familiar with jupyter but doesn't it host a local webpage that you can access? Maybe they mean that you should set up a container to host that. https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html
But what reason is there to do that?
to prove you know Docker? ๐
or more seriously, to prevent jupyter from modifying your host machine's existing stuff?
Maybe it's easier for them to run what you worked on if it's containerised (less work for them to set up a suitable environment with dependencies)
Maybe
I think I'll just upload the .ipynb file to Google Collab after I'm done ๐
Much easier, same result
But thanks guys ๐
thanks for this btw... I'm not sure how i feel about what they've done there I guess, re using nox in that way. I've not seen it done so much - perhaps it's fine.
Colab can't handle Tkinter unfortunately
https://towardsdatascience.com/how-to-create-a-docker-image-with-jupyter-notebook-kotlin-2e8bbf212f81 anyone know how to convert this from Kotlin to Python?
Have you tried reading through the link I sent? Here it is again https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html
Yes, couldn't find an example Dockerfile 
I don't think you necessarily need to write your own image. Do you have additional dependencies that the base images don't supply?
I'm not sure either.
It seems to use conda to install Python
I suggest you test if the provided images come with tkinter before going through the effort of writing your own.
The article you linked for Kotlin doesn't state whether tkinter is supported by that setup.
Yes because it won't work
venvs are not designed to be relocated to different directories let alone different machines
Best practice is to include a requirements.txt with all the dependencies or equivalent if you use a tool like Poetry.
I don't know how conda users deal with it though.
If that's what you're using instead of pip
I use pip actually, I was gonna include requirements.txt anyway but since they specifically mentioned Docker I don't know
Anyway, thanks ๐
Since I'm using jupyter, should I install all required libs with !pip install [...] on the first cell instead of doing this?
I have never used jupyter so I don't know what the best practices are for dealing with dependencies.
In general though, first a venv is created, then activated, then pip install -r requirements.txt. Once all that is done, the actual program can be started
No worries, thanks!
Can anyone explain what the ~= does in a requirements.txt? If I'm planning on the code being usable for both Python 3.8 and 3.9, should I use that operator or <=?
Upper version constraints for dependencies are a contentious topic. Here is one lengthy discussion if you want to dive into the rabbit hole https://iscinumpy.dev/post/bound-version-constraints/
It's more of a problem for libraries than for applications though.
Thing is, technically it should've been written in Python 3.8
But I'm on 3.9, since there's virtually no reason for me to be in 3.8
So my generated dependencies are for 3.9, therefore I don't know what to do
What do you mean by "generated" dependencies?
You mean what you get when you pip install a package without a version specifier?
pip freeze on my venv
Oh
Yeah locking dependencies with an approach like pip freeze doesn't necessarily work out if you want to support multiple Python versions
You'd need a separate pip freeze output for each python version you want to support
Hm
Though you may pick the lowest version and it will probably work fine on later versions
If I leave just the libs on requirements.txt, will it install the most recent compatible version?
If you put the package names without any version constraints then yes, it will install the latest (or use the existing version if the venv already has it)
Great, thank you! ๐
But using the latest version isn't guaranteed to always work. A newer version may introduce a breaking change
So some people set upper constraints to prevent that. But then that causes other issues. So, it's a complicated topic that the post I linked goes into.
That's rough
In your personal opinion should I set upper constraints or no then?
What I've been doing for applications is essentially a pip-freeze that's generated from some initial constraints (that typically only contain lower bounds)
I haven't had to deal with supporting multiple Python versions recently so I'm not sure how I'd handle that.
You're welcome.
Sorry I cannot offer more concrete advice on version constraints. It's a daunting subject.
No worries ๐
Hey guys, not sure if this is the correct channel, but is there a way to check which of my 3.9 libraries have been ported to 3.10 and "auto install" them?
You can use pip list -o to list outdated packages
im trying to make a ig tool.can any1 help me..
Im getting this 405 response, i want to be posting to port 5000, is it not doing that?
Guys I need to use another library in my public project. My project is licensed under Apache 2.0 and the third party library is under the GNU General Public License v3.0. From what I read they are compatible.
I do not want to add this library to the project dependencies, but simply add the folder with the module to my project (so as not to depend on it on pypi, suddenly HE will remove the package).
My question is: what should I do so that I can do everything as described above? I saw some people call such folders "vendor" and add a license to it, is that enough?
How to choose a cloud provider for an edtech startup ?
in jupyter lab, can i attach a console to the currently running notebook kernel?
nm, found my issue. .. was starting a new 'terminal', .. i should've started a new 'console' and attached it to the currently running kernel
You pick one.
There's a lot to choose from. Digitalocean , Linode , heroku , google cloud platform , azure , aws.
I've narrowed down to aws , azure and gcp ? Any personal recommendations on these 3.
AWS has first mover advantage, Azure is good but bit enterprisey, GCP is cheapest generally but A) It's Google and B) Has least features.
Pick one, whatever decision you make will be wrong
You can't. Vendoring that code means your project must also be licensed under GNU GPL v3.
It's debatable whether GNU GPL v3's viral nature also applies if you're using it as a standard dependency, but vendoring is 100% going to cause you to run into the copyleft clause
I need to deploy (zip files) AWS Lambda functions written in Python to an S3 bucket. Does anyone have a great open source tool to make that easy? I am familiar with Docker and Gitlab CI (in fact we already have Django build and deployments, but I'd need retrofitting and some changes).
Hi everyone! Can anyone recommend any decent courses/workshops for furure SDETs? CI/CD, performance testing(jmeter/gatling), any additional stuff expected from ex QA moving towards SDET career? :)
https://python-poetry.org/ anyone used this and know how i can utilise it with pycharm?
Python dependency management and packaging made easy
thank you!
you can configure PyCharm to use Poetry using Settings โ SDKs โ Poetry environment
neat, thanks!
Ive built my docker project having two entirely different configs for prod and dev, and i realize now that this is not the way to do it. It makes prod and dev too different.
the django-cookiecutter config is too divided between prod and local for no reason.
Add third config: staging/preprod
And it should be having almost everything similar to prod
Including deployed to cloud
It complies with the 12 factor development approach https://12factor.net. This helps to test what works in local will also work in production. And whatever is in development in local will not affect production until it's ready.
can someone help me with parallelism in python i'm stuck. I've a project and i need multiple instances running at the same time bot i don't know how to do that can someone explain it to me please ?
You mean like multiprocessing or threading?
idk what that means but if you just want parallel processing, just use either threading or multiprocessing.
I like how this guy explains it https://youtu.be/ecKWiaHCEKs
Let's just clear up all the threading vs multiprocessing confusion, shall we? Let's jump in!
Hope you enjoyed the video!
Check out this code here:
https://github.com/ebrian/engineerman/tree/master/036
Join my Discord server to chat with me:
https://discord.gg/k5VcqDP
Check out some code on my GitHub:
https://github.com/ebrian/engineerman
Tw...
yup but once i start my loop it didn't start the other process
thx
i'm looking it
hey
I wanna make a tool which will take values from a few live graphs
and depending on the values execute action ๐ฌ
how much time will it take me tto complete the project
give your answer in hours
45 minutes, plus or minus 10 minutes
thank you
any time
disclaimer: that was 100% sarcastic; I haven't the slightest idea how long it'll take; I don't even understand what you're trying to do.
Other than that, however, I stand by my answer.
lol I too was sarcastic
this is what i was thinking
isnt the 12 factor approach to make prod and deveopment environments as close to the same as possible so that you can make many pushes rather than few?
yes and no
its number 10 lol
yes that its supposed to be as close as possible so you can replicate what you have at prod to local and vice versa
But its also set as a way to decouple local and prod so whatever you are working on local and not sure to push to prod yet, don't put in the prod configs until its bug free
its definitely possible the blame isnt on the config or structure but on my implementation of it... not focusing on treating development like staging by default
and to be honest it has local/prod files for too many things.
One clear example is the debug value for local. You wouldn't want debug enabled in prod
right i get that but in the grand scheme, these should be deploying the app to a container on docker that is treated like a production environment. the dev step should use all the same steps as prod except a few things.
exactly
you should just start building for production in development i thnk instead of working on a dev config that you cant use
What do you mean by "can't use"?
Why would it be in dev config if I can't use it?
im just saying, spending all this time getting things to work in a dev environment is a waste of time. You dont need twenty billion files to first build the dev app, then build the prod app, almost a completely different app in some ways.
Instead, just build the production app. In the dev environment, flip a few switches, change this to that. But you shouldnt configure an entire series of "For the development version" files from requirements to django settings to different evn files to to different dockerfiles to different compose files.
its excessive
how they do it in that cookiecutter structure
So you would have to remember to always flip the switches back before deploying to prod, right?
The cookiecutter structure was supposed to not have the switches flipped or be reminded to flip between prod and dev since the configs are separated out from the beginning
Im just saying, some of the templates ive seen are not in their perfected forms is all.
and thats probably true of every docker config ive looked at...
it just took me going ove rthem to learn this
Not saying you have to follow the 12 factor approach.
yeah.
But it is one of the approach
Especially working in teams
Where everyone has the same development env set up
But working solo, we can do whatever we want
but even in 12f
A methodology for building modern, scalable, maintainable software-as-a-service apps.
the configs are tied to the env and everything else falls into place. There is no need for... look at this
why not all this in... less files?
i like the overide yaml system
Not sure what the problem is. It's just extra files.
I guess we're different. When I open a linux CLI, I don't see files until I ls them. Otherwise, it's just another blank black screen to me.
As long as I know where local and production files are, that's good enough
And whatever is supposed to be in production is supposed to be there, is there. local files should stay in dev.
hm. I mean this is just my first time doing this and the way i did it wasnt perfect.
thats really all it is]
and i learned some things from it
Well worry less about it
yeah. i just need a break haha
i been at this for like 24 hours lol
well nah i think the cookie cutter is a great idea, i just think i might consider some better organizational skills than i did this time
Then you'll find the reason behind 12factor approach
really i think the fault is with me, not the structure
it was to solve that struggle
well the one thing that is making the most sense to me at this point is number ten
whcih i definitely did not follow
at all
but it made sense to you?
it does make sense to me but I wish i had prepared for production configs sooner and wasted less time working only on the dev environemtn.
Well that's what the cookiecutter did. It made the prod configs and the dev configs. So its easier and faster to deploy
yes but as I built the app, I neglected to work on prod and worked on development configs. In the end, I have to rewrite the app. It was a waste of time. In the future, my dev config will be ....as per number ten of your 12 factors.... essentially a prod config but staged to a stage server/container
that is otherwise a prod config
and that is where i will develop
it wasnt a waste of time...
there is no way i would havel learned all the things i learned if i didnt try doing it
Cool
has anyone tried sagemaker serverless? how is it compared to traditional lambda + API gateway architecture?

Hello, im trying to get priority speaker in discord group chats , or to make me louder in discord Group chat ( just a way to lower people and be louder ) Can anyone help me ?
How do I merge my master branch to main branch?
I'm a beginner and pushed my project onto github.
It sounds confusing. Let's have master branch as main one
Delete .git, git unit it locally, dump everything into initial commit, and force push to remote
Or tinker in github settings online, if they still allow choosing master as master, and just delete main
Yeah I mean people use only one branch either main/master but just wanted to know how can I merge my master into main
git checkout main
git merge master
you just want to rename the branch, right?
or do you have both branches simultaneously?
@heavy knot
It's more like I wanted to try make a pull request but then I wasn't able to.
Though then I changed my default branch to master and deleted the main branch as @rapid sparrow suggested.
okay. you can just rename your branch though
I tried that too but changes were not made on main branch on GitHub.
git branch -m master main
git push --set-upstream origin main
uh, git checkout master -> git pull master -> git checkout main -> git merge master then
Aight okay
Is there a way, by chance, to make the On branch whatever when you do git status show up in all caps or a different color or something? I'm always looking for that tiny line of what branch I'm on but it gets lost in the other output 
maybe just type "git branch" instead
and check for *
or use some sort of UI -- many shells have git status stuff built in (ohmyzsh and/or powerlevel10k e.g.)
e.g.
homedir on git 
can those themes be applied to powershell perchance ๐
heh
but I think powershell has plenty of customization too. I put a timestamp into my powershell prompt, but never bothered with git status since I don't git much on winders
"oh my posh"? Heh
posh-git works and was easy to set up
thanks offby
๐
hey , I have this django project deployed on a local server running on docker containers
I'm using nginx to serve media files. It works on my machine , but when deploying to the local server the mediafiles are not loading. Any Solutions ?
- have you verified these files are accessible?
- have you verified the URLs you generate are valid?
The things that surprises me is that , it works on my machine and not on the local server.
The folder and the files exist in the docker container.
then the obvious answer is to dive into the differences
all else being equals, it should work
How do i set django's STATIC_FILES and MEDIA_FILES location as a directory in another docker container ?To be precise i want to set the STATIC_FILES and MEDIA_FILES location to be a folder in the nginx container ?
I think your only option is to scrape it
perhaps https://docs.github.com/en/rest/activity/events#list-events-for-the-authenticated-user ? though that contains a lot of events
I've read and seen examples that the past data can be written to show usage (or not)
Is anyone aware of a marketplace AMI which embed a CMS and allow to use a remote postgresql backend using tags or whatever which avoid to do anything from within the instance ?
the v4 api has that information
https://docs.github.com/en/graphql/overview/explorer
query {
user(login: "kosayoda") {
contributionsCollection {
contributionCalendar {
totalContributions
weeks {
contributionDays {
contributionCount
weekday
date
}
}
}
}
}
}
How would I resolve this issue when running pip install -e .? ```
Obtaining file:///home/mart/git/kaudio-python
Preparing metadata (setup.py) ... done
Installing collected packages: kaudio
Running setup.py develop for kaudio
error: subprocess-exited-with-error
ร python setup.py develop did not run successfully.
โ exit code: 1
โฐโ> [79 lines of output]
<...>
running develop
/home/mart/.local/lib/python3.10/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/mart/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
error: ("Can't get a consistent path to setup script from installation directory", '/', '/home/mart/git/kaudio-python')
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
ร python setup.py develop did not run successfully.
โ exit code: 1
โฐโ> [79 lines of output]
running develop
<...>
/home/mart/.local/lib/python3.10/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/mart/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
error: ("Can't get a consistent path to setup script from installation directory", '/', '/home/mart/git/kaudio-python')
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
Here's my setup.py: https://pastebin.com/HHYhvrZu
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
๐ค is there a way to not let it do stuff to Pydis?
or does is not change anything?
thanks, I'll take a look at it
I have no idea what GraphQL is so I'll need to do some digging
GraphQL is just an alternative view to REST API
instead of having multiple endpoints, they are merged into one that can be queried with graphql language to get different outputs
as a pros of this approach, client can query precisely info which is needed. no less, no more
and theoretically more stuff can be queried in parallel in one request
if they provide rest api endpoints, why not ๐คท
or if u wish to provide rest api in your app
also small benefit of graphql, that it can potentially decrease amount of endpoints ๐ค i mean it would be just one endpoint with less duplicated logic perhaps
Hello. ๐
I have a slight case of dependency hell which has led me to ask the following question, to which I have not been able to find a suitable answer:
How do you deal with a situation where your dependencies have conflicting dependencies in the same project?
The information I've found for dealing with dependency issues was all about separating into different projects, virtual environments, etc. - but what do you do when you need these things in the same place?
you mean, two versions of the same library?
I don't think there's a good solution
well, you can always run two separate Python processes
So far I was just resolving those conflicts. And that's it
with having requirements.txt only with core deps, and all secondary deps in constraints.txt, it makes easy to resolve conflicts
as an option there is also to use pipenv, which sorts of helps with this too, but I still struggle how to solve problems in a nice way in it xD
Sometimes i have situation when library is not updated and just can't be used in newer versions
in this case I just take this library out of deps and put into my source code folder
and update the necessary stuff in it
optionally I could have deployed a fixed version to pip though
Yeah, I've been doing that, but it's a painful process and I find myself thinking there must be a better way.
I had to update a certain package, which forced me to update another, which forced me to update another, ...
Each one I upgrade breaks some other package dependency, and I don't even want to update the other things that use them - if X and Y were using v1 of Z and now I upgraded Y which makes it need v2 of Z, I still want X to use v1 of Z.
Is there no way to accomplish that?
- just try to add less packages to your project. xD
u will have less problem then
- split the service into mciroservices, each one will be having need for less packages to use
- optionally clean architecture can be used in order to contain implementation details in certain places for easier changes
Introducing microservices or any other IPC sounds like a lot of extra complexity if you just need two versions of a package
Good advice, but doesn't help with a project that's been around for years already. ๐
I'll be working on reducing the dependencies there, but my question is more general and not specific to my project.
Is there a way to make a package use a specific version of some dependency it has while another package uses a different one, all in the same virtual environment?
Is there a way to make a package use a specific version of some dependency it has while another package uses a different one, all in the same virtual environment?
No, that is not possible in the general case.
I guess if the library uses relative imports (like from .bar import baz instead of from foo.bar import baz) you can rename one of the packages into foo2 and still have it work. But it's a hack, and it won't work if it's a transitive dependency
Maybe justuse can help in some way? https://pypi.org/project/justuse/
its README claims it can have two versions of the same library in the same venv, somehow
Thanks for the suggestion. I checked it out just now and found this:
np = use("numpy", version="1.21.0rc2", hashes={"3c90b0bb77615bda5e007cfa4c53eb6097ecc82e247726e0eb138fcda769b45d"}, modes=use.auto_install)inline installation of packages and importing the same package with different versions in parallel in the same code - most people wouldn't even dream of that!
This is quite interesting and potentially promising (assuming it actually works).
Now, if there was a way to take a module and redirect itsimportstatements to use a similar mechanism to take the right version, that'd be great.
One thought I had was to map the dependencies in some file, then wrap imports in code which temporarily places you in an environment where the expected packages have the right versions installed.
That is, continuing my example from above, you'd have both v1 and v2 of package Z installed somewhere, and you replace import X with X = myimport("X"), which would then point the module search so that importing Z would lead to your installation of v1, just for the duration of performing the import, in order for the loading to get the right thing.
And similarly it would point it to v2 when doing myimport("Y").
But that would only work on the top level, as I can't go and replace import statements in external packages.
you could ask the authors, which are regulars here. @greyblue92 and @amogorkon
Is there a way to make a package use a specific version of some dependency it has while another package uses a different one, all in the same virtual environment?
@shadow crow it is possible actually
just copy the package into your source code folder
and rename it being a different one
woala. U have two packages of same thing that can be even different versions
A bit of a WET solution, but if we will explicitely forbid changing code in this package, I think it is sort of a solution
although technically it is not WET, since both packages will still not be containing any of your code ๐ค
it will be just a different way to install package
slightly dangerous due to possibility for you introduce changes into it, that will be hard to track if you decide to upgrade the package
did you mean voila
I think what you're describing is called "vendoring"
yeah
I was planning on doing just that; didn't know they were regulars here, so that's a time saver. Thank you. ๐
That would work for having multiple versions, yes, but it wouldn't solve the issue of your dependencies needing to use said versions, as they only have "import whatever" rather than whatever name you gave them.
But that's the basis of what I said, sort of. Having multiple versions available, then redirecting the imports to the right ones.
It doesn't need to be in your project though, just some folder you create when you do your setup and install your dependencies.
Oh yeah, it would mean u would have to copy not just deps
but also the parent dep
Yeah, it gets complicated when you take multiple levels into account. =\
Anyway. Your situation starts to sound similar to this funny interview https://www.youtube.com/watch?v=Uo3cL4nrGOk
Javascript programming language
Interview with a Javascript developer in 2022 with Jack Borrough - aired on ยฉ 2022 The Javascript.
https://imgur.com/a/PnaZq1F
Find more Javascript opinions under:
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f
Programmer humor
Javascript humor
Programming jokes
Programming memes
Ja...
"My job is to keep our code running while other packages are changing theirs." (quote from video)
https://jjquery.io/ bwhaha. Someone had a humor and created web site in honor of the video above
You tried CoffeeScript, rewrote it in TypeScript, then went back to vanilla JS. Now it's time for JJQuery, the new de facto Javascript standard for the web.
won't work if the package uses absolute imports
Love people with good humor. ๐
Hey guys I have a question about GIT and VSC :
I just installed Windows. git is also installed. i am cloning a repo then making a change. nothings come up here :
It was not like this before my windows formatting
Does someone retrieve secrets from AWS secretsmanager through ansible ? I have a hard time achieving to do it, the lookup plugin don't find it even if I force all envs while I can retrieve it with the cli ๐ฆ
in fact the lookup return not found if the secret exists but is empty ๐
Did you click the refresh button? Does running git status manually in the terminal yield anything?
Is this for like libraries and ide extensions we make
Cuz like Iโm not terribly great at making stuff but Iโm pretty good at making stuff to make stuff with
here:
and yes i tried to click refresh
reloaded the window? (Ctrl+P, "reload window")
I tried. nothing changed
Could it be that the "publish to github" prompt is blocking any git operations?
press esc until it goes away
so I deployed a flask application on nginx (ubuntu vps) and connected a mysql database to it
its up and running but every other functionality except login is working
I used flask login for saving the user session
everything works properly on my local server
but here the session is not being saved
Why people use pipenv?!
it is not showing dependency errors in detail! This tool suggests me only to install stuff with --skip-lock and checking manually what the hell went wrong in pipenv graph
in regular requirements.txt+constraints.txt it is much easier to handle
when you have everything installed, you throw it to constaints: pip freeze > constraints.txt
it locks secondary dependencies but will not install them
you point stuff necessary to install in requirements.txt without secondary deps
you can even point requirements.txt without versions at all xD they are locked in secondary deps anyway
makes relatively easy to handle deps i think.
we just regulate requirements.txt file, while having a free reign in constraints
it is technically really similar to how pipenv works
we just use pip default functionality
I started using pipenv because it's from Kenneth Reitz, who made requests, so I figured it'd be equally awesome. It isn't. ๐
Is a Github Token the same as Personal Access Token?
GitHub does use PATs. or do you mean a deploy token?
In Mac OS 12 terminal, python commend cannot be recognized, but python3 can be recognized, anyone know how to fix this?
get used to typing python3 instead of python is probably the best way
it's not broken; why do you want it "fixed"?
well, you could also symlink or alias python to python3
or install python from homebrew, which uses python and you can put it ahead in the path
Thanks~
Kinda. I basically wanna use it for GitHub Actions but not sure of which token is which and where.
apparently it's just a special token
you need a terminal window if you're using input
don't pass the flag that disables it
ai need something put
It's from the line you used to build th app, not in the app iteslf
don't do the -w
how can i add more script into one exe ?
bcs it open onlY one script after that when it will go to menu list it will close
i send it friend and he only got opened login
So I am trying to build a Dockerfile and I get this error...
Here is my Dockerfile
FROM python:3:10-slim-buster
WORKDIR /api
RUN pip install poetry
COPY pyproject.toml /api
COPY poetry.lock /api
RUN poetry install
COPY . /api
CMD ["sh", "launcher.sh"]
This is the traceback
Sending build context to Docker daemon 23.38kB
Step 1/8 : FROM python:3:10
1 error occurred:
* Status: invalid reference format, Code: 1
3.10, not 3:10
ah tysm
Question: In Sphinx, where is the builder_name added to the build directory?
Eg: buildir /docs becomes /docs/html when building with the html-builder.
โโโโโโโโ
Using the recommended make-mode aka -M.
I have combed through the source code without finding it where it actually modifies the outdir.
The reason is I am building for Github-Pages and the trick with the redirect inside an extra index.html seems to be breaking some stuff (mostly css for some reason).
I wrote a little sphinx wrapper because I also am doing other things not possible with base sphinx. This currently builds to an temp dir and then copies it to the docs folder directly with no html subfolder.
It works but if I could just fix that by sub-classing/custom-builder/extension/โฆ I would rather do that, as the current solutions is quite duct tapey and also makes sphinx console output non-sensical (your files are in <temp-dir>/htm/ for example)
Anyone has some knowledge about sphinx internals, and can help me?
feel free to ping/@ me when answering!
0 votes and 0 comments so far on Reddit
Umm if links are prohibited, I'll copy paste the whole post over here
I am creating a python library. I have put detailed docstrings with examples in all functions. Which tool can I use to generate documentation from these docstrings
I want this documentation to be available/readable on Github
So I guess it needs to export it to .md files? I'm not really sure about this part
Not at all use mkdocs
With mkdocstrings
Very ease and simple
Make sure you adhere to a doc style like google or numpy or whatever else there are
Thanks. I'll check it out.
that's something you should ask in an off-topic channel
Hello, guys!
Can anybody recommend some solutions for monitoring cron jobs?
I saw some paid options but prices were too high.
Looking for free self-hosted or cloud solutions with moderate price for small amount of jobs (up to 100 cron jobs/up to 1000 runs daily)
From my perspective, there is a free self-hosted option of grafana + timeseries db, when every job contain formatted output with result of job result (datetime, duration, name of process, high level exec result, low level exec result, etc) and this output will be redirected to our timeseries db. after that we put this data to grafana. We getting dashboards for cron jobs + option of alerting on unsuccecful runs or too long runs.
What do you think about that? What do you use?
Appreciate any advice or thoughts ๐
My first thought would be to recommend migrating from Cron jobs to Celery Beat, and just getting its monitoring system Flower
will check this option in details, looks promising. Thanks!
what is the best way to use all the linux commands in the windows terminal?
WSL
for some value of "in the windows terminal"
with WSL, you can run "bash" exactly the same way you'd run "cmd" or "powershell", and it's either 100% pure Ubuntu Unix, or else so close that I haven't noticed the difference
[not that I've spent a lot of time with it, but it's pretty impressive]
sudo chown myuser /usr/local/var/postgres/ is this location for mac?
i saw this on stacksoverlfow, and unable to resolve issue
this is the error
i am using ubuntu on windows
i have to urgently install an application, as asked by my professor
could be, or it could be for any of a number of Linux distros
you have to figure out which package includes postgresql-setup, install it, and figure out the directory into which that file goes
I just tried apt-file search postgresql-setup and it returned nothing which suggests there's no Ubuntu package that includes a program of that name ๐ฆ
I think the instructions you're reading are
- for Fedora, not ubuntu; and
- pretty sloppy
basically as a someone who just downloaded ubnutu, i am ...., right
https://www.prisma.io/dataguide/postgresql/setting-up-a-local-postgresql-database says
Once the MySQL package is installed, initialize the database by typing:
sudo postgresql-setup initdb
so you can tell this is not super-professional documentation
i am following this to reinstall:
is it ok?
how would I know?
if you are following their instructions and you've got a working postgres setup, then they're OK; if not, not.
I glanced at it and it looks reasonable; that's all I can say
according to professor instruction:
is this cosistent with alternate aproach to installation
๐คท
?
ask your professor then
๐ข
the postgresql12 package contains a file named /usr/lib/postgresql/12/bin/initdb. That probably does what postgresql-setup initdb does. Try it and see.
if that advice turns out to be useful, the lesson is: Ubuntu's "apt-file" program is super-handy; ask me for details.
ok trying
what to choose?
shows installed in 14.4 version of postgresql
I haven't the slightest idea
I don't use postgresql. and I don't know what your instruyctor had in mind
if i ask the professor, he might be dissappointed
well no offense but I don't want to study that repo in order to answer your question
my pc+my brain is going hay wire
well, your brain will cure itself if you take a rest. Your PC, though, I can't help with
havent cried in years, seems like record gonna break
postgresql-setup seems to be specific to the way rhel/centos/fedora packages postgres. Since you're using Ubuntu, you won't have that. initdb should be sufficient. https://www.postgresql.org/docs/14/app-initdb.html
yeah we've been through that
Sorry, I suppose I don't understand what the current problem is then
OP got initdb to work, but it's interactive and they don't know what to click on
Weird. I guess Ubuntu does things differently too
Normally it's a CLI command and you just need to give it a directory. https://www.postgresql.org/docs/current/creating-cluster.html Seems like Ubuntu has pg_createcluster so maybe try that https://manpages.ubuntu.com/manpages/trusty/man8/pg_createcluster.8.html
ok please tell me one thing
what type of location is that
is it mac?
how does it translate
i have located initdb
can't tell for sure
sudo and the /usr/ path format are unix/posix-based only, so mac and linux
though it appears for you that postgres follows similar paths in windows
fwiw on my mac my ~ is /Home/username
So do i need to enter from c: uptill bin for windows?
that would make sense, yes. to make that job easier, note that you can right click the address (the This PC > Windows (C:) > blah blah blah) and press Copy address instead of typing it all in manually
Ok thank you,
I'm trying to connect to a python language server from python, are there any lsp clients written in python?
also how can i run a language server independently ๐
sounds like something google could answer
sounds like i asked here intentionally since someone might have an answer
(i already googled it and spent quite a while but didn't find a result)
best to say that up front, to head off smartasses like myself ๐
how to run it independently: the one that I use is just a python module, which you just run from the command line, and iirc it just sits there either listening on an IP port, or else reading from stdin
I bet pylance works similarly
which one do you use?
I actually have to check! Hold on
python3 -m pip install 'python-lsp-server[all]'
my notes also say Beware: there's also a "python-language-server" but it's flaky and abandoned
ah and which editor do you use to interface with that?
Emacs
not recommended for normal humans
pretty sure pylance is what you want; it's the default for visual studio code, and I've never encountered, nor heard of, any problems with it
what i'm doing is making an api that interfaces with a language server
this is not for an editor :P
when you say you "didn't find a result", did you mean you didn't find anything that actually worked, or ... ?
because
I couldn't find a client
that was maintained*
might have to roll my own
I assume 99% of the interest in LSP is for editors, and I assume 0.0001% of editors are written in Python
my goal is an api which can return introspection on provided code and other tools
it won't be a public api, I'll be using it with another project
embracing lsp means I don't have to worry about the hard parts and can switch it out as well
i found this so post
Lets say ive been working on the same project in two repos.. and im now tired of switching back and forth. I would like to add one repo into a dir called old and merge that into that old one. But im having trouble getting it to "merge two unrelated histories"
Advice/guides on how to go about this?
or some other way i could slowly go over both in the same project and keep the best of both. keep in mind, these projects have entirely different structures despite solving the same problems
ideally the old and new should have been separate branches instead of repos
git does have a way to merge unrelated histories IIRC
Guys anyone familiar with configuration management in DevOps, having a hard time getting my head around what it does for the process?โฆalso do we use tools for this too? Since we want everything to be automated?
awfully broad question
that's like asking "Hey anyone here a doctor? How do you do brain surgery?"
๐ญ๐ญ๐ญ๐ญ
just ask a more specific question
Youโre hilarious man
Iโm trying dude ๐คฃ
CI/CD is hard enough
Then IaC - this stuff never ends ๐
"what does it do for the process"? Automates it, obviously. That's good because it reduces the risk of accidents caused by humans typing the wrong thing.
"DO we use tools for it"? Of course. Ansible, Azure Dev Ops, Github actions, AWS surely has something, &c &c
Thanks man ๐
I don't do all devops every day, but sometimes it feels like it (spoiler alert: I much prefer regular coding)
Trying to get my head around the term โpipelineโ as Iโve been reading it a lot. I hear it in many things. Like DevOps pipeline and CI/CD which is also apart of the micro services architecture too. I read just under this page with the title โCI/CD pipelineโ
The first sentence is
yeah it's pretty vague
โYour pipeline is the path your code travels from development to production.โ
Is this the case for all pipelines?
Like when I read the word, pipeline, is this what I should be visualising ?
I'm familiar with Azure Dev Ops pipelines, which is basically a super-complex process whose point usually is to take code you've checked into a git repo, and get it running on a machine, or machines, "in production", often with intermediate stops on "development" and "integration" machines
yeah that's roughly how I use the word pipeline too. But I bet you'll find people using it to mean slightly other things as well; it's a relatively new concept (I don't recall people talking about pipelines 20 years ago e.g.) and the definition hasn't quite settled down yet
Thanks for your help man. Really helpful good answers
I think the best way to learn about a tool like this is to not use it, and suffer; eventually you'll say "geez I wish there were a way to automate all this crap". At that point you'll be receptive to the idea ๐คฃ
... and if you never find yourself complaining like that, then pipelines probably aren't for you
I'm 100% serious here
Alright Thanks man ๐ค
if it helps any -- if you're good at this you can get paid a lot of money
๐โ๏ธ๐
that's another way of saying it's hard --
If it were easy, everybody'd be doing it
- A. Berg
so, finally was able to start initdb by sudo service postgresql start
but what do i do about systemctl
a little search indicate it require extensive hacking for working on windows?
are there alternative to systemtcl steps
if you have "service", that's roughly equal to systemctl
wininit i have heard, and wwould scm
would it suffice? also the second step is done right ? if it says:
i think i have installed 2 version and it start both
right?
how would you ban a specific string (TODO in this case) using pre-commit? It seems the fail language can only ban commits with filenames that don't match rules?
I think I will try a local hook with the 'pygrep' language
hi there, please read our #rules ๐
is this a self-promotional post?
is this a tool that fits in the scope of this channel for #tools-and-devops ?
i use pips and imports so i donโt have to copy paste raw package code
That's smart!
you should open a help channel. this doesn't seem relevant to this channel
is there a tool for jupyter note book to play a sound when running a code cell finishes
dont wanna waste my time having to keep checking on it
Have you seen this? https://stackoverflow.com/questions/17323336/automatically-play-sound-in-ipython-notebook
that looks like what im looking for at first glance. thanks!
have you tried adding the exception like it says?
disclaimer: I never use phusion; I'm just reading the error message
How to mount directories in docker-compose file ?
What does this mean in docker-compose.yml file : - ./static:/etc/nginx/static ??? ๐ค
Looks like it does something from ./static and applies that to /etc/nginx/static. Probably a copy or perhaps mounting a directory
yes, that does a bind mount by default
I'm running conda 4.12 on WSL2-Ubuntu20.4 and trying conda env export > environment.yml, which fails with InvalidVersionSpec: Invalid version '1.12.0<2': invalid character(s)
This seems to be a popular solution, but I don't have a nb_black at that location https://github.com/conda/conda/issues/9624#issuecomment-737107961
And this one provides a workaround for not having nb_black, but it's for windows ๐
https://github.com/conda/conda/issues/9624#issuecomment-777160270
Does this command work for you? Please ping me if you reply
hey can anyone help me on which Plugs should i use in neovim for python development
that question's better suited for #editors-ides I think
Check Lunarvim or Lunarvim docs for plugins
can someone help me with pyautogui
Any ideas on solving this error :
Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Tech stack :
web server (reverse proxy) : nginx , application : django , application server : gunicorn & Docker.
Does anyone here have a working docker setup that can run GUI applications? I'm on Ubuntu 22.04 and none of the SO answers/blog posts that seem to have worked in the past work for me. Can't get tkinter to find my X server even after stripping away all security layers.
Docker can run only CLI, TUI, and web UIs
the most close to GUI is obviously web UI at localhost somewhere available
It's been done in the past. You can share your display server socket with docker. If you don't believe me: https://www.youtube.com/watch?v=cMsIT2otEjA
In this video, we will see how to create a GUI app image and run it in a container using X display of host machine. It will not work on Windows.
Please email dotslashrun.sh@gmail.com, if you need training on docker.
wow. That's some dark magic
Hey! I'm currently using Pyautogui to automate a program. I'm running my script on a vps, but when I close the connection to my vps it stops working. I'm using .write(), .moveTo(), etc.
I've seen some post saying I should use some vnc stuff, but I didn't quite understand howto
Could you start your script in tmux?
Maybe, but what difference would it have?
tmux prevents your program from stopping when you close your VPS connection
now, if it's a gui program I'm not sure it'll work
is the "connection to your VPS" a web page, or some program you run at the command line, or what?
It will not stop when you disconnect
My script doesn't stop when I disconnect from my VPS, but Pyautogui doesn't work because there is no active connection or something like that.
I'm using the .rdp file I downloaded from Vultr, but I can also connect using a web page
ah gotcha
well ...
I don't know why your program stops when your RDP connection drops
Pywinauto's docs explains everything and a solution, I just don't understand the solution
https://pywinauto.readthedocs.io/en/latest/remote_execution.html
can anyone tell me if my understanding of docker is correct
so ive been trying to learn docker for a while now and I get the basics of docker and docker-compose
so if I containerized my app using docker and want to deploy these are generally the steps I would have to follow
- create a docker image that would contain my application
- push the docker image to some docker repository
- on my cloud service (digitalocean, aws, gc, whatever...) I would pull the docker image from wherever I pushed my docker image to and simply just start the docker container?
Yes
would I have to do any additoinal config relating to networking side?
also would it be better if I developed my application first and then dockerized the app or should I just dockerize the app from the start?
Depends on how exactly you deploy it I suppose. Like, if you deployed it just to a VPS then you would likely need to configure the firewall, among other things. But a VPS is typically not the most cost-efficient way to deploy containers anyway.
which process is better?
whats the best way to deploy a docker app? I should use something like AWS?
I see lots of people recommending DigitalOcean
Cloud providers typically have services that let you deploy an image directly
I just want to build a dead simple app, dockerize it and deploy it just to understand the basics
cloud providers you mean like AWS, Azure, GC etc...?
if I deployed to AWS, would I still need to configure firewall and additional other security measure?
Again, depends on how you deploy it. There are multiple ways to do it.
For example, AWS has Elastic Beanstalk which can be used to deploy containers. They also have AWS App Runner, which is a simplified version of Beanstalk. These approaches require less configuration than if you were to just use EC2.
is EC2 a VPS just like having DigitalOCean server?
Yes
I remember using AWS a while ago but it was confusing as hell
even to do something very basic
AWS is just an example. Other providers have similar offerings
I'm just more familiar with AWS so I used it as an example.
would I have to push my docker image to the AWS docker registry or can I push my docker image anywhere?
IIRC for AWS App Runner it only supported automated deployments for images on ECR, their container registry.
Not sure about Beanstalk. You'd have to check their docs.
ok no owrries. appreciate the info. much love
In any case I believe ECR is free if you push the image to the public repo. The cost is when you want it to be private.
Well, free as in up to a certain limit
if I push my docker image to ECR and make it public then I can host the dockker image for free on EC2?
nope
ECR and EC2 have separate billing
And if you use EC2 directly you don't necessarily need to use ECR
oh so you're saying its free to deploy my docker image to ECR for free if i make it public but I still have to pay for EC2?
oh right that makes sense
that means I can just deploy to dockerhub or wherrever and use EC2 separately?
Yes.
Beanstalk and App Runner have more integrations for automated deployment and at least for App Runner I am sure only ECR was supported.
My only concern with AWS is unexpected high costs... I read some horror stories where some users are racking hundreds of dollars unexpected bills
I suppose that can happen with any cloud provider.
like if you dont know what you're doing you can be hit with some gnarly usage fees
In AWS you can set alerts and limits for your billing
thats what scares me to be honest
I dont think DigitalOcean has that issue. at least I dont' thiink so
Well AWS only charges you for what you use, so if you unexpectedly use a lot, then you will be charged a lot.
It's not like a flat rate
well I wouldn't expect my app to receive high traffic but once you share it publicly to users, there will be someone who will try to exploit your application
which is what happened to someone
someone ran an infinite loop which was constantly hitting their api which racked up some hefty costs
That's why one should implement rate limits for their API
yea but for someone who might not be too experienced this could be a very costly mistake
๐ฌ
im trying to open my app at localhost:8000 but keep getting Unable to connect to localhost:8000
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f8ed60d8a39b prakhar1989/foodtrucks-web "python3 ./app.py" 6 seconds ago Up 4 seconds 5000/tcp, 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp foodtrucks
but should be the correct port? what am I doing wrong
my process memory scanner
there are a lot of values with "5" :P
ye
hey guys, wonder if anyone can help me maybe guiding me or providing me some inputs on this. My end goal is to implement a pipeline in Azure DevOps that executes usual python steps (code validation, tests, etc) and deploy or make the updated version available to be deployed to my server. As my environment is still based on servers, not containers, I am wondering how I can accomplish this.
Whatยดs still not clear to me is the actual "code deployment" to the server. Thatยดs what I have in my mind for the pipeline:
code quality validation (flake8, black, isort), tests, etc
once this all passes, it would either move the code to artifactory and then deployed to the server ( itยดs not container )
Should I have something on the server itself being triggered to download the latest version of the artifactory?
Appreciate any tips, articles or recommendations.
Thanks in advance
How about simply SSHing into the server and then using git to pull changes?
the issue in this case might be that my server is not in the cloud. I think my azure devops environment wouldnยดt be able to reach it. Should I have something on the server end looking for code updates and then trying to pull it from my repository or artifactory?
not sure if this is an unusual setup. This is a new environment to me, so tyring to see how I can make this a good solution considering devops good practices
Is the server connected to the internet? If so, then you can set it up to run sshd and connect to it over ssh via Azure Pipelines.
I will check it out. Iยดve heard ansible might be a good option for it?
Yes. In fact, Ansible ultimately operates using SSH. If you simply need to move some files then Ansible is overkill. But if you have a lot of other things you need to provision on the server, then check it out.
cool. I will check more into it and will post here what I was able to test. appreciate your time and answers @tawny temple
hey guys i have a lot of python files which writes to a log files
and these python files mostly talk to a elasticsearch db
i was wondering about what would be the best approach to monitoring these logs
like getting an email or sms when i get a error or debug log level
I checkout out the logstash
but grafana does sound like a good option as well
or maybe a self hosted sentry
any ideas please?
In general, I don't use logs for alerting if I can help it. This means:
- Metric/events for any quantifiable information such as golden metrics
- Logs/Traces for insight and debugging
Regardless, you can use some services like New Relic or Datadog, which have some free tiers and provide everything you need.
`print("1. Tool Help")
print("2. Tools List")
import keyboard
keyboard.on_press_key("1", lambda _: print("Test"), suppress=False)
while True:
pass`
I want that u only can type the "1" one time
to open the "Tool Help"
Hi, given project structure (name-spacing):
root/
sub1/
namespace/
__init__.py
pyproject.toml
pyproject.toml
Can I specify in the root/pyproject.toml somehow the local sub1/pyproject.toml as dependency?
(Couldn't find anywhere in documents. If someone can point out doc that says that, I'm all ears)
Additional question: Can I specify somehow sub*/pyproject.toml as dependency?
Essentially, what I want is to be able to do is pip install -e . in the root folder
Does anyone know how to cross compile a Python executable? I want to cross compile for aarch64-pi while on an amd64
โ server sudo docker-compose up
WARNING: The PWD variable is not set. Defaulting to a blank string.
Removing server_caddy_1
Recreating e18c48c71aed_server_caddy_1 ... error
ERROR: for e18c48c71aed_server_caddy_1 Cannot start service caddy: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/Caddyfile" to rootfs at "/etc/caddy/Caddyfile": mount /Caddyfile:/etc/caddy/Caddyfile (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for caddy Cannot start service caddy: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/Caddyfile" to rootfs at "/etc/caddy/Caddyfile": mount /Caddyfile:/etc/caddy/Caddyfile (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
version: "3.7"
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- $PWD/Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
external: true
caddy_config:
have you tried ./Caddyfile:/etc/caddy/Caddyfile?
because from the error message it seems like Docker Compose doesn't recognize $PWD
Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go.
im following the exact steps in the docs
if i remove the volumes in docker-compose file then everything works
what OS? what shell?
if i change $PWD to just a .
then the WARNING: The PWD variable is not set. Defaulting to a blank string. goes away
but container still doesnt start
im using linux
hmm. $PWD should be set automatically by the shell
does it still throw the same error?
echo $SHELL
im using zsh
hmm. straaange
/usr/bin/zsh
can you run
echo $PWD
this is like the 10th time im trying to learn docker
and its stuff like this that meakes me want to giveup
ok
$PWD => /home/rickyjw/odinproject/test-app/server
hmm
yes hmm
could you try
PWD=$(pwd) sudo docker-compose up
k one sec
same error
i dont think its a $PWD issue
cause even if i replace $PWD with a . its the same error
some it must be something with the way im creating the volumes
you know what im trying to say
with the ., what exact error do you get?
but like i said im just following the docs
the error that I pasted above
โ server PWD=$(pwd) sudo docker-compose up
[sudo] password for rickyjw:
Removing server_caddy_1
Recreating e18c48c71aed_server_caddy_1 ... error
ERROR: for e18c48c71aed_server_caddy_1 Cannot start service caddy: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/rickyjw/odinproject/test-app/server/Caddyfile" to rootfs at "/etc/caddy/Caddyfile": mount /home/rickyjw/odinproject/test-app/server/Caddyfile:/etc/caddy/Caddyfile (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for caddy Cannot start service caddy: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/rickyjw/odinproject/test-app/server/Caddyfile" to rootfs at "/etc/caddy/Caddyfile": mount /home/rickyjw/odinproject/test-app/server/Caddyfile:/etc/caddy/Caddyfile (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
What is Caddyfile?
Note
are you trying to mount a directory onto a file (or vice-versa)?
The mount paths must both be directories, not files.
they are directories
I can cd into it

so doesnt that mean its a directory?
what are the contents of Caddyfile?
I believe the error is stating that the destination (i.e. within the container) is not a directory.
- ./Caddyfile:/etc/caddy/Caddyfile
Caddyfile is supposed to be a file AFAIK
so how would I fix that line
could you answer this?
uhh
Sorry I misspoke. They can be files but they have to both be files. Or they have to both be directories.
For caddy I think it should be a file
yea
make Caddyfile a file
Resources for packaging and distributing Caddy. Contribute to caddyserver/dist development by creating an account on GitHub.
โ server ls -l
total 44
drwxr-xr-x. 1 rickyjw rickyjw 0 Jul 6 15:31 caddy_config
drwxr-xr-x. 1 root root 0 Jul 6 14:59 Caddyfile
-rw-r--r--. 1 rickyjw rickyjw 381 Jul 6 15:40 docker-compose.yml
-rw-r--r--. 1 rickyjw rickyjw 0 Jul 6 14:47 Dockerfile
-rw-r--r--. 1 rickyjw rickyjw 12 Jul 6 14:54 index.html
-rw-r--r--. 1 rickyjw rickyjw 268 Jul 5 17:52 index.js
drwxr-xr-x. 1 rickyjw rickyjw 1646 Jul 5 17:51 node_modules
-rw-r--r--. 1 rickyjw rickyjw 347 Jul 5 17:51 package.json
-rw-r--r--. 1 rickyjw rickyjw 27956 Jul 5 17:51 package-lock.json
drwxr-xr-x. 1 root root 0 Jul 6 14:59 site
First, do you need or want to override the default Caddyfile? The mount is optional. So if you don't need it, don't do it. If you do need it, then for -v $PWD/Caddyfile:/etc/caddy/Caddyfile, $PWD/Caddyfile should point to a file on the host.
basically, delete the Caddyfile directory and make a file named Caddyfile
@tawny temple I just want to follow the official caddy docs
to get something working
im not trying to do anything advanced here
Well on Dockerhub they imply that overriding the Caddyfile is optional. But I know nothing about Caddy.
@brazen forge ok give me a sec
well, mounting a custom Caddyfile would be the advanced thing to do here
ok so something interesting happened
so i deleted the Caddyfile folder and created a new Caddyfile file
and now I get this
โ server PWD=$(pwd) sudo docker-compose up
[sudo] password for rickyjw:
Removing server_caddy_1
Recreating e18c48c71aed_server_caddy_1 ... done
Attaching to server_caddy_1
caddy_1 | {"level":"info","ts":1657137329.5013137,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy_1 | run: adapting config using caddyfile: EOF
does that mean its working?
probably yea
but like Mark said, you probably don't need to mount a custom Caddyfile for basic usage
I kind of suspect it isn't working properly if you created a file without putting anything inside it
its not working
cause when i got to localhost, it gives me the page not found
normally it would bring up the default caddy page
you told me to create a Caddyfile?
That instruction was likely given in the context of you wanting to override the config. But as I suggested, you don't have to do it; it's an optional step.
i dont want to override anything
i jsut want to get it to work
if there is anyone in here that knows anything about docker please just send me a DM. thanks
dude im just followingg what i was being told
he said to delete the directory and to create a Caddyfile
thats what i did
i dont know if it overrides some other file
im obviously new to all of this
That was said to you before it became evident that you didn't want to override the config. It was (perhaps mistakenly) taken for granted that you understood that it was an optional step, so they were following with that assumption and just giving you instructions on how to correctly overwrite the Caddyfile. After that was given, I put into doubt whether you actually need to overwrite it, and evidently you don't; you didn't realise it was optional. It was a miscommunication but I hope that clears it up.
This option creates a bind-mount which overwrites the image's Caddyfile with the file on your host -v $PWD/Caddyfile:/etc/caddy/Caddyfile. Just remove that and it will revert to using the default Caddyfile in the image.
so i delete the Caddyfile?
On your host, you can delete it for the sake of tidiness but it doesn't matter really. The important part is that it's not mounted i.e. that the option I just mentioned is not used.
yea but i really want to just follow along with the docs says to do
version: "3.7"
services:
caddy:
image: caddy:<version>
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- $PWD/Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
external: true
caddy_config:
This is all the docs have to say on the matter in the "Basic Usage" section
To override the default Caddyfile, you can mount a new one at /etc/caddy/Caddyfile: ...
yea sure I can delete the volumes to make things work
but id like to understand also how to get it to work using volumes as well
That instruction is basically saying that if you have a reason to override the Caddyfile, here is how you do it. It's not saying you should unconditionally do it. In your case, you just want the basic set up so there's no reason to overwrite it. Just remove this line - $PWD/Caddyfile:/etc/caddy/Caddyfile.
If you did want to override it, then you basically had the mounting part figured out. The only problem was that your Caddyfile was empty. You'd have to read their instructions to know what to put inside. But as you said, you're not trying to do anything advanced so why make this harder for yourself?
ok let me make sure im understanding this corectly
i only specify that line if I plan to overwrite the original Caddyfile?
Correct
if not then I simply just dont include that line?
Correct
ok one other thing
i was following this tutorial
s
โค๏ธHost your applications and get ๐ฐ$100 credit (referral): https://m.do.co/c/1b74cb8c56f4
By watching this video you will learn how to deploy your Node.js application in minutes with Docker, docker-compose & Caddy Server with full HTTPS support.
GitHub Repository: https://github.com/TomDoesTech/caddy-nodejs-docker-tutorial
Article: https://to...
at 4:54 you can see that includes that - $PWD/Caddyfile:/etc/caddy/Caddyfile`
in his docker-compose file
is that because is overwriting the Caddyfile?
because late ron in the video he creates a Caddyfile
to do some reverse proxy stuff
Yeah, if you want to follow this tutorial you will end up overwriting the Caddyfile. So you'll want to keep that line.
And it also shows what to put inside the Caddyfile, so that solves the problem of having an empty one
ok makes sense now
the docs was confusing me but it was probably just my lack of knowledge
anyway thakns dude. i really appreciate your help
i dont know where the other dude went but thank you too
You're welcome
Oooh, I'll take a look at those
Thanks man
What is the best way to create a simple API with Python and publish it?
I already have the "base" for it
The base being this code: https://github.com/gtkacz/nba-headshot-api/blob/main/source_code/crawler.py, that will crawl the NBA.com website for every player in the league and store their ID, and therefore can generate an URL for the official headshot for every player using their ID
Can someone help me, I succesfully made a list generate a random text. But it only regenerates it when I start my script, I want it to do it every second or so. Does anyone know how I can get this?
These are some parts of my code:
random_rose = random.choice(random_rose_list)```
``` client.set_sounds({
"rose": random_rose,```
Has anyone was able in vscode to point as a python venv to be inside docker container? ๐ค (docker-compose)
UPD: Nevermind; Attached. It is possible and quite good. I think better than dealing with venv ;b
!kindling
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
Why would you?
just install everything into the docker container
oh, i mean to say, how to point for vscode to use python environment from docker container xD
so that vscode would apply syntax recognition from installed libraries and etc
nevermind, it all works
can someone pls code a youtube downloader in Py for me?
nope because 1) that's against YT's ToS 2) we don't just write some code for people here
okay but thx for the reply
also there is already youtube downloader https://youtube-dl.org/, it is already even having python integration
hail FOSS
Any tips on enforcing unspoken and perhaps somewhat weird style rules? I have a project of mine I want to make sure upholds a set of guidelines I try to follow, but I am not sure I can easily find a linter which does this.
Essentially, I am wondering what would be the easiest way to define very custom styling rules. Is making my own linter very difficult?
I'd expect so ๐
๐ To give an example... I want to ensure that the order of __all__ is the same as the definition of the names inside of it
that, by itself, should be easy; at least for function definitions
each function has some attribute that tells you the file and line number.
Right, this will only really be for functions and classes
I'd probably look at what it would entail to write a flake8/pylint plugin - I imagine it will do most of the work for you and you just hook in your checks at some point, but it's something I've never dabbled in
Considering that python gives away a lot of information in Dunder methods.
And that we need just throw away single scripts for one thing only
I would expect it should be easy to write your own single time linting scripts
Most of desired linting should be within the grasp of some regex
๐คฃ
is there some pure python line profiler?
Any python developer here knows how to use autodocs in sphinx?
https://stackoverflow.com/questions/72909680/how-to-use-autodoc-in-sphinx-to-show-docstrings
!pypi pprofile
I made docs in sphinx so yeh
anyone used pycharm community ver for Django? Is it good enough? Pycharm pro version has special support for Django. Is it worth going for it, in your experience?
Anyone familiar with Poetry? I've gone from poetry just working without manually activating environment's and being able to call one project from another to Poetry stropping all the time and having to delete, recreate and reinstall environments. I'd like to go back to seamless usage. Any tips?
hey any recommended advanced git tutorial?
Like for people who have comfortably clone/pull/commit/push/merge for years and now want to learn about more messy stuff like branching, rebase etc?
by branching, do you mean branching strategies?
also, have you been through the Pro Git book? https://git-scm.com/book/en/v2
Nope
This looks good
So basically I know stuff up to chapter 2
I'll start reading from chapter 3 i guess
thx
I think the more advanced stuff is in Ch. 7
go through https://learngitbranching.js.org/?locale=en_US interative tutorial and it gives visual understanding what happens under the hood
Fun and fast, and highly useful
It's neither "advanced" nor a tutorial, but I found https://eagain.net/articles/git-for-computer-scientists/ super useful at first
I am trying to run script `python3 src/scrappy/manage.py
https://github.com/darklab8/darklab_darkbot/blob/master/src/scrappy/manage.py
But i get this error
darklab_darkbot$ python3 src/scrappy/manage.py
Traceback (most recent call last):
File "/home/naa/repos/pet_projects/darklab_darkbot/src/scrappy/manage.py", line 1, in <module>
from .database import engine
ImportError: attempted relative import with no known parent package
how to how to resolve those importing problems? xD
file has code like
from .database import engine
from .players.models import Base
Base.metadata.create_all(bind=engine)
I hoped relative import will work
i altredy tried absolute importing too
how can I debug it even?
Well. I was able to solve it no idea how ๐ค
import database as database
import players.models as models
models.database.Base.metadata.create_all(bind=database.engine)
changing imports to this apperently solved issue
i wonder if i can use somehow imports starting from folder src
You might be able to run it as a module with the -m flag
I constantly forget to pull after I've pushed to one of my own repos with a github action that commits changes to the repo
Is there a tool that maybe reminds me to pull or pulls for me
It makes merge commits after I forget with isnt great
not that I know of
you can tell git to prohibit merge commits, though, iirc
so you'll get an error rather than a merge commit
That could work ill look into that
put this in ~/.gitconfig
[merge]
ff = only
I have written (in python!) a tool that fetches from all my repos more or less at once, and I run that a few times per day
nice and fast
when I try launching program from root level of folder src/scrappy with uvicorn main:app.py
i get error with relative import ImportError: attempted relative import with no known parent package
how to resolve it?
that's how stuff is there
so far as solution i was only able to launch the folder from parent one. But I wish to try launching it from the root of this scrappy folder
That does not seem appropriate
scrappy is a package since it has __init__.py so really it should be scrappy.main:app. And in main.py you should be doing from scrappy.players import views as player_views
It doesn't make sense to launch from within scrappy because it's a package
Also I don't think src should have __init__.py
And definitely not the root of your repository
You would have to launch with src as the cwd. But typically the intent behind using the "src" directory structure is that you plan to install your scrappy package. If you do install it, then you'd be able to run from the project root, or from anywhere really.
That's helpful
this explained everything
I just deleted __init__.py file from scrappy folder
and it started to work under different importing rules
which resolved everything correctly now
That is not the appropriate solution
scrappy should be a package
so it should have __init__.py
why? Scrappy is a microservice, it is not a package
it makes sense for it to be not a package
Scrappy is a fully fledged application
with its own dockerfile
launched as uvicorn main:app
It's a package in the sense of the Python import system not in the sense of publishing something to pypi
urgh. my intent for usage of src was to be having absolute imports along the project, which are less messy than this situation xD
Well I don't quite follow your intent or directory structure
I mean...
It looks strange to me
picture in architecture folder explains
it shows future plan of infrastructure
src is having 4 different microservice parts
which are going to be in the project
Usually all your Python files are within a package (i.e. a folder that has an __init__.py) and everything else like dockerfile, requirements.txt, etc are outside in the project root
This is quite standard regardless of whether it's a library or an application
erm. The confusion is because, technically each folder of src should be having its own repository
I simplified situation and made them all in one repo
each src folder, would be having (potentially) its own dockerfile
as they are all different apps to pack
therefore they have their own requirements/constraints files
I'm not familiar with all the files (like what manage.py and databases.py) are for, but I would structure it like this
src
scrappy
scrappy
alembic
bases
core
forum_records
players
__init__.py
main.py
tests
__init__.py
conftest.py
test_whatever.py
.dockerignore
alembic.ini
dockerfile
requirements.txt
If you have some python files that are more like scripts for development/deployment rather than a core part of the app then those can live in a "src/scrappy/scripts" or "src/scrappy/utils" directory
Oh yeah, I tried already to do that but encountered doubled initialization of ORM model that lead to error
Hopefully now since it is not a package, I will be able to structure it
I kind of half agree with your location of test files though
I'm not familiar with sqlalchemy so I don't know why that would happen for you
I think relevant test code should be in same sub package where it belongs
kind of nice that I encounter such problems. Good that I finally went to FastAPI
in Django i remained blissfully ignorant to such problems xD
everything worked out of the box
Yeah it generates a project structure for you. You could deviate from it but most stick to defaults