#tools-and-devops
1 messages Ā· Page 4 of 1
looks like you're still in conflict. how did you resolve the conflict?
i clicked accept incoming changes
and saved the conflict file
on your terminal, type git status
i think i pressed merge staged files or something like that afterwards
Try rebasing your changes onto the incoming ones
wait hang on
i opened github desktop
and it showed me an option to continue merge or skip
i pressed continue, and done
š
ok, glad that worked
At #GoogleCloudNext letās modernize, build, model, analyze, operate, secure, collaborate, and
innovateātogether. Join experts, October 11-13, to learn and grow together to meet tomorrow head on.
Register today, https://goo.gle/3xnxi2q
Today, meet tomorrow. Join me at Google Cloud Next ā22, happening October 11-13, 2022. Catch keynotes, live demos, and content from around the world from visionaries, thought leaders, developers, and Google experts at g.co/cloudnext
Then you can scramble to move everything when they shut it down after 2 years
Hello!
I am uploading files to github, but I can't add hidden files for some reason. I keep getting this message when I try to add a hidden file:
"This file is hidden."
Does that mean it is not possible to upload hidden files, or is there something I must do?
Be a man, show us output to Git CLI
git add .husky
Files and folders starting from dot are considered hidden in Linux though. But it does not matter for git
It worked!
I used these commands:
git remote set-url origin https://token@github.com/name/repo.git
git push -u origin main
How do I fix this problem?
Does running the commands they tell you to not work
No they do not work.
Especially the second one
do wsl --list to see what distros are registered in WSL, and use that info to properly unregister from it
I mean this is standard debugging steps, typically run whatever command line tool you're using with either -h or --help to see the available commands and go from there
Install the ubuntu one from the link they have there
or open the MS Store app and search for Ubuntu made by Canonical Group Limited
IF you already have that app then uninstall and reinstall it
I already have it then, I'll uninstall and reinstall it again
Nope. The same thing
@graceful light What do you think?
might be better to ask somewhere more involved with WSL than this Python server
But who? I cannot find such people...
why do certain tox testenv's recreate while certain don't?
Looking for testers to try this out
https://github.com/luxluth/changedetector
https://github.com/demberto/PyFLP/actions/runs/3164360724
Can anybody please tell me why the publish step was skipped?
Pleasantly surprised. Started to read book Expert Python Programming 4th edition
instead of stuff i expected, it started to explain me in Chapter 2, how to set dev environments with venv/poetry, and then jumped into vagrant, docker/docker-compose and explained througly its usages and code examples with python specificsš
Really nice of them doing that. Indeed book with modern approach.
Omg. it explained throughly all stuff how to use it for dev environment. All the different tricks... which i already use though
And even much more than that š Really useful
abc = [1,2,3]
print(123)
raise Exception("123")
$ python3 -m pdb -c continue test46.py
123
Traceback (most recent call last):
File "/usr/lib/python3.10/pdb.py", line 1726, in main
pdb._runscript(mainpyfile)
File "/usr/lib/python3.10/pdb.py", line 1586, in _runscript
self.run(statement)
File "/usr/lib/python3.10/bdb.py", line 597, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "/home/naa/repos/pet_projects/experiments/test46.py", line 4, in <module>
raise Exception("123")
Exception: 123
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/naa/repos/pet_projects/experiments/test46.py(4)<module>()
-> raise Exception("123")
(Pdb) abc
[1, 2, 3]
(Pdb)
(Pdb) list
1 abc = [1,2,3]
2 print(123)
3
4 -> raise Exception("123")
[EOF]
This alone trick is amazing.
getting into pdb debugger Right before Code Crash automatically! with capturing that environment before crash
Although the most i like this trick with watchmedo
watchmedo auto-restart --patterns "*.py" --recursive -- command [...] into docker-compose and we have hot reloaded program in container even if it did not have hot reloader
Hey does anyone have experience with salt/sls files and the configuration of it? idk if this is a good place to ask or if u can lead me to a place where i can ask this
plz tag me or dm me
good recommendation, i'll check it out!
salt as in the deployment/automation tool? this is the right channel
Yep the deployment/automation tool
oh oke then i will post my problem here thxc
install_network_packages:
cmd.run:
- name: |
subscription-manager register --username blank --password blank --auto-attach
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
pkg.installed:
- pkgs:
- epel-release
- yum-utils
- unzip
- curl
- wget
- bash-completion
- policycoreutils-python-utils
- mlocate
- bzip2
- httpd
- redis
- mariadb
- mariadb-server
- redis
- dhcp-server
/etc/dhcp/:
file.directory:
- user: dhcpd
- group: dhcpd
- recurse:
- user
- group
/etc/dhcp/dhcpd.conf:
file.managed:
- source:
- salt://dhcpd.conf
- user: root
- group: root
- mode: 644
/var/www/html/:
file.directory:
- user: apache
- group: apache
- recurse:
- user
- group
/etc/httpd/conf.d/nextcloud.conf:
file.managed:
- source:
- salt://nextcloud.conf
- user: root
- group: root
- mode: 644
# dhcpd:
# pkg.installed: []
# service.running:
# - enable: True
httpd:
pkg.installed: []
service.running:
- enable: True
- require:
- pkg: httpd
cmd.run:
- name: |
systemctl start httpd.service
systemctl enable httpd.service
firewall-cmd --add-service=http
firewall-cmd --add-service=http --permanent
mariadb:
pkg.installed: []
service.running:
- enable: True
- require:
- pkg: mariadb
cmd.run:
- name: |
mysql --silent -u root -e "create database NextCloud_db; grant all on NextCloud_db.* to 'test'@'localhost' identified by 'testpass'; FLUSH PRIVILEGES; "
php:
cmd.run:
- name: |
yum install -y php php-mysqlnd php-common php-json php-xml php-gd php-mbstring php-process php-pecl-zip php-pdo php-intl php-ldap
atm i have this salt script sry for the eyesore. my problem atm is with the dhcpd giving me an error that the service can not be found. I have tried it with dhcp-server, dhcpd.service and dhcp.service. I am running this script on my Rhel 8 linux vm. I mostly want to fix the turning on and displaying dhcp is installed. If you got the time an patience to give me any tips on the rest of the script i will appreciate it. I know its a mess with those cmd.runs i started 2 days ago.
thx for the time if anyone decides to read it š
also any advice on where to edit those scripts would be appreciated because copying from my vm is a pain since i mostly use nano as my editor
Indeed. Than more read, then more I am happy about it.
Book concentrated itself in first chapters at least how to increase productivity with python
I did not understand fully walrus usage cases, now I see
Besides obvious usage for regular expressions, I really liked trick of its usage for dictionaries
I really missed this stuff to declare better classmethod attributes. I needed to have global values before that like in example with dictionaries in order to have them dry. With walrus it will be all a bit nicer
Though in reality I wished to read that book for Parallelism chapter
It explained thoroughly and in examples difference and applications of Multithreading, multiprocessing and concurrency
Plus it will show how to integrate C++ into Python, which is cool too xD
- I have a problem with pyqt, actually with a timer there. My code includes timer (it's updating every 100 ml seconds) and a button. It's is one thread. However when I try to press the button , I have a delay and it freezes. A code which is connected to the button starts working in a second. As far i understand i need to make two threads i made test-class for this but i donāt understand how do this right.
- https://paste.pythondiscord.com/sulaqimari - My code
2.1. my "test-class"
def __init__(self, *args, **kwargs):
QThread.__init__(self, *args, **kwargs)```
3.I want everything to work quickly. No delays and no lags
Why doesn't this check https://stackoverflow.com/a/58478262/5541355 run as its supposed to in my workflow https://github.com/demberto/PyFLP/blob/master/.github/workflows/ci.yml ?
if you would have checked dates, u would have discovered 2019 date for the post
and that answer linked u official docs
syntax slightly changed itself to 2022 year, while still remained though
that's an event after publishing the release manually
ok wait hang on
i use tbump
on:
pull_request:
types:
- opened
jobs:
run_if:
if: startsWith(github.head_ref, 'releases/')
runs-on: ubuntu-latest
steps:
- run: echo "The head of this PR starts with 'releases/'"
official docs
latest syntax
and it does tagged annotation
oh you mean like this, this link is something else
they used head_ref instead of ref for some reason
u need to check which variables are available
won't head_ref work?
š¤·āāļø
being developer is about being more persistent than your computer errors xD
that's a good option too
Why don't u try Gitlab CI, it is better and way more modern ;b
i am tempted to do that too, but i tried it and really disgusted with 1 minutes of dependency resolvings to wait
i dont have many dependencies
using pip install -r requirements.txt with -c constraints.txt / requirements.dev.txt
i am tired of outsourcing everything to a different thing
top level deps rules to requirements.txt
pip freeze > constraints.txt
there's build to build wheels, twine to upload to PyPi, tbump to bump version, venv for virtual environment, pip to install stuff
i am sure i still forgot something
i use docker-compose instead of venv ;b
docker takes a lot of RAM
not really. u can use docker even in small ram PC 
what is a "small ram PC"
less than half of GB will be taken for your python application
postgresql is a bit fatter though
well, within 1 GB u can fit your whole dev env
IDK running VSCode + Chrome (2-3 tabs) + DIscord alone takes like 70% of my 8GB ram
anyway, that's why my dev machine has 16 GB RAM, first. Though i bought them for google chome xD
256 SSD + i5 CPU + No videocard except inbuilt one -> Kubuntu OS
docker takes 2GB
Chrome + Discord + Skype + several VSCode and yeah, your ram is gone
and ik it does, task manager is too lame to show it
U can....
try adding ram through Zram (compresses RAM usage twice through CPU usage for compression and storing back in RAM)
and Swap (works well if u have SSD)
I better get a working publish step first
its been literally a whole year i couldnt find out why for fucks sake it didn't run
should you squash and merge a feature branch that's a major rework or just leave it?
wdym just leave it?
Found good guide for ZRAM https://www.maketecheasier.com/configure-zram-ubuntu/
it describes how to configure it further
"Ubuntu"
no
i just can't get the fluidity on ubuntu
its just always that something is glitchy
never smooth
I like my faithful Kubuntu. All defaults are right, and everything is easy to install
i dont even touch anything else than vanilla ubuntu in linux distros
Ubuntu/Debian is often used for Docker images ;b Choice number one, besides Alpine images for Docker
Anyway, i did not complain about it even when had much weaker PC
My complain about docker is only in need to have extra 50-100 GB of a hard drive for quickly getting filled memory with cached containers and images
docker is a huge white elephant
often needing to go for docker system prune -a š
with probably no advantages for simple use cases
way lightweighter than any virtualization xD
using for any simple use case xD
i mean just do everything in a venv instead
it does not make sense to use venv instead
or use tox, its enough isolation
docker ensures... your system binaries are recorded too. It is just not always just pip packages u know, some binaries are needed often being installed too
and easy networking by container_name usage as hostnames to postgresql/redis and other stuff in other containers
those dependencies are basically recorded too at docker level, which postresql version u need to have it working
Docker is fully encompassing environment to record your whole stuff needed for web application
@shadow crow Btw, Vultr is more or less semi acceptable cloud provider. It can be paid in cryptocurrency
although cryptocurrency soon could be becoming more difficult option too
besides that i use DigitalOcean. It has option to be paid in advance by any acceptable visa card even from third party service. I just paid my stuff for year in advance
Docker does not take that much RAM. Linux VM on Windows on other hand takes RAM.
Can someone help me with pyqt? there #help-lemon PLS!!!!
that's kind of like saying *insert editor with extensions here* is an ide
that's true. There seems to also be an impression that not being an ide is bad. That can actually be great as it means it's lighter. All these fancy features in IDEs aren't free and will contribute to making it slower and heavier
Should a sdist include gitignores/github workflows ? How about requirements.txt ?
no and no imo. sdist should only include files required to build/install/use your package. specify dependencies in setup.py/setup.cfg/pyproject.toml or whatever file is appropriate for the pep 517 build backend that you use
maybe it could also include your test suite
Nice, thanks ! Setuptools already includes my tests/ by default.
I also include my package data in the MANIFEST.in instead of using package_data in pyproject.toml. I don't know if it's bad form
manifest file is fine, it's part of setuptools. it shouldn't include your tests by default, maybe it's because you are using find_packages() and your tests are a package
Oww, I include my workflow as well as the docs currently, am I doing it wrong?
docs maybe are fine since arguably that's part of the package
there's nothing strictly problematic about including the gh actions stuff, but what's the point? none of that is necessary to "distribute" the software
Docs make my probably 50kb tar.gz to a 1.2mb
It actually is a module, so I can run it as such and configure some things before I run the suite (it's a pygame project and needs some setup to run headless tests)
Yes you have a point, its just that check-manifest suggested to add it once
MANIFEST.in docs say that the manifest file itself is added by default
that's probably why. there is an argument to be made that you should include your tests in a distributed package, so that end users can run the tests to ensure that it has been installed correctly
i meant that using it to list package data files is fine
How does one use MANIFEST.in with poetry?
i don't know if that's possible, manifest.in is part of setuptools. it's likely that poetry doesn't support it
So does poetry not support sdist at all
I mean what's even the point of an sdist in 2022? Somebody can just clone the repo, why would anyone bother about a sdist
the repository could be deleted, someone could force push something, etc.
it should. but that isn't related to manifest.in specifically, you can generate the sdist manifest some other way
If the repository itself gets deleted then it was probably not meant for use anyways
And it won't definitely be maintained
then no point in a package
there are some projects with complicated dependencies where the git source repo is very different from the sdist
I agree for complicated projects sdist might make sense
i see it the other way, end users should not have to figure things out from a developer source repository
but there are plenty of situations when you can't download a compile binary package, so an sdist is the perfect choice
Why would end users need an sdist anyways
That's what bdist is for
likewise an sdist can be distributed alongside other packages in a central repository like pypi
packages with compiled extensions or other system/platform-specific files that need to be constructed
you aren't supposed to distribute a wheel that has unbuilt stuff in it, that completely defeats the purpose of a binary package
Why can't that be just left over to the end user to just clone the repo and do it themselves, add a BUILDING.md or something to show how its done
because as i said above, that isn't something you can distribute through a central independent package repository
or because your source repository might have extra files in it that you don't want to distribute, or because you don't even want to host a source repository, etc
Why would you need to redistribute something already hosted on Github or something to an another place? Seems like a chore maintaining both
That's definitely rare
it was certainly less rare at a relatively recent time in the past
Git has submodules and stuff so you can pretty much divide stuff like C extensions if they are too big
i also gave several other reasons why you might want such a thing
i work with a lot of packages that require compiled extensions and other such set up, i much prefer having access to an sdist instead of whatever manual inconsistent bullshit i would have to do otherwise
of course it's best to have a compiled binary package, but that's not always possible
Just use less C extensions ig
that's not really an option
what is devops TuT i still don't understand
also what is your complaint about sdist to begin with? i don't see much value in wondering why something exists, and then rejecting the various good reasons why the thing should exist
Its an excess for most pure python projects
"developer operations", it usually refers to things like deploying applications and running automated tests
With nicely maintained repos being a nice plus
nice
you are free to never upload one to pypi if you don't like them
other people will continue to use them for any of the valid reasons i gave
I think I will when I switch over to poetry
poetry for one is insanely better than setuptools
Everything is nicely added to pyproject.toml
could any1 help me with this question?
hatch is also a good choice
Setuptools supports project.toml and it actually follows a standard unlike Poetry.
Of course Poetry existed before the standard for metadata, but it doesn't seem like they plan on switching soon the last time I looked into it
my pre-commit is working differently on my ci?
isort runs just fine locally but changes things on gh actions
My best guess is it isn't using the same configuration options. What does your environment look like
I am working on vial a new project of mine which needs a lot of user input in order to run. I have a design kind of delima. I was thinking if it would be better to make the user experience using argparse or using a interactive prompt.
Heres a demo of the prompt below for example
https://imgur.com/a/D0NsBLY
Check out Click if your goal is to have a nice CLI based tool
As i said i was asking which one to use. Click is more of a shell like prompt based cli app
you can do prompts with click too
i had ubuntu, i instlled linux mint, dont know if it can be the reason but ubuntu and wsl stopped working, i uninstalled them and tried reinstalling, now this comes up
What plugins/configurations do you have on Pycharm to ensure all code is clean and upto standards?
from vscode experience i can say that it is not really concern of IDE to do that. Those are CLI separated tools inserted into CI pipeline
IDE can do only next things regarding this:
- Have
Blackformat files on save to ensure auto applied code formatting - Install plugins to see errors from your tests/linters/static type checkers inside IDE for quicker discovery and visual approach (mypy, pylint, pytest integrations and etc)
- Its in beta.
- What standard are you talking about
If its PEP621, Poetry already follows it
It was in beta in the past, but it isn't anymore. And yes, PEP 621. I still see issues open on Poetry regarding adding support and planning the implementation, so does it really already follow it?
But it does at least sound like Poetry wants to support 621 now
hi! i hope this is okay to post here. looking for feedback from python devs. im building a package manager for python and thinking about adding a feature for project types. right now it'd mainly just help with bootstrapping project structure, but i think it could have a lot of other great use cases later on. I'm wondering if devs would find this useful. Link in thread.
oh no threads š¦
here's the issue https://github.com/cnpryer/huak/issues/270
You can set up pre-commit to run through multiple checks before a commit can be sent, such as formatting with black, removing unused imports/dependencies with pycln --all, sorting imports with isort, etc.
And any time you want to run those tasks, even when not applying a commit, you can do it with pre-commit run
No, we donāt need another package manager
cute logo though
i don't think there's anything wrong with exploring the design space of package managers, but i also would not expect people to start using it
it also depends a lot on what exactly it is
if it's just another tool that wraps pip, then yeah forget it
if it's a completely new reimplementation from the ground up that doesn't use pip at all, you have my serious attention
not that pip is bad per se, but that's a design space that has not really been explored at all, and imo is a good opportunity for "disruption"
No, PSF needs to pull it's head out of it's ass and get extremely opinioned on this topic.
I would say for that matter, all modern python packaging tools kind of suck
Bad resolving or really long resolving time of deps
Also, packages manager are a problem because PyCharm. Run time has long been solved with Docker, though it sucks that Docker is pretty much mandatory with Python.
Development has been solved with VSCode and Remote Containers, everyone but PyCharm and VSCode can be ignored, though they won't take that well.
that's an alternate timeline
also good point about pycharm being a major obstacle to adopting any new tooling
I donāt blame PyCharm. Itās just Python sucks for this. Thatās on PSF.
i don't know, they seem a little slow about adopting community standards

the psf is also doing a pretty good job at picking up the pieces, i think. they have/had a lot of hard problems on their plate to solve. i think it's for the better that they're spending the effort to define standards, instead of ramming through one preferred solution and creating serious fragmentation.
imagine if there was no pep 517, and they just NIH'ed their own thing and declared poetry and flit and hatch as nonstandard and unsupported?
things would be 100x worse than they are
we have editable pep 517 installs, we have pip-compile
imo the psf should adopt pip-tools in the same way they adopted pipenv, and they should focus on making a stable python api for pip, and a stable web api for pypi that doesn't require downloading and unpacking wheels to get metadata. otherwise i think things are headed in a good direction.
and pretty fast i might add, given how relatively few people and man-hours are available to work full time on pypa-related efforts compared to the untold billions of compute-hours and dollars of revenue that makes use of python packaging tools
if you want to assert that this never should have been a problem in the first place, then yes i agree with you.
this is not the fault of any tooling, but instead the nature of Python packaging
tooling in this space is building on decades of architectural decisions that cannot be undone without inventing a parallel incompatible* world like conda
*semi-incompatible, certainly interoperable with work but not entirely seamless
To this day you still can't use pip search because the XMLRPC endpoints have been taken down due to some attack-like stuff going on in those endpoints
PSF needs people who are interested and qualified to fix that kind of issue
Poetry does not yet implement PEP 621, but we have a core maintainer interested in developing support. In general, it just hasn't been a high priority as we have plenty to work on and limited voulenteers.
Most people clamoring for PEP 621 so far seem to want to see it supported simply because "it's the standard" but it has substantial drawbacks/quality of life changes from Poetry's custom format (e.g. Poetry encourages use of markers heavily, and PEP 508 syntax is overwhelming with no editor support for new users), as well as being less expressive in general.
It definitely seems worth supporting given the main goal of 621, which was to allow different tools to introspect sdists without having to discover and run their build-system if the metadata they seek is defined declaratively (and likewise, to know which fields are declarative and interpreterable in an interoperable way, and which ones require executing the build system to return an interoperable answer).
However, outside hatch no one is really doing that yet, and it will take years and years to realize that benefit.
Basically there's not a direct benefit to users now, and it's very beneficial to tooling authors, but only in a future where everyone is using 621 as much as they can and it's had years to mature. It's very much on the road map for Poetry to support and an implementation is cooking, but it's a big change with little immediate benefit (and I predict a massive spike in support requests due to PEP 508 syntax being much less accessible to new users).
I'm seeing a lot of frustration and negativity here -- I would request that those who think that the PSF is obtuse, incompetent, or intentionally unresponsive review https://snarky.ca/the-social-contract-of-open-source/
Most of the people doing work on tooling are voulenteers, and the PSF does support development of the very difficult/critical features the community identifies in PyPA projects (+ warehouse, aka PyPI) with transparent, paid professional development sprints.
I'm not saying that the PSF is directly to blame - they themselves pointed out that a lot of issues with pip and some security vulnerabilities are things that they want addressed, but they can't find people who are interested in those things
There is simply a limited number of voulenteers, funding, bandwidth to plan sprints using that funding, and generally experts in this space, as Python packaging is a very specialized space with very different considerations from other ecosystems.
A lot of the intrigue is with the Python core and not so much the related tools used in relation to Python, which is a shame, but there isn't much they can do except try to drum up support or start doing paid bounties
Packaging in Python is something that has evolved over time and hindsight has benefited other ecosystems, but not Python itself obviously, as decisions 'made' (many were unplanned/more a codification of developing practices) decades ago are difficult to revisit now. Many are language-level constraints (e.g. the single sys.path).
More experts in this space are always needed -- if you're willing to put the effort in, and be persistent/dogged as you learn the problem space as well as working in large/stability-focused open source projects, basically any project in the packaging space would be happy to have more regular contributors.
I'm just going for it, Poetry is part of the problem along with PEP 621
these Domain Specific Tools have set in to fix what is clearly a language fault
Do you propose another breaking change along the lines of Python 3? It's very difficult to make such a transition as the last decade has taught us.
There are many things people would like to change about Python if it was started from scratch today, but most have accepted that gradual change is the only path forward for the ecosystem as they are not willing to risk another Python 2 -> Python 3 transition.
I don't want breaking change but just very opinioned. We are consolidating around pip, venv will be autocreated and PIP will start doing pyproject.toml
Keep in mind that Python is also in large part a specification now, with many implementations and gaining consensus among them is required for many changes -- CPython is not the only game in town.
Ah, I see. I think you might be a bit naive as to the problem space. If it was as simple as getting everyone under one roof to bless/force the one true way of doing things that would meet the needs of everyone, we wouldn't need the PyPA. We wouldn't have any use for Conda, even.
Isn't PyPA around packaging?
Also, full disclosure, I'm coming at this from SRE PoV. As SRE, Python as EcoSystem sucks unless it's inside docker. Full stop, don't hand me a Python whatever unless it's inside Docker.
These days the prominent alternate implementations are primarily CPython forks used for both prototyping of new performance-focused features (ala the way PyPy has been used in the past), plus PyPy and MicroPython. IronPython and Stackless Python are around but much less prominent.
and cython, jython
The issues you are discussing are considered packaging issues in the Python ecosystem.
Does Poetry not consume PyPI packages?
Cython is not a Python implementation -- it is a compiler that turns a restricted subset of Python into compiler IR, which is then turned into native code.
but they still are involved in discussions, as far as i can tell
That's fair, but at that point we need to count NumPy and SciPy š
I'd call it a 'critical extension' that primarily reasons about CPython instead, but maybe that's splitting hairs.
i mean, some bugs have been fixed that happen on cython
I am not sure what you mean -- pip, warehouse, and virtualenv are all packaging projects and not part of the core language.
I'm approaching it from PoV of SRE,
I got main.py, I need requests/FastAPI/SQLAcademy, it's using Python 3.8.latest. š° Cool, What do you got to run it?
Well, I got this Pyproject.toml š° Does PIP understand it?
No. š° Why not?
I'm stuck using this Poetry thing because multiple versions of Python and various libraries is nightmare for local developer. š° So I'm going to dockerize this, I have to install Poetry into my Docker container?
Sure, here is 4 line instructions š° Is it required for Runtime?
No. š° So multistage build process?
Yes. š° I hate you
I would ask you to please understand that negative comments do nothing but damage to the ecosystem as you demoralize the volunteers who work tirelessly to try and maintain and improve it. Nobody is selling you Python or a support contract.
Constructive criticism (especially from those without 'ecosystem blinders' on -- a fresh perspective) is always incredibly valuable and useful. However, you've expressed nothing but negativity and frankly used some rather demeaning language -- I suggest you take a step back and consider if your comments add any value, or if they only serve to put down those who you are asking to do more work for you.
I don't think anyone uses Python because the packaging story is great. We're still a fair league ahead of C, however.
If people simply wanted to use the best designed ecosystem/tooling, they would pick Rust and Cargo, assuming that everything else was fully equal.
Python is not a commercial project, but instead a community project developed by the employees of some large users (but mostly by volunteers).
wait, what? pip does understand pyproject.toml as long as the build backend is specified.
this is literally what pep 517 solves and has solved for like 2 years at least
could it be a little easier to find info on how to write a pep-517-compliant pyproject file? yes. but the problem is literally solved.
to further your point: pep 517 has existed since 2015, over 3 times longer
it's fucking amazing if you think about it. what other language's package manager lets you drop in one of like 6 arbitrary build tools that all implements a single unified interface agreed upon by the community (which now even supports editable installs as an optional extension), and does so in a completely isolated fashion from the rest of the system?
pip install -r pyproject.toml and away I go?
no? pip install .
root@1ee3cdf26006:/# pip --version
pip 22.0.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)```
PIP ships with Python Container, seems pretty much core to me
pip is included as a bootstrapping mechanism as it is the only tool that can perform 100% of installation/uninstallation duties of Python packages. It is not part of CPython, but an external project.
arguably cargo isn't part of rust even
got a demo pyproject.toml file, I shove it down PIP throat
Can we not use the borderline sexualized language please?
also i don't even get this complaint because unless you're packaging relatively niche scientific libraries that don't ship wheels (eg. cartopy) you can install a specific python version with pyenv or asdf-vm anyway and that's the only system-level dep you need
shit you don't even need zlib if you really don't want it
Wasn't my intent but sure.
You kind of need OpenSSL, but Python's build system will in large part handle that for you.
containerization has a lot of good things going for it w/ respect to sre and dev ops, sure
pip is core tool in same way npm is to node
er, how?
pip is core tool in same way npm is to node
that's probably true
As SRE, Python is ONLY language that cannot easily live outside Docker Container
why though? if a typical node app depended on several huge c++ frameworks like pytorch then you'd probably want to run node in a container too.
what do you mean sre? site reliability enginerring is all that comes up for me in a google search
š
I use Python outside a container every day -- the tooling is quite different, but much more intuitive and easier than say, Perl. I suspect you are looking at the Python ecosystem with Javascript blinders, which is very common these days.
because it's inside the OSes and I cannot rely on venv to properly handle it, it's docker or bust with Python in same way Node isn't.
i've also worked with several real world applications that were deployed outside of containers, installed the old fashioned way on linux servers w/ nginx, and it worked fine
Poetry itself (and related tools like Pipenv and PDM) were all developed with lessons learned from the Javascript and Ruby ecosystems, translated to Python primitives (with different decisions made along the way).
Actually, my day job is .Net/Java(Kotlin) and Node (mostly frontend with Node)
same, i use python out of a container all of the time for development, aside from deployments and testing deployments
can you give an example of why not? i haven't seen a lot of issues like this except with building seriously complicated stuff
are you aware of pyenv?
(also for context, $DAYJOB is maintenance of Docker/Moby -- I work with Linux container runtimes and kernel code daily)
some Python from Data people, it's actually pretty rare, DevOps teams write more Python then anyone else
the biggest mistakes IMO are:
- using system python to make venvs
- running pip install without activating a venv
using pyenv solves those issues, however
based on the code i've seen devops people write... i wouldn't want to run any of it outside of a container š
Almost all other languages, C aside take extremely opinion approach to Package handling. Python for whatever reason hasn't caught on their need to be extremely opinioned. I don't care if they suck Poetry, Conda or someone in PSF but they need to and fast.
they're specifically saying that venv isn't sufficient, which i don't get. using the system python is i guess not great but it won't cause things to explode either
you're not answering the question, you're just complaining about something else
Also if you dislike virtual environments (not sure why as they are basically a 'container' for Python), maybe helping with the effort to get https://peps.python.org/pep-0582/ out of draft is productive?
pep 582 is pretty cool, been meaning to try pdm
won't cause things to explode either
nope. I can say from experience i have thoroughly busted system python before
Seems like you have a lot of opinions and energy -- educating yourself on the specifics of the problem space and putting those opinions to use are the best way to help move Python forward.
This has LONG been needed. It's shocking that someone in Core Team isn't trying to throw this over the finish line.
with a venv?
i forgot to activate it and ran pip install . š
oh lol, that's another story
Python operates on the basis of consensus. The role of the SC is to break ties and be the higher power, not to proscribe changes from the top down.
export PIP_REQUIRE_VIRTUALENV=1 in your shell config file and never worry again.
ah, i didn't know you meant making venvs with system python
where has this been all of my life
I saw some of the email traffic on PEP 582, I was pretty dishearten and decided to walk away.
something like ruby gems or npm would have been pretty cool, where pip install into __pypackages__ by default. i suppose that's what pdm does. but backward compatibility and all.
This really should be default
If you were disheartened, imagine what it's like to be the developer of one of the tools trying very hard to improve the very thing you are complaining about, and being told "I hate you" š
this is one of those, Starting in Python 3.13/3.14 PIP REQUIRE VIRTUALENV will be opt out, not opt in
For every person who thinks the breaking change should be made, there will be two more who complain that their workflow was broken and their companies business is put in jeopardy. There is a transition plan to make this the default, but it was hard to get consensus on even a multi-year timeline.
One of the things you have to understand about pip is that it has to be all things to all people -- this significantly constraints the amount of experimentation or development of new features that they can do.
Likewise, anything they introduced has to be supported for multiple years at a bare minimum, even if they decide it was a mistake and move to deprecate it.
aren't there parts of setuptools which have been deprecated for years?
distutils has been discouraged most of my life.
We're still trying to kill it.
I don't know how old you are so that doesn't help
Let me rephrase: we've been trying to get people to migrate to setuptools for 15 years (half my life).
I don't hate you, your like really Cool Windows Utility to fix something terrible about Windows. I'm equally impressed and disappointed in Windows that you are needed.
and I spend a fair amount of time in Windows
Like Powershell, I'm so glad you exist and WHY ISN'T THIS DEFAULT ALREADY!
Powershell is the default in Windows 10 with developer mode on, or Windows 11.
I know
Anyway, I think I'm going to step away from this conversation. I'd be interested to discuss actionable ways the packaging ecosystem can improve as a whole without breaking it for existing users, but vague "Python sucks and you suck" is not very useful. We know it could be a lot better, and a lot of very smart people are spending their free time working on it, instead of pursing their other hobbies, spending time with their loved ones, or doing something that might make them money.
Also, PyEnv is YET ANOTHER THING that must be installed when working with Python. In theory, you hope your language ships with all those tools already.
PIP does VENV by default, PEP 582 is bulldozed over the finish line, PIP freeze outputs in Pyproject.toml
sorry you got pulled into this. i'll politely repeat my suggestions that pip having a stable python api, pypi having a stable web api, and pypa/psf making pip-compile semi-official would all go a long way.
pypi really does need that stable web api, instead of removing features from the json api...
it's the same reason as on windows. backward compatibility.
I think the current plan surrounding pip is to rewrite the functionality in a compatible but greenfield way, and then test swapping out the current bespoke pip internals to validate it.
Basically, 'modular' pip -- this was the approach taken with build and what is happening with installer.
i like that. i've occasionally wondered if something like pip wouldn't be a bad candidate for a complete rewrite.
it's a lot of individual loosely-connected pieces of functionality anyway
pip has to maintain so much compatibility that rewriting it is likely much more effort than evolutionary development.
oh i meant in the sense of what you described, rewriting big chunks of the internals and swapping them out
Ah, that makes more sense.
starting from nothing but import argparse i agree is not a good strategy
It's also worth noting that there is a concerted effort in pip to define to scope/goals of the project these days, instead of blinding accepting whatever seems useful. The pip-audit folks were let down by this, and it's also why pip-compile will never be built in as things stand.
pip-audit folks were let down by this
what happened?
Certainly it wouldn't hurt to promote pip-compile more over use of pip freeze which has so many compromises it's really only useful for tightly controlled environments (e.g. a single container base image).
i think that's also a good strategy. however pip-audit and pip-compile imo do belong at least somewhat officially under the pypa umbrella, like pipx and pipenv
if only in name only, and if only for community visibility and to encourage adoption
If you want to follow 'mainstream' Python ecosystem developments without having to watch GitHub, DPO, MLs, etc, you should subscribe to LWN. They have excellent Linux ecosystem journalism: https://lwn.net/Articles/904197/
A tool to discover known security vulnerabilities in the Python packages installed on
a system or required by a project, called pip-audit, was recently
discussed on the Python discussion
forum. The developers of pip-audit raised
the idea of adding the functionality directly into the pip package installer, rather than
keeping it as a separately ...
lmao you know me by now :^)
i should subscribe to lwn too, i keep putting it off
It's incredibly valuable and a very inexpensive way to support a pillar of the Linux community.
I'm surprised pip-tools isn't under the PyPA umbrella, but I can only imagine that Pradyung or someone else has reached out at some point, and for one reason or another the project has decided not to make the leap.
pip-audit is a PyPA project, mere months after presentation to the general Python-using public: https://github.com/pypa/pip-audit
tsk tsk. I've subscribed for years
2016 apparently
I always wonder about these auditing tools being well maintained.
In recent years the PyPA has adopted the 'big tent' strategy (as opposed to the prior approach of curating/'blessing' projects) to try to make everyone interested in packaging talk to each other + ensure continuity for widely-adopted projects if the current maintainers can no longer contribute. The PyPA is also an 'authority' now and strives to generate consensus and strongly encourage interoperability of tooling.
didn't realize!
one issue with the "big tent" is the possibility of newbie confusion
my complaint
e.g. people thinking pipenv is "official" and the right tool for all projects, when in reality it's kind of a weird tool that doesn't actually fit a lot of use cases
Indeed, it's one reason Poetry hasn't joined the "big tent" so far š
like pip-compile and pipenv are sorta similar, but they aren't at all like setuptools/poetry/flit/hatch
Pipenv is something of a special case -- if I remember the timeline right it's what started the big tent. It was adopted out of necessity was it was widely used and needed new maintainers, but also precipitated the modern iteration of the PyPA in the fallout.
And PDM! š
right
i was wondering about pipenv, i remember being very surprised to see it under the pypa github account
Without revisiting old wounds, it's in large part because of the same reasons that lead to requests becoming a psf project.
I used to love pipenv but they wouldn't let you specify a min/max supported versions of the Python runtime
Admittedly moved on to poetry and loving it so far
!pep 508
I switched to asdf because its Homebrew distro has the new Python versions faster than Homebrew/pyenv.
asdf + Poetry is the reliable happy path that I've found
asdf directly uses pyenv under the hood (for the Python plugin)
it doesn't manage the versions itself
Makes sense
So using Pyright on strict mode w/ Python 3.10 I think I discovered a little-known feature: https://dogweather.dev/2022/10/03/i-discovered-that-python-now-can-do-true-match-exhaustiveness-checking/
well, strictly speaking it's not python that does it, it's pyright š
right, i think that's the distinction that you should be making. you have discovered a very useful feature of pyright!
Hello community,
I've been learning ansible lately and I got a question.
How do I add my generated ssh key (~/.ssh/id_rsa.pub) to my servers authorized_keys file using ansible?
Adding my keys manually for setting up servers for ansible seems tedious, so is there any way to do this using ansible?
An example play-book would be nice if you already have one, thanks š
You mean the key that Ansible will use to connect with? Obviously not possible. I think you could use a tool like teraform for that.
If you already have a key for Ansible and just need to add user keys, that's simple, I googled it for you: https://www.cyberciti.biz/faq/how-to-upload-ssh-public-key-to-as-authorized_key-using-ansible/
I'm talking about the key that we generate on our machine and add the .pub key to our servers we ssh into..
Once added, we can ssh into our servers without password.
Having this set-up allows us to run ansible from our machine to our servers without a password.
This is the same thing right?
Also, if there's any specific term we use for it then let me know
Right, AFAIK Ansible needs that key to be in place before it can access your server, so I'm pretty sure you need Teraform or another similar tool to put that in place
i see, what is this though?
As the link says, if Ansible already has a root key, it can add the user keys
So maybe that is actually what you need, I'm not sure
I'm logging in as root, so yeah, i would need to add my key to authorized_keys file of the root
Hello All, I'm wondering if correct here in this study question or no?
This is not the right place to ask, nor should you be asking for people to answer your homework for you
not homework
I'm using ansible to clone a private repo to my server.
It works fine when I run the playbook on my VPS but when I try to run it on a machine I have hosted locally, it says I don't have access to the repo.
Same script, same state servers (new) with only one difference, that one is rented on cloud and one is private server exposed on local network.
What could be the issue?
presumably the VPS has a credential for the repo host, and your local machine doesn't
if the clone is going over ssh, for example, perhaps the VPS has an ssh private key in ~/.ssh/id_rsa
or perhaps ansible is picking up a private key, and forwarding it to the VPS, but for some reason isn't doing that when you run it locally
hmm, I found the issue:
I wasn't accepting new hostkey.
Adding this fixed it
accept_newhostkey: yes
!rule 5 <@&831776746206265384> scraping web sites is against their terms of service usually. Not really welcome
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
@copper roost Either way that's not the right channel for that, but do be mindful of a website's ToS, many don't allow scraping
what is the correct way to check if a tag name starts with a v in github actions?
for triggering the workflow? just v*
No with use in an if
Is there a way to automatically keep track of the current git revision in a python package installed over a git repository?
My goal is to keep track of git revisions in my log files for future reference
It's not clear to me what you are trying to accomplish and how it differs fromgit log
I was just wondering if there's a way to automatically get access to the git commit hash from within the package when installing it using e.g. pip install git+http://example.com/repo.git
maybe it's buried somewhere in some pip cache location. but in general i think the answer is "no" unless the author embeds it in the code somehow.
After doing some more research I found this which fits my needs: https://github.com/pypa/setuptools_scm
what's the current recommendation for setting up a pip-installable project?
pyproject.toml? manually-created? poetry? something-else?
would this be directly installable via pip install ., etc?
IMO poetry with a pyproject.toml config
any packager really
there's multiple because they cater to different usages
(in no particular order)
- poetry
- hatch
- setuptools
- pdm
- pip-tools
- flit
What's the difference between a, b, rc, pre, post and dev versions?
a,b is alpha beta but if they exist why do dev and pre exist
Dev is pre-alpha essentially
I believe pre release is just another name for a release candidate, but I'm not sure.
Release candidate is where no new features are added, only existing bugs are fixed
https://xkcd.com/927/ moment
guess i'll take a look at each of them later
What you're describing is a beta. But since rc follows the beta, that also holds true for the rc.
what do you guys use to show directory trees as text?
something like this but more automated
tree
Something to note is that poetry doesn't yet officially support native extensions - so if you have e.g. c extensions in your package you'll likely run into issues
hey can anyone look @ my question in broccoli pls
How do you feel about the contributing workflow where you split contributions into proposal and implementation issues ? Does it also make sense for bug reports ? (e.g. you first create a bug report issue, then a bugfix implementation issue + PRs)
It depends on the scope of the issue. It probably would not make sense for bugs in most cases - the discussion on implementation can happen in the bug report issue.
My thinking was, because we were planning to have enforced standardized issue templates (no blank issues)
That if you *had *to go through the process of filling out the proposal/bugreport part of the form anyway, why not make it so proposals and implementations were two different templates, so you don't have to fill out the same stuff twice ...
Then you just have to create one issue if you are only posting a bug report / feature request without implementation, and the "second issue" of implementation gets filled out by whoever takes up the task/bug report (even if that other person is you) (also meaning multiple implementations by different people can point to the same proposal/bugreport).
So implementation issues "cancel out" proposal issues in a way
Too convoluted ?
thanks for the response by the way
Can you have the proposal template include optional fields for implementation details?
o yes, we use github templates, they support that. you're saying we should just merge them into one template ?
Not exactly. I think the proposal template should include optional implementation fields. This will cover the case when the author wants to propose something and already has an implementation in mind - they can just do it all in one issue. If they don't know implementation details, the fields are optional so they can leave them blank.
A separate template should still exist for implementation details only, which will be used when a proposal was created with the optional fields left blank.
As a maintainer, you want people creating issues, so it's important to reduce friction in that process. I think it's better to avoid the situation where the same person would have to create two issues back to back.
That's a good point ! Would it be a good idea to (in order to not clutter the issue form) create a secondary mixed proposal-implementation form instead ? We currently have 4 templates: bug-report, bug-fix, feature-proposal, feature-implementation. Then we would just add bug-report-fix and feature-proposal-implementation
It's difficult to say. On one hand, the template can become cluttered. On the other, the contributor is presented with too many choices for templates and becomes confused. I'm leaning towards having less templates, but it just depends on how bad the clutter would be.
The same can be said for the clutter - they see to many fields and become confused.
You should also focus on keeping the amount of fields to the absolute necessities.
That being said, I'm not entirely sold on having separate issues for implementations generally. It starts to make sense if a complex and/or vague issue needs to be broken down into smaller pieces. However, there isn't much risk to trying it - it's fairly easy to switch to another system if this doesn't work out.
Ty, will keep in mind. I think we'll try the split route initially. To be honest the entire idea stemmed out of the fact that a separation between a problem and an implementation is logical and symmetric/beautiful. Might be one of those adhd things after all.
If you can find other projects/teams using a similar system successfuly, that would help validate the idea
But I don't recall encountering something like that before
how to fix this
./prepare_fonts.sh: ./tools/unpack_font.py: /usr/bin/python3: bad interpreter: No such file or directory
is this python problem, or something else?
python can't find your interpreter
how to fix it, i'm on windows 10
Ig this is msys2 or wsl?
wls, here the script...
original script from github
when i run it, its print...
/usr/bin/python3 : The term '/usr/bin/python3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
- /usr/bin/python3 "c:\Project OmegaT\tools\unpack_font.py"
-
+ CategoryInfo : ObjectNotFound: (/usr/bin/python3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
its not a problem in the script
why are you showing me the script 
you need to install python in wsl
Is anyone on line that can answer some Docker related questions with launching a DRF and psql database?
Recommending to read the guide : https://www.pythondiscord.com/pages/guides/pydis-guides/asking-good-questions/#q-can-i-ask-a-question
and answer is yes
A guide for how to ask good questions in our community.
is anyone remembering a way for pytest to read current active marks? 
i think i misunderstood your request before. i thought you were asking about other people's packages that you installed with pip as with pip install git+...
ah I guess I was a bit unclear about that but I was talking about my own package
I have this condition in my GA workflow
on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:
yet it ran, (even without a tag) https://github.com/demberto/PyFLP/actions/runs/3215579314/jobs/5256776862
GA is so fucking annoying
I am thinking off pulling out the entire publish action itself
It's because it treats branches and tags as an OR rather than an AND i.e. if it matches the branch or the tag, it will trigger.
How do I make it an AND?
I don't think it is possible
š¦
You could have a step in the workflow that checks the branch and fails if it isn't master. Of course it'd be better for the workflow to not trigger at all, but I don't see any other options.
And it's probably unlikely that you'd push a tag to a non-master branch anyway
Yea ig
They really should document this behaviour more clearly
And also why does startsWith(github.ref_name, 'v') not work?
Yea they should space it out more tbh, like poetry docs, its too cluttered
What triggers did you have set up for the workflow when you were trying to do that?
Same as above?
No
Earlier my test and publish steps were in a single workflow
And the publish had a needs: test with the if condition
But it never got executed since I merged it
Well I'm asking because I believe that the value of ref_name depends on what triggered the workflow. So if you had a branch filter, and it matched it, then the ref_name would be the name of the branch, even if it also happened to have a tag.
That's my theory
Now I separated once again and don't care if publish action runs without waiting for tests
You could confirm that by checking the value of github.ref_type
Doesn't ref_name always return the tag name? If one was pushed?
No. It says
The short ref name of the branch or tag that triggered the workflow run.
What is a ref name
I even did startsWith with github.ref and refs/tags/v but it didn't work either
Basically it's a branch name or tag name and points to specific commit.
If you want more details see https://git-scm.com/book/en/v2/Git-Internals-Git-References
Well, like I said, I believe it depends on what triggered the workflow.
Right, so you had a branch filter for the workflow trigger, which means ref_type would be "branch" and ref_name would be the name of the branch.
ref_name would be a tag name if ref_type was "tag" which would happen if the workflow was triggered due to a tag filter
If you want to trigger on a branch but still get the tag, I'm sure there's some git command you could do to get the current tag you're on.
How do you make a workflow in a different file wait for a first workflow to finish?
I used some wait-on action, it started failing, but I read somewhere that workflow_call or something can do it
Yeah, workflow_call or workflow_run depending on what exactly you want
Is it okay to ask docker related question in this channel?
@real wedge
Recommending to read the guide : https://www.pythondiscord.com/pages/guides/pydis-guides/asking-good-questions/#q-can-i-ask-a-question
and answer is yes
A guide for how to ask good questions in our community.
ah my bad!, and thank you.
Will running a container with multiple processes instead of running multiple containers with individual process, decrease the load on CPU? I want to run a container with django + mysql + nginx + rabbitmq processes instead of separate container for each to save the extra overhead each container causes. Is this the right way to think about docker?
Hey, I consider to learn about using dvc (https://dvc.org/), but before that I have some questions regarding dvc with cloud:
- Does dvc saves all the different versions of the dataset?
- Does dvc support all data files format (csv, feather)?
- Can the usage of dvc with the could, lead to extra costs from the cloud provider, since it increase the frequency of the communication with the cloud?
- Can the usage of dvc with the could, lead to extra costs from the cloud provider, since it saves many versions of the data files?
- Is there a limitation or disadvantages of the tool when working with large data files(100GB+)?
I never heard of dvc before now, but I am deeply skeptical of any version-control system that isn't git. I've seen too many come and go.
ah it sounds something like git with the "large-files" extension or whatever it's called.
If I were you, I'd read https://en.wikipedia.org/wiki/Data_Version_Control, then I'd get some sort of trial subscription, and just play with it
"DVC is a free and open-source, ..."
Maybe I wasn't clear enough, but I talked about the cloud service provider
if it saves many versions of the data, then instead of using 1GB for example, it might use 10GB for the same file
I will check that thanks
I am just guessing, but git itself is extraordinarily efficient; I'd imagine dvc is also
iirc, the entire history of GNU Emacs -- 30 years or more -- takes up roughly twice the space as just the current snapshot
A 2.0.0 version will be greater than any alpha release of the same version like 2.0.0a4 right?
A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes. Pre-release versions have a lower precedence than the associated normal version. A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92, 1.0.0-x-y-z.ā.
Yes
Hey @heavy knot!
It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
https://github.com/GeneraBlack/PrittyLog
i made a little but pritty logging tool for python, hope you guys like it and finde it usefull
!pypi happy
!pypi searchor
is there github magic that lets me steal all the pull requests/issues from the abandoned repo I forked into mine
can probably enumerate them with the api. but there might be some murky copyright issues there.
laws scary
Nobody will sue you for an abandoned repo of all things in this world š
That's not the point though
Is there any way to include parts of a markdown file in rst? There's m2r2 and myst_parser both of them don't have such option
Will running a container with multiple processes instead of running multiple containers with individual process, decrease the load on CPU? I want to run a container with django + mysql + nginx + rabbitmq processes instead of separate container for each to save the extra overhead each container causes. Is this the right way to think about docker?
That kind of defeats the purpose of Docker and while I would expect it to save you some RAM I think the CPU savings would probably be negligible.
This is exactly opposite of being right
there are already made containers for mysql, nginx, rabbitmq and etc. few code lines at most to add it to your composition as side cars
one containers is supposed to be one process, exceptions are allowed but very rarely
containers reuse so much of your OS, that overhead from having multiple of them is almost nothing in comparison to introduced additional complexity of having everything inside one container. Plus logging / networking whatever other stuff made for containers assumes using multi container setups
the thing about "containers reuse your os" is important. at least on linux, standards-compliant containers are basically not isolated at all from the rest of the system, and are (as far as i understand) basically just groups of processes under a particular kind of process namespace
it's like putting up a curtain in a big room and pretending it's a separate room
AHH this opened my eyes, Thank you!!
I was suspecting it might be something similar, thank you
Is there a difference in the configuration settings when you dockerize a normal django project or a DRF backend?
Not really. I don't remember anything different about it 
oh, actually i remembered
Normal project requires served static assets via nginx, and DRF backend is usually not requiring that stuff xD so it is easier to dockerize DRF xD
U would still wish reversed nginx in front at some point though, for the sake of getting Nginx level server side caching for some of your endpoints, or some other shenanigans
speaking about static assets, my backend does store a handful of pictures to be used on the front end. Do i need to set up anything specific to be able to render those photos? For example, I have a series of icons stored as a FileField in my model. In development they are being stored in a media folder, but its unclear to me if django will pull from that same media file in production.
https://docs.djangoproject.com/en/4.1/howto/deployment/
https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
-> https://docs.djangoproject.com/en/4.1/howto/static-files/deployment/
-> On the server, run collectstatic to copy all the static files into STATIC_ROOT
if u deploy django with unchangable static assets
just collectstatic django-admin command will gather statc assets from different folders into one folder which will be needed served by nginx
if u have dynamic static assets (changable not just by git commits), consider using S3 buckets stuff (at least if u wish to keep your backend application stateless)
ok, so lets say I add another 5 icons to the database later in production, would that be considered a dynamic static asset?
are u going to store image itself in database field? which database type? expected image size?
stored as a filefield.
Yes. https://docs.djangoproject.com/en/4.1/ref/models/fields/
https://docs.djangoproject.com/en/4.1/ref/files/storage/#django.core.files.storage.FileSystemStorage
if u will care to read how it works under the hood by default
it will upload file onto your filesystem, while only having link/path stored in database
image files are served much faster by Filesystems/S3 Buckets
Within Django philosophy, u are expected eventually to write your own implementation of Storage class that will implement S3 Bucket Storage for you (or finding already ready library for that)
and just replacing for FileField Storage engine from FilesystemStorage to S3Storage
initially of course it is enough to use Filesystem, S3 bucket is just for... greater scaling things and keeping app stateless
depends on requirements of a project
Technically nothing really prevents u from storing it right in database (without filesystem). It is just bad performance advice. But it is great in terms of better data integrity.
it depends on project requirements
ok, I will read through the docs to get a better understanding of file storage for production. This project isnt terribly big, its just a portfolio website for myself and i wanted to have a django backend to easily change data in the future.
Then all those optimizations aren't really relevant to your case.
just make sure preferably to serve files in the way that it is possible attaching client side caching headers for served contents (FileSystem Storage is fine for that when used together with nginx)
that's all you probably wish to have
for the sake of minimizing costs, u will not want to use separate S3 Cloud objects
Im not familiar with caching header. What does that mean to cache client side headers for served contents?
is that at setting i need to configure and if so, where? in the django project or with nginx?
with nginx
alternative guide https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
@rapid sparrow Do you ever get this error with installing psycopg2 to the docker image?
may be u don't need it in the first place š install just pip package psycopg2-binary
provide all available details, i suspect i know what u a talking about but i wish to be sure.
how is it related to python?
is it graphical only tool abstracting interactions with databases? What database u a currently using as driver/under the hood?
urgh. This is not a FOSS. https://www.youtube.com/watch?v=ufNpooHyDD8
MLP FiM My Little Pony Friendship is Magic
S04E07 S04 E07 Season 4 Episode 07 Bats!
Pinkie Pie - Run for your lives!
well that's why i said "hope i'm in correct channel."
sorry
Ergh... pure technically your question is related to data structures and other basics
even if it is not related to python, people still can answer that
#algos-and-data-structs can potentially answer u
i am just not wishing to answer this question, because it involves implementation details of a proprietary solution which has no value for my specialization
not wishing to dig into this direction
because any question answering also asks from person to google around a bit / reading docs
especially for tool which is not known for them (such proprietary tool will have no one familiar here highly likely, or may be it will)
anyway: here your generic answer not attached to your implementation details of your tool
Integer can fit only... integer values. within limited range, usually up to 2,000,000,000 for int32 format
float is having limit which numbers it can fit too, and it really worngly stores... nubmers like 10.00000, they are getting miss-corrupted on intention to stuff like 99.999995646345646
double same, but higher limit due to keeping up to 53 digits after dot
deciamal... i haven't learnt implementation details deeply of this one, except knowing that despite working as double, it can correctly estimate itself into integer values
basically for your tool in the end is suggested all its unique data types being equvalient to.. all generic data value types, and same rules should be applied to your app specific value types as to those values
besides that values can be kept as a string(array) of character, as a binary and date time
so, person chose 38 precisioned decimal probably because he wished value acting both like integer and as number with digits after dot. He chose to sacrifice space efficiency for universla easy to use default
and 38 is just a limit of precision for decimal u have mentioned in your docs
in order to understand fully what is going on, it could help u to learn how generic programming data types works (we had subject in university for that, not remembering name)
The real shit begins from the point that your tool uses those generic values and somehow translates as ORM into multiple different database types / and even file/documents as storages.
To be honest, at this point it is impossible to say further what is specifically going on without learning first how those data types work for the chosen specific driver/storage type
Thanks!
Hi im new here, was wondering if anyone could possibly help me with chrome dev protocols
Hi new here! I recommend reading guide how to ask good questions: https://pythondiscord.com/pages/resources/guides/asking-good-questions/
A guide for how to ask good questions in our community.
thanks
How can i remove my account/remove my name and email from the authors list in pyproject.toml
[tool.poetry]
name = "..."
version = "..."
description = ""
authors = ["Guido"]
Everytime poetry creates the file it's annoying as it always uses a name and email and i always have to replace it
sorry for not being clear enough!
poetry picks it from git's config
https://github.com/python-poetry/poetry/blob/master/src/poetry/console/commands/init.py#L127-L131
src/poetry/console/commands/init.py lines 127 to 131
if not author and vcs_config.get("user.name"):
author = vcs_config["user.name"]
author_email = vcs_config.get("user.email")
if author_email:
author += f" <{author_email}>"```
where can i change it exactly?
you can answer n when asked
pardon?
when doing poetry init
it'll ask you to enter/config author
hmm, new doesn't have that question
So to change it i have to change what exactly?
/shrug instead of using poetry new, use poetry init
-_-
@ebon minnow try changing git global config?
i dont even have git
š
Yes you do
wut
Why are you even using poetry when you don't have git 
dont ask questions š³
I mean source control is first, then comes packaging
It might be possible that your ide installed git
Through an extension or something
I looked at github desktop and i think that was the issue
Yea github desktop does configure git
Git config is located somewhere in C:/Users/your_user_name
is there something i'm missing about sphinx toctree?
i have this file:
bigcorp (namespace)
==============
.. py:module:: bigcorp
Packages:
.. toctree::
:maxdepth: 1
bigcorp.datascience_api_service
bigcorp.geo_utils
bigcorp.testing
where each of the files referenced in the toctree directive contain their own toctrees with the same :maxdepth:, and so on recursively until you hit a file that has no toctree.
when i compile this to html, the resulting top-level document has the entire tree represented in bullet points, but i was only expecting bullet points for the items listed explicitly in the toctree.
what's going on here?
sphinx has been driving me up a wall today
oh dear, problem solved... i had one toctree without :maxdepth: set
Also if you are documenting the entire module in a single toctree you can use recursive or glob
are you talking about recursive with toctree? i didn't know it had that option, it seems inherently recursive
I think that's for automodule
oh, yeah. in my case these were generated with sphinx-apidoc, but that's also an interesting idea
I am considering using a Jinja template for autodoc
i've been torn between "hand crafting" the layout and generating automatically. the former might be a little nicer for readers, but more burden on contributors (who in my case are not likely to be very proficient sphinx users)
that's what apidoc does!
As your point above, apidoc is too less control
A template lets you decide how its gonna look without you having to mention class names explicitly
If your non-reference docs are good, I think 2nd is a better option. It kinda makes you write better docstrings as well.
By non-reference docs I mean like user guides, handbooks, getting started and all that stuff
apidoc now lets you use a custom template for each generated page, that's what i did
Yea that's the template i am talking about
I was confused between apidoc and autodoc
I wish VScode came with rST support for docstring previews
it doesn't? that's annoying
i feel like a lot of newer python tools try to avoid rst as much as possible
All docstrings look like shit in rST which is like a standard but somehow vsocde supports a custom variant of markdown
i bet it's mkdoc or something similar
Which doesn't support italics but supports stuff like tables and images
weird
Mkdocs is good for non apidoc stuffs
it doesn't currently support docstrings at all right?
which is why pydantic and fastapi literally don't have reference docs (which is incredibly annoying)
Even I felt mkdocs is good but for auto generated reference docs sphinx is hands down the best
one of my coworkers recently tried pdoc and got good results
Its does but its not very good
!pypi mkdocstrings
fastapi also doesn't handle rst properly. it puts docstrings directly into the openapi schema, which means that your openapi docs are littered with ugly rst markup.
Rst isn't as ugly really
After using it for like continuously a month I realised its not meant for too much decoration but its good for long texts with various types of content
There's next to no IDE support for complete rST syntax. VScode has like one extension which is quite buggy and complaining. Pycharm strips out all formatting
it's ugly if you are looking at the raw markup inside what should be a rendered document!
i think part of the problem is that rendering rst requires actually rendering rst with the full engine, because of the custom roles and directives
is there a tool like setuptools-scm that produces "calver" versions like 2022.10.14+git{hash}?
ideally i'd also be able to embed that version in the source code itself so i could emit it in my log messages
actually... i think i might just write a script to do this
So I'm trying to use the pyperf library to measure some personal benchmark stuff, and I'm running into an annoying issue
doing: ```py
runner = pyperf.Runner()
using some example code from their docs
t = runner.bench_command("python_startup", [sys.executable, "-c", "pass"])
pprint.pprint(dir(t))
But it seems like `t` is being yielded into, where the `pprint` call is being made in a loop as results are coming in. I would've thought that `pyperf` would block until it finished, but it feels like it's calling the entire program multiple times
How should I be using `pyperf` to run measure the runtime of a function so that I can later get the mean & median runtimes and write that to a CSV?
are you sure that's what's happening? can you show your whole module?
i assume you are following this example from the docs https://pyperf.readthedocs.io/en/latest/examples.html#bench-command-method
#!/usr/bin/env python3
import sys
import pyperf
runner = pyperf.Runner()
t = runner.bench_command('python_startup', [sys.executable, '-c', 'pass'])
import pprint
pprint.pprint(t)
Yep that's the guide I'm following, just ordered a little differently```py
import sys
import pyperf
from pprint import pprint
runner = pyperf.Runner()
t = runner.bench_command('python_startup', [sys.executable, '-c', 'pass'])
pprint(t)
And the output:```
<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.<Benchmark 'python_startup' with 1 runs>
.
python_startup: Mean +- std dev: 24.5 ms +- 0.4 ms
<Benchmark 'python_startup' with 21 runs>
If I do something like putting print("this is a test") before the pprint statement, I get this:```
this is a test
<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
this is a test
.<Benchmark 'python_startup' with 1 runs>
.
python_startup: Mean +- std dev: 24.5 ms +- 0.4 ms
<Benchmark 'python_startup' with 21 runs>
interesting. i wonder if that's somehow related to using sys.executable
try using a different command as a sanity check, like /bin/true or whatever
also try guarding all that code behind if __name__ == '__main__'
i don't know how any of that would matter, but try it
it's hard to say what sort of silliness this library does internally, so maybe guarding behind if-name-main is useful
Just tried it, as well as moving the actual pyperf code into it's own function that gets called from the if-name-main block, but no change
Also strangely enough, I can't use pyperf outside of a virtualenv like poetry's shell
it does seem oddly recursive in a way that it shouldn't be
i would consider just filing a bug report at that point
the examples in the docs shouldn't be so fragile
So looking further into the documentation, pyperf runs the function that you want to benchmark on different CPU cores. This is bypassing the if-name-main block that should prevent the non-main processes/threads to run that block by using subprocess.Popen to call python -m pyperf command your_app_here
My hacky temporary solution is like this:```py
import sys
import pyperf
from pprint import pprint
processes = 20
loops = 5
runner = pyperf.Runner(processes=processes, loops=loops)
t = runner.bench_command('python_startup', [sys.executable, '-c', 'pass'])
if len(t.get_runs()) == processes:
print(t.mean())
t.dump("output.json", compact=False, replace=True)
Hey , i want to deploy a 2 websites built with django.Both the apps are dockerized using nginx as the web server , gunicorn as the application server.I want to deploy both the websites on the same virtual machine. Any solutions ?
excuse me
how did u make dockerization of nginx, gunicorn of them?
are they separated containers or u smashed into one?
separate containers
thanks gods )
so u have docker-compose yaml as result at the moment?
yep , its working on a digitalocean instance with a custom domain .But how would i do the same with 2 websites .
oh, so your real question is, how to have two domains leading to same VPS server, and rendering different web sites from same 80:443 ports then?
Exactly , There are a lot of tutorials online for static websites using nginx.But what i have is 2 dyanamic websites running on docker containers.
well, i'll explain you options but in the mean time
i highly recommend reading. Then u would not have such questions. Especially carefully reading Docker Networking section
Lets start with simple explanation what u have at the moment
When u deploy Docker-compose, u have written in it different containers/services
they are able to communicate with each other by service names if u noticed
u can address db as db
that's because Docker-compose boilerplates docker networking stuff and created bridge network, which unites those containers
they can communicate freely within this bridge network with each other
and u expose with ports only the desired stuff outside of this network to host/and outside server
Ideally u do next thing.
version: '3.8'
networks:
default:
name: darkbot
u can add to your docker-composes that they share same bridge network
make sure for each one to have unique service names
in order to avoid problems
U raise your docker-compose with first application
and u raise your docker-compose with second application
they both don't expose their ports. but they will be joined into same network
They just output their website through Nginx
which service their Static content + forwards requests to Gunicorn
now within this darkbot bridge network you can access your websites as
http://nginx_1/ and http://nginx_2
u can create third docker-compose containing just Nginx working as reverse proxy (it will be launched within same bridge network named darkbot)
it will listen in one section to requests from domain_a.com and redirect them to nginx_1
another sectoin will be listening to domain_b.com and redirected to nginx_2
technically u can avoid this stuff.... by simplifying the process...
just write one docker-compose that has containers for your both applications
and add declared third service nginx that redirects incoming domain requests to different nginx containers of your services
and obviously expose with ports only this third nginx
https://www.digitalocean.com/community/questions/nginx-with-a-domain-and-subdomain with one error person wrote almost correctly nginx config to redirect requests based on different incoming domains here
Something like that u wish to have as your third nginx
Hi guys, First timer configuring nginx here, hope you can help me. I have my domain, letās say www.example.com . And I have my app, which I would like to ruā¦
just instead ofproxy_pass http://localhost:3000; you will be directing to proxy_pass http://application_nginx_container_name:3000;
mm third nginx will be working purely as reverse proxy
static assets will be regulated by nginx of specific application
so for third nginx u need to declare just proxy_pass http://your_application_container_name:3000; and e.t.c. config twice for different domains
for additional reading, recommending free Nginx cookbook https://www.nginx.com/resources/library/complete-nginx-cookbook/
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
what happens if you put all the code under if-name-main?
if you have the option to use docker compose, it makes multi-container setups a lot easier
No change
Definitely due to pyperf running the program in a new process with subprocess.Popen and keeping track internally
yeah but i fail to see why that would run your code
I need to look at their code more when I get home tomorrow
hi can anyone help me
https://pythondiscord.com/pages/resources/guides/asking-good-questions/ recommending to read linked guide there, how to ask good questions
A guide for how to ask good questions in our community.
Python Expert Programming is definitely amazing book
in chapter 11 i finally got all answers how to deploy/develop uploadable packages with all details
before that i knew only crude approach how to deploy to pypi only in some way
and this book finally explained what the hell is magical Meta stuff xD
plus explained event driven stuff finally
plus finally got details regarding different strategies of parallism. It explained how it works under the hood
multiple other topics i wished to know but never knew where to learn. It explained everything i wished to know. in 13 different chapters
quite fresh book, just from 2020 or 2021 year. Well, at least its 4th edition
Must have to read for python devs i think xD
Is anybody here using Poetry and Docker? I tried my first little project with poetry, because I like the clean way to sort dev packages from other packages. But from my feeling and by looking at my Dockerfile, it is way more stuff than simply use requirements.txt and pip. Do I miss a big opportunity from Poetry here?
Yes, installing with Poetry will be more steps if only because the base image likely won't have Poetry itself, so you have to install it first
Poetry's benefits are mostly useful during development (venv management, generating a lockfile from pins, isolating dev deps)
you can use Poetry in your Dockerfile, but a common approach is to export production dependencies into a requirements.txt (Poetry has the export command for this), and installing from it in your Dockerfile, using just pip itself
the export step can happen for example in your deployment pipeline before the build step
ok thanks. didn't look up this export command š
I ended up posting an issue on the pyperf Github repo and funnily enough the first suggestion the original developer gave was to use the if-name-main block, which we already went through š
Hoping they're able to replicate the issue and figure out what's going on
is their a way to install chrome from code, and not in terminal?
On Ubuntu server
What do u mean?
digitalocean provides a simple "one click web app"
The downside is, that you can't acces root user.
So I can install anything using the console
But forget it, I am trying to deploy on a droplet now..
Anyone done that before?
Trying to host my flask-webapp
Digital Ocean web app provides deploying from Dockerfile. It is possible to fit Chrome into dockerfile
Well... For regular VPS, there are more options, but I still recommend using docker... Just adding docker compose for happiness
And I placed already Chrome into docker before
+Selenium web driver
This is a very solid book... and there have been a number of changes since 2020 that you might want to consider: Moby has changed the licensing a bit AND there are some solid alternatives to Docker host and to the docker CLI.
pythonspeed.com blog has good resources specific to Docker, and they explain why many of the practices that make docker good for statically compiled languages are not optimal for Python.
Nothing beats Poulton š His Docker Deep Dive and The Kubernetes Book are amazing.
hey,
I did do this in docker now,
and I am trying to start my selenium script like this, so that it runs once a day at specific time.
( __init__.py )
from apscheduler.schedulers.background import BackgroundScheduler
sched = BackgroundScheduler(daemon = True)
sched.start()
@sched.scheduled_job(trigger = 'cron', minute = 15, hour = 20)
def get_values():
get_values_script.main()
But it doesent seems to start.
Wen I just run the app ( without docker ) it works fine
Timezone setting maybe? Any hints in the container log?
Hey, yeah was timezone ...
But I run into another error now.
"selenium.common.exceptions.webdriverExcepion: Message: Unknown error: Chrome failed to start: excited abnormally" ..
What image are you using for your container and does it have the required dependencies? I'd use the official Selenium one if you can. https://github.com/SeleniumHQ/docker-selenium
!warn 244658476909854720 our server is *not an ad board. Don't post unsolicited advertisements
:incoming_envelope: :ok_hand: applied warning to @orchid cloak.
Any idea to pack a python multi process application as an exe
pyinstaller
Does anyone understand how this image is built : https://hub.docker.com/r/jwilder/nginx-proxy
Here's the github. https://github.com/nginx-proxy/nginx-proxy
It's mostly templates
It also uses this. https://github.com/nginx-proxy/docker-gen
the actual logic is written in go
Is there any other way to deploy multiple containerized apps on a single virtual machine.
kubernetes will do it
for something more lightweight, podman and docker both support services.
podman actually supports (basic) kubernetes apps
How do I deploy a dockerized flask app on digitalocean ?
has anyone ever done that or can link me some resources ?
Also what is the yaml file for? š
docker compose?
I get this error wen trying to create an app with my container from docker hub
"error validating app spec field "services.name": services.name in body should match '^[a-z][a-z0-9-]{0,30}[a-z0-9]$'Close"
idk, I don't actually use do
not 1 app with multiple containers , multiple websites with multiple containers.
Anyone else like formatting the self keyword to be very close to background color so your eye can skip over it easier?
but self isn't a keyword
it's just a variable that has special meaning by convention
but why do you want to skip over it
there's a pretty big diff btwn an instance variable and a regular local
There's also nothing stopping you from reassigning self. Your linters won't like it, but they can't force you not to.
you can call it _ if you prefer
as stated above, you would need to be careful to only apply that format inside an instance method definition
I want to keep self. Especially when looking at other peoples code
But it was actually not that hard to create a formatting rule in vs code so it's just a bit les contrasty than other code
I'm just saying I like this look.
One really easy way to do this is with Nginx Proxy Manager. Run that in its own container, use its web GUI to point different URLs to different containers based on port number
i keep getting this error when i run my docker container off this image SyntaxError: Non-UTF-8 code starting with '\xac' in file /bin/sh on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details ```DOCKER
to build the image run "docker build . --tag website"
FROM python:3.10
LABEL MAINTAINER="HRLO77" LICENSE="MIT"
COPY ./* website/
WORKDIR /website/
ENTRYPOINT [ "python" ]
EXPOSE 8080
RUN python -m pip install -r requirements.txt
CMD ['main.py', 'True']
to run a container on this image, run "docker run <IMAGE_ID>" you can get the IMAGE_ID by running "docker images"``` it doesn't matter what the CMD is, always the same error
Does it work outside the docker container?
wait i found it
ENTRYPOINT [ "python" ] it runs all commands in the docker container with python for some reason
even when not the CMD
fucking dam
What's in main.py?
It really looks like you're trying to read /bin/sh as a text file
import os
import socket
import uvicorn
import sys
if sys.argv[1] == 'True':
os.system(f"echo {socket.gethostbyname(socket.gethostname())} is my ip address")
uvicorn.run('backend:app', host=socket.gethostbyname(socket.gethostname()), port=8080)
else:
uvicorn.run('backend:app')```
why are you os.system('echo')?
i could use 0.0.0.0 right
if your networking is configured correctly, the container's name will be dns pointed to its ip
and yes, use 0.0.0.0 to bind to all interfaces
your container ip is pretty much useless outside of docker-world
I'd also recommend using uvicorn backend:app with HOST and PORT set as environment variables.
I also suggest using gunicorn in prod. ```dockerfile
ENV PORT=8080
RUN [ "gunicorn", "backend:app", "-k", "uvicorn.workers.UvicornWorker" ]
The port really doesn't matter in docker anyway.
Here's a dockerfile I use for a fastapi project with poetry. ```docker
FROM python:3.9-slim AS python-base
ENV PYTHONUNBUFFERED=1
PYTHONDONTWRITEBYTECODE=1
# pip
PIP_INDEX_URL=https://python.repo.eng.netapp.com/simple
PIP_NO_CACHE_DIR=no
PIP_DISABLE_PIP_VERSION_CHECK=on
PIP_ROOT_USER_ACTION=ignore
PIP_DEFAULT_TIMEOUT=100
# poetry
POETRY_VERSION=1.2.0
POETRY_NO_INTERACTION=1
FROM python-base AS builder-base
RUN pip install poetry==${POETRY_VERSION}
WORKDIR /app
COPY poetry.lock pyproject.toml ./
RUN poetry export -o requirements.txt
FROM python-base as production
WORKDIR /app
COPY --from=builder-base /app/requirements.txt .
RUN pip install -r requirements.txt
COPY ice/ ice/
ENV ENV=production
CMD gunicorn -k uvicorn.workers.UvicornWorker ice:app
Had the following issue today, solution is probably dumb š„² https://github.com/orgs/community/discussions/36831
https://stackoverflow.com/questions/57946173/github-actions-run-step-on-specific-os one googling request Github Actions check if linux
it is from 2019 though, u will need preferably checking latest available official documentation to confirm it
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions official docs show matrix.os at least
that doesnt work tho
i need includes
do echo "${{runner.os}}"
check what is available as variables, try different ones
why can't u use ==, why do u need includes
because theres 2 targets that include linux
i mean i could do == || == but stuborn
ok idk what issue is it works now thank\
if i want to run multiple linters in github actions, is it better to run each linter in a separate "job"? it seems a little wasteful to clone the repo into an action runner 4 separate times just to run 4 separate linters, but it would be nice to have them all separated in the PR
https://paste.pythondiscord.com/nexideqava.yml this is what i have right now, but i have no idea if this is considered good practice
U would wish as separate jobs in order to see all errors at one run of all tests, instead of needing to rerun and discovering new errors unseen in previous run
Surely, performance wise worse... But u know that is a regular problem with better testing
that makes sense
also these are free actions so i'm not paying for the compute š
plus they will run in parallel
it just seems like a big waste of cpu cycles in general
there's no way to re-use the "clone" and "install python deps" stages for multiple jobs?
They will, but they will add slight overhead from more containers launch xD
U can preserve deps thorough cache syntax of CI
But usually modern pipelines just build docker image at first stage in order to freeze competly what we test between all CI stages, staging and prod envs.
When using public GA, then resort to pushing image to public docker hub, and repulling for each stage.
When using self hosted runner it can become optional if runner uses same docker Daemon for all jobs
Docker strategy ensures we test exactly same thing
Deps change
Tested image just retagged under new tag into docker registry
in this case our image is private and can't be pushed to a public repo, and it's being built in a completely different CI platform (teamcity). so even if i did try to rig up all the ECR authentication stuff, there's no guarantee that the teamcity build finishes before the GH action runs
Then use private docker registry
AWS ECR
I don't get it, why your GH/teamcity cooperation can be breaking?
wdym? teamcity is running on jetbrains servers and GH is running on microsoft servers, there's no way (that i know of) to establish a dependency between them
i also might not be allowed to connect GH to ECR for security reasons
completely separate platform and all
Well, GH Actions does support continuing to run even if a step fails I believe,
I don't like the overhead separate jobs adds to the time (waiting to acquire a new agent, etc) but I agree that organisationally and semantically separate jobs are nicer.
Can't u build in Team city, doing everything in one CI?
(Also it should be having rest API ability for integrations for external connections)
it would be nice, but that's the domain of devops and there's a lot more "administrative" overhead involved
i'm basically using GHA as a place to prototype things
The cache is scoped per-job I believe. If you want to share it across jobs, then you can use artefacts. However, I don't think those are easy to access outside of the same workflow run, if that is something you need.
https://teamcity-support.jetbrains.com/hc/en-us/articles/360021065280-What-is-a-self-hosted-build-agent-
Dogshit. Paid self hosted runner connections!!!!!!!!
GA and gitlab gives it for free
lol different pricing structure
Plus teamcity is not yaml. Horrible
teamcity is so much better than codefresh at least, which i used at my last job
i fucking hated codefresh
in this case i just want to re-use the same git checkout & pip install for the handful of different linters i want to run (flakeheaven, isort check, black check, hadolint, shellcheck)
don't need pip install for hadolint or shellcheck
i guess i'll just live with having a lot of repeated work in the runners
this won't be a "high volume" repo with lots of commits
I want solution independent from proprietary CI clouds and being lightweight š
Gitlab is almost nice in this regard since it is fully open source including cloud itself
I want ability to run jobs locally
Like Tekton almost gives
Wishing to write my own CI tool to satisfy all desires. Writing instrument to define purely workflows runable locally. Let s have some other CI tool handling GUI and runners
I see. I don't think actions/cache will work for that, but I haven't actually tried. Artefacts will work, but it does take some time to download/upload them - possibly not even saving you much time there.
I think this is ultimately a UI problem on GH's end. In your case, it doesn't seem like you need separate jobs for anything other than to be able to see all the failures separately easily.
I think this is ultimately a UI problem on GH's end. In your case, it doesn't seem like you need separate jobs for anything other than to be able to see all the failures separately easily.
yes, precisely
GUI plus syntax. If allowing to fail steps, steps will be possible to complete with errors and to pass pipeline run
Isn't there another way that won't cause the workflow to pass?
Maybe it's if: success() || failure()
Yeah it's a pain in the ass to test workflows
https://github.com/community/community/discussions/15452
Looks like in desired state
Tool for local workflows will also make pipeline code mostly independent from specific CI provider
Hating problems to migrate
Wishing to own my CI code
Tekton already allows it
Remotely executed local launched pipelines in k8s cluster
Never heard of Tekton but I will check it out
It can be inserted into any CI tool
i've been using act for this
What is that? Is there a full name?
Never mind, found it a bit further down in search results https://github.com/nektos/act
https://github.com/nektos/act it's a github actions emulator
yeah, that
emulator runner thing
That sounds very useful. Will definitely try it out next time I make significant CI changes.
So it just emulates GH actions?
Is there a risk of differences in the official implementation and this emulation?
So it just emulates GH actions?
yep!
Is there a risk of differences in the official implementation and this emulation?
yep! but hopefully none that i'll run into, in my simple case.
It's not a big worry anyway. I'd still test it in a PR before I merge any CI changes. It just reduces the churn of pushing commits and waiting for GH Actions
and having a pile of broken/failed workflow runs in the history cluttering things up
@tawny temple https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
Yeah, this is what I was talking about regarding caching. I believe that cache is going to be scoped to the job (but you can access the cache in subsequent workflow runs as long as its in the same job).
It uses https://github.com/actions/cache underneath. I can't find clear documentation on whether it can be used across jobs, but IIRC last time I looked into that I had no success.
Still, you would only pay an upfront cost once and it would be cached, so not a big deal if installation gets repeated in different jobs.
Well, until your dependencies change
the docs arent really clear about that, there seems to be the ability to use a "shared tool cache"
it seems like (at least in theory) you should be able to mount a network filesystem in a self-hosted runner and cache everything in one place
i just want to avoid putting more pressure on pypi!
Ah yeah, if you have a self hosted runner you can have control over that. But that's beyond anything I've ever attempted
If you do figure something out, do share the results
i don't think i will pursue this just to run linters š
Fair enough, I probably wouldn't either
anyone used fastapi with graphql?
Hello, in docker is it possible to make a developement environment for me for such a situation I needed to change my device so dont need to reinstall every thing?
Like can I do a docker image that contains depndencies, vscode, files, folders without even downliading it? Just running it ftom docker
My favourite way to go
Thanks!
I want to share... AWESOME development tools available for you if u are working in Linux at least
Soft links = like regular anchors to folders, they imitate path resolution to different folder which is enough for Terraform like tool, but Git will see only one file instead of folder
Hard Links = Making fully fledged mirrored files. U can even delete original. As long as any hard link is left for file, it is still existing. Real time sync. Because link links to memory in hard drive. Disadvantage: For file only.
Mount --bind = The best option when u deal with multiple projects/microservices, u can bind entire projects for real time syncronization (almost same like pip install -e, installing some local package in editing mode essentially) (Very useful to have multiple projects combined into one project temporally) (Even git can see those mounted folders fully, so u can commit those files as long as they are mounted)
===
Essentially mount --bind is the most useful option greatly enchancing dev environment. Mind blowing at the level of using Docker-compose stuff for dev env
Soft links are fine for some usage cases too though
Windows has symlinks as well. And whatever else NTFS supports
Hello everyone, I'm trying to run prometheus and grafana using ansible with docker compose.
Dockerfile
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/
docker-compose.yml
services:
prometheus:
build: .
image: prometheus-custom
user: root
ports:
- 9090:9090
networks:
- monitoring-net
.
.
But I'm getting this error:
TASK [Ensure monitering apps are running with latest image.] ************************************************************************************************************************************************************************************************
fatal: [192.69.0.11]: FAILED! => {"changed": false, "errors": [], "module_stderr": "", "module_stdout": "", "msg": "Error: pull failed with 404 Client Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=prometheus-custom: Not Found (\"pull access denied for prometheus-custom, repository does not exist or may require 'docker login': denied: requested access to the resource is denied\")"}
I understand that it's not able to find prometheus image I'm building, and I think it's not even building it in the first place.
So how can I build it?
ansible task
- name: Ensure monitering apps are running with latest image.
community.docker.docker_compose:
project_src: "{{ config_dir }}/monitoring"
pull: yes
build: no
become: false
I tried with build: yes btw, didn't work
I can suspect percentage of Windows user who will discovery it is extremely low xD
Linux ecosystem pushes users to discover CLI instruments eventually
pretty sure symlinks are gated behind admin on windows lol
Plus learning windows is in general useless for web dev. Windows sucks (and their Windows Servers suck)
anything u learned from Linux -> makes u more efficient to handle servers in addition to having better dev env
wow
Freeze gun can simulate time running as 1 hour per tick
very useful for tests
@rapid sparrow question if you are free
if you use aws lambda to call another api
where do you put the api token
i see that aws lambda has environment variables feature - do you use that?

AWS secret manager
ah this isnt for production. just poc
U can query secrets with boto3
Probably yeah
We have in current organisation written plugin, that exposes secrets in boto3 AWS secret manager like fallback if they aren't found in environment vars.
Application only sees environ["bla"]

i got everything setup only a few hiccups with hosting a fastapi server. I made a docker image docker FROM python:latest LABEL MAINTAINER="HRLO77" LICENSE="MIT" COPY ./* website/ WORKDIR /website/ EXPOSE 8000 RUN python -m pip install -r requirements.txt CMD ["python", "__main__.py", "True"] and i want to host it on localhost:8000 so that i can connect to it in my webbrowser, this is __main__.py ```py
import os
import socket
import uvicorn
import sys
if sys.argv[1] == 'True':
uvicorn.run('backend:app', host='localhost', port=8000)
else:
uvicorn.run('backend:app')```
im running docker run --privileged --network="host" <IMAGE_ID>
i can't connect to localhost:8000 tho
the server starts up but i just can't connect to any of the endpoints
Try binding to 0.0.0.0 instead of localhost
I did
Then I visited 0.0.0.0:8000 and localhost:8000
Neither worked
Well connecting to 0.0.0.0 wouldn't work but localhost should. 0.0.0.0 is just a special value that means bind to all interfaces I believe.
Anyway, does it work without --network="host"? And what if you use -p 8000:8000? (should be redundant with EXPOSE but who knows)
Oh, and are you using http or https when you try to connect? Should be the former.
Doesn't without --network or with EXPOSE
and http
I'm out of ideas, sorry.
u can't build and point image at the same time
image syntax declared image to pull from docker registry (optionally from local thing, where they are already built in local docker)
build syntax declared building from dockerfile in current filesystem
u need to choose something one
(delete image syntax if u want building it locally)
Ok
I had fast api working inside docker, let me share my files in a moment
you need -P or -p 8000:8000 to actually map the ports to the host network
the server can listen on 0.0.0.0 inside the image, it will be mapped to localhost/loopback on the host network
