#tools-and-devops
1 messages · Page 3 of 1
and secondly... i think there is not really answer to simplify it. except, for whatever system you are going to use, try to make it using numbers like requirements.3.9.txt or something like that 
i mean, each python version has different requirements, sometimes even libraries are needed moved out of deps into project folder of colde, so i think it is the only choice to account everything
I have such a system in place, I just want to make it such that the same requirements.txt can be referred to in each iteration over the matrix so I don't have to copy more or less the same set of dependencies across multiple files
you do know u can point to multiple requirements files?
pip install -r req.txt -r req2.txt and etc?
feel free to make some of them shared 🙂
u could make your own kind of tool in addition, that would be having everything of it in single file with some semi ini format, and then generating resulting requirements files
may be there are already tools like that. dunno. i think it would be easier to make one xD
one file with requirements.ini would be having it grouped under different inis
then template rendering to requirements for different versions
and same tool would be installing it if necessary
The code is a bit messy but I managed to write a CLI script that checks the versions for an input package
thats cool
Hello every body. I'm not sure I'm on the right channel, if I'm not feel free to say it to me (and also that would be great if one could indicates me where to go...).
Here is the situation : I'm not a developper (I did some development some years ago, but just kind of scripting). I'm a Ubuntu user since a while and up to now I managed to compile about everything I wanted to compile on Linux). But... I'm now trying to build a software from source (Ardour) and the waf command is use for that (./waf configure and ./waf). It worked fine on linux, I managed to build and run this software but I can't manage to buid it on mac. I make the assumption that waf is a part of python and would like some assistance to build this Ardour software if possible. Up to now I (think) I passed the ./waf configure step, but the ./waf step exits with errors...
Any help would be great !!!
Thanks
Made it a bit more robust, but I could still be missing something
from itertools import groupby
import json
import re
from typing import Any
from urllib.request import urlopen
from pkg_resources import Requirement, parse_version
import pandas as pd
# Dummy requirement that cannot be satisfied
BAD_REQUIREMENT = Requirement.parse('python<0,>0')
def _get_python_requirement(dist_data: dict[str, Any]) -> Requirement:
python_version = dist_data.get('python_version')
if python_version is not None:
if python_version == 'source':
requires_python = dist_data.get('requires_python')
if requires_python is not None:
return Requirement.parse(f'python{requires_python}')
return BAD_REQUIREMENT
else:
m = re.match(r'[a-z]{2}([0-9])([0-9]*)', python_version)
if m is None:
return BAD_REQUIREMENT
major, minor = m.groups()
if minor:
return Requirement.parse(f'python=={major}.{minor}.*')
else:
return Requirement.parse(f'python=={major}.*')
return BAD_REQUIREMENT
def ls_supported_versions(package_name: str, python_versions: list[str]) -> None:
output = pd.DataFrame(index=python_versions)
data = json.load(urlopen(f'https://pypi.org/pypi/{package_name}/json'))
for package_version, release_data in data['releases'].items():
for dist_data in release_data:
python_requirement = _get_python_requirement(dist_data)
for python_version in python_versions:
if python_version in python_requirement:
output.loc[python_version, package_version] = '✓'
output.fillna('', inplace=True)
# We only care about the latest patch version for each minor version
latest_patches = [
max(columns, key=lambda s: parse_version(s))
for _, columns in groupby(output.columns, key=lambda s: parse_version(s).release[:2])
]
formatted_output = output[sorted(latest_patches, key=lambda s: parse_version(s))] \
.rename_axis(index='Python (↓)', columns=f'{package_name} (→)')
print('[Supported versions]')
print(formatted_output)
Hey folks, I've found this setup in an old repo of mine:
python -m venv venv; source venv/bin/activate
pip install -r requirements.txt
python ./setup.py develop
As of 2022, do you think it is still relevant? I've also used virtualenv though venv seems specific to Python 3 (I don't need to support older Python apps). I guess I should also put requirements within setup.py.
Are there more modern/standard/efficient tooling around? I've heard about "tox", "poetry" for instance
i would recommend upgrading your setup to at least
pip install -r requirements.txt -c constraints.txt
do pip freeze to constraints.txt, and mention main root deps without version / or with range of acceptable versions in requirements.txt
feel free also having dev dependencies mentioned in requirements.dev.txt
poetry, pipenv and etc are slow as fuck and i don't recommend them because of this reason. May be for some big projects they are justified for easier keeping track of deps
btw I hit "setup.py install is deprecated. Use build and pip and other standards-based tools" when installing so it's definitely outdated
with the vaguest message ^^
ah that's interesting to know
tox is like local matrix pipeline builder, technically people use usually CI tools stuff like gitlab CI instead of that, building CI and CD pipelines in it
guthub actions does exactly same things as tox, but runs at cloud servers remotely it for every commit
ok I see, I don't really need that currently, more a way to manage packages
venv does the trick but requirements.txt is too simplistic
with requirements/requirements.dev/constraints being used at same time it becomes sufficient tool i think
at least it works super duper fast
with having constraints, you can have neat deps like...
that will help thanks for this tip
requirements.txt
flask >= 2.0
constraints.txt
flask == 2.1
click == 2.2
wsgi === 2.2
and etc
you mention only root/first level deps in requirements even without versions
flask
constraints.txt is not installed, it is just locking which versions are needed used for root and secondary deps
pip install -r requirements.txt -r requirements.dev.txt -c constraints.txt as final command
requirements.dev.txt for example has only first level deps for your dev env
pytest
depending on what kind of type of app you make...
well, in backend world we use then docker/docker-compose to setup dev environment including having testing further
it sort of works like augmented venv
but locks not just python version and its packages
docker locks all necesary binary applciations neede to be installed to linux OS in its dockerfile
yeah this pattern is great but just time consuming to create the Docker image, relative to a few pip commands
that's cool in a team context though
ok so I think I'll be ok with venv and well defined requirements + constraints, regarding to package installs
and about "setup.py install", the deprecation message doesn't help much
how can I bundle a binary based on an entrypoint?
on Python 3.10 installed with asdf it doesn't work anymore it seems
or maybe my binary ends up in a path that is not in PATH yet
long?! probably u just not having sufficient experience in it. it is brain dead easy with python docker hub images
FROM python:3.10.5-slim-buster as base
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /install
RUN apt update && apt install -y \
git \
bash-completion \
&& rm -rf /var/lib/apt/lists/*
COPY ./requirements.txt ./constraints.txt ./
RUN pip install -r requirements.txt -c constraints.txt
WORKDIR /code
COPY . /code
any time used on docker is compensated with brain dead easy setups later, and having all installations as a code documented
i have commands further simplified with docker-compose and makefile made in python though
" && rm -rf /var/lib/apt/lists/*" this lines is the kind that bothers me lol
but thanks for sharing, the great thing is that once done it will always work indeed
https://github.com/darklab8/darklab_darkbot/blob/master/docker-compose.scrappy.yml
as example, i have here documented all database versions / side car deps at docker compose level for scrappy microservice
ergh, docker best practice to decrease a bit final sum size of all layers.
So much wrong here
feel free to mention what is wrong 🙂
i would mention i don't use already COPY . . though. since of not reliability to use .dockerignore as blacklist to ensure nothing leaks into image
I use of course stuff like COPY src /code, to ensure whitelist copying
ENV format is wrong
you are pinning to exact version so bad testing
your install git and bash-completion for some reason
let it write bytecode, who cares
I've found that also: https://stackoverflow.com/questions/62983756/what-is-pyproject-toml-file-for
it seems that I should replace setup.py by "python -m build" + a pyproject.toml
forced upgrade
but initalizing the pyproject.toml leads me back to poetry
well, it made sense when i used multi stage containers
they are installed to augment my dev environemt
visual studio connected to container with installed git
has working correctly git modules
i develop from within containers with cli or vscode connected to them
python bytecode-writing is disabled in the "official" debian python image too. i wonder why?
the community is attempting to finally converge on some new standards. this isn't a matter of chasing the shiny and new; the status quo was horrible for the better part of a decade, and despite being a major upgrade over what came before, was still quite nasty and subpar compared to other language tooling. the current churn should be short lived, as the standards are stabilizing and tooling catches up with the standards.
pyproject.toml aims to be a standard place to specify your project/library metadata, like name, dependencies, version, etc. it also aims to be a central location for dev tools (e.g. flake8, mypy) to look for static config information. the intention is that you should be able to replace setup.cfg, mypy.ini, and tox.ini with a single pyproject.toml file.
however, the most important part of the pyproject.toml file is the part where you specify the "build backend" and any dependencies that are needed to build the package. examples of build backends are setuptools, poetry, flit, and hatch.
the idea is that when you run pip install on a package with a pyproject.toml file, pip will read the file to determine which build backend to use, and then hand off the build process to that backend. the backend is then free to do whatever it needs to do in order to build your stuff as a binary archive. setuptools for example will still look in setup.py and run its contents for doing things like building C extensions, but that's only after the build process has been handed off.
i should write this on stackoverflow...
setuptools specifically intends to deprecate their python ./setup.py interface, so yes, you should eventually plan to change how you build setuptools projects, and the build frontend is probably the best choice for doing so. however this does not mean that you have to throw out your setup.py file, it only means that you need to add a pyproject.toml which declares that your project uses setuptools as the build backend. you can leave everything in your old setup.py if you want.
as far as i know, build should work with any pep 517 build backend, so you should be able to use build for any project: poetry, setuptools, etc.
Much thanks for the details answer, that's indeed worth a SO answer!
ok I get the point
btw loading requirements in setup.py doesn't seem to work anymore: https://stackoverflow.com/questions/14399534/reference-requirements-txt-for-the-install-requires-kwarg-in-setuptools-setup-py
"python -m build" doesn't run in the same context/folder/whatever so it cannot find "requirements.txt"
I don't know yet if its due to Python 3.10, how build work, how python -m work, or my install of Python with asdf
but after a bit of struggling I could at least build my CLI tool again with "build" \o/
this doesn't answer your question, but consider heeding the advice in that SO answer f not using requirements.txt as the source of data for install_requires=
"the community is attempting to finally converge on some new standards. this isn't a matter of chasing the shiny and new; the status quo was horrible for the better part of a decade" haha hello from the JS ecosystem
I had issue specifically with TatSu version
so I am not sure how I can imposes versions to the "build" venv without that
somehow it kept loading an older version that I probably accidentally installed outside of venv
I thought it would have loaded the requirements.txt automatically but no
setuptools never did this fwiw
show your setup.py and pyproject.toml as well as any commands you ran + errors you got
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
indeed so I didn't get how to pick the right packages, if I cannot pass it requirements.txt, that means a lot of duplication
(also your requirements.txt for good measure)
imo the best solution is to put your deps with "loose" package versions into setup.py/pyproject.toml, and use pip-compile or pipenv to generate a "locked" requirements.txt (or as i have been calling it, requirements.lock)
much like package.json vs. package.lock
right. but here's a question: is this an "app" or a "library"? and how do you intend to distribute it?
it's a binary
a CLI tool, it takes my Google Agenda export and generates a CSV with my work per day per client
(so sorry it's not clean enough to share, it has my client names everywhere, but you could write that in 2 hours if you are a skilled Python dev)
okay. consider that pinning exact dependency versions means that it can never really be installed outside of a venv, or outside of some other encapsulation/dep-bundling tool like pex
I have a second app that is more interesting, it's an Electron soft with a Python backend, I am mainly preparing to improve this one
hence the need to upgrade my knowledge
well it's probably for the best to install an app into its own env anyway
brb a minute
thank for your help
my guess as to why it wasn't finding requirements.txt: the requirements file wasn't included in the package data files, so it wasn't being added to the ephemeral build environment
but regarding general recommendations. if you assume that it's installed into some isolated environment (like a venv) that won't conflict with other installed packages, then go ahead and pin exact package versions in pyproject.toml or setup.py
and then if you want to be extra-safe/pedantic about transitive dependencies, you can use pip-compile from the pip-tools project to walk through all of your deps and generate a requirements.txt that acts as a lockfile
!pypi pip-tools
you can also generate a "constraints" file which is very useful if you have different sets of deps (e.g. one for testing, one for runtime) but that's a separate thing kind of
hmm not sure, it's happening higher, because I load requirements.txt in setup.py directly
package_data={"": ["requirements.txt"]},
this doesn't work, because it it's in the setup config, but you load the file in setup.p
yeah I was recommended that earlier so I've created one
hm. yeah i'm honestly not sure. but you probably don't need/want it anyway in the setup i'm recommending
yeah makes sense
i have something like in the makefile my current project at work:
requirements-run.txt: pyproject.toml
venv/bin/pip-compile --resolver=backtracking --generate-hashes --reuse-hashes --extra=run --output-file=$@ $<
@printf '$@ regenerated. Make sure to add it in Git.\n'
requirements-test.txt: pyproject.toml
venv/bin/pip-compile --resolver=backtracking --generate-hashes --reuse-hashes --extra=test --output-file=$@ $<
@printf '$@ regenerated. Make sure to add it in Git.\n'
# See https://pip.pypa.io/en/stable/user_guide/#constraints-files
constraints.txt: pyproject.toml requirements-dev.txt
venv/bin/pip-compile --resolver=backtracking --strip-extras --extra=run --extra=tests --output-file=$@ $^
@printf '$@ regenerated. Make sure to add it in Git.\n'
i was calling them .lock instead of .txt but i changed it back to .txt to avoid freaking people out too much 😆
i think .lock makes a lot more sense, but inertia is strong among programmers (understandably)
sounds perfect I am going to try that asap!
I am probably going to look for cross-platform patterns as well
oh and requirements-dev.txt is where i list pip-tools, mypy, and a handful of other dev tools
I recall having issues with windows only packages used for debug that don't install at all on linux
you could use snakemake and/or python scripts (with subprocess), i just happen to be comfortable with make (and a lot of people have access to it through wsl or cygwin or msys anyway)
oh, when it comes to windows-specific deps i know nothing
I've been testing "just" lately, basically make but just to run commands
I've seen that in some Rust projects
I am tired of bloated package.json scripts so now I use that in JS projects
i saw just too but it didn't seem like enough of a make upgrade, nor did it appear to support actual files as targets
yeah it's more suited to accomodate with JS dev, which will be scared by make... and just need a way to put scripts outside of messy package.json
i have a mix of "tasks" that i want to run and "targets" that i want to create. make is better at the latter but support the former, whereas afaict just only does the former.
yeah if you don't need to create any "targets" then go for it w/ just
exactly, in JS we don't use the npm scripts for files anyway hence the good fit
I hope this will become the standard
yarn/pnpm are helping because they don't support the same set of features so package.json are becoming huge messes with perfectly incompatible scripts
I've used separate requirements.txt in the past but that was messy
why don't people write scripts/foo.js and just invoke them from package.json? i've seen this before, people writing big commands right there in a json string. and i don't understand it
you can include one requirements file in another with an -r ... line, or you can use multiple together on the cli pip install -r requirements-base.txt -r requirements-win.txt
writing scripts in JS is a mess, google/zx improved it but not enough
so people mix bash one-liners, JS scripts, binaries...
i saw zx, looked pretty cool!
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
i think people do this in every language. but i agree, having a dedicated task runner makes a lot of sense. people used to use setup.py for this kind of nonsense too, inventing their own custom commands.
holy shit
also you had a "pre"/"post" convention in NPM that is not valid anymore in Yarn 2+
this doesn't happen with Just
same applies for global config variables, doesn't work
many scripts are still one-liners so you can hardly justify creating a whole file for them
"prebuild": "(.vn/scripts/is-monorepo.js && rm -Rf ./node_modules/@vulcanjs && mkdir -p ./node_modules/@vulcanjs && cp -R ../../packages/* ./node_modules/@vulcanjs) || echo 'Not in the context of a monorepo, ok'",
i would create a separate script for this 100% every time!
so yeah Make and Just are probably going to be more prevalent in JS as projects go more mature
ok true for this one lol
and a few others
Makefiles built in python for the win. Argparse is really good shit
.ONESHELL:
.SHELLFLAGS := -c
SHELL := venv/bin/python
😬
that won't please JS users haha
im a bit surprised snakemake hasnt taken off outside the bioinformatics world
Discovered today I can link multiple argparse interfaces without any imports and without breaking --help command. I can link with subprocess.run sub commands, not just with subparsers originally available there.
It allows me to have dynamically installed plugins to my makefile
And using commands without having all imports imported which would break stuff in environment where deps aren't installed yet
have to go, much thanks for helping me update my Python-foo (among all, Discord communities are imo the best thing that happened to many languages !)
xD let's build our own argparse in JS then
I've been a Python programmer for several years now. But I've barely used many of the tools available (e.g. setuptools, pytest, flake8, mkdocs, pre-commit, CI/CD platforms) . I want to take my projects to this next level but find it difficult to learn all these different technologies and how I can use them all together easily. Does anyone have a recommendation? Should I just learn one at a time? Or are there good tutorials you know of to learn all these kinds of tools? Thanks in advance!
one at a time imo
I'd agree with salt. I learnt a lot of these individually and then adding to different projects gives you a good understanding
Thanks!
Docker will solve a lot of your problems (easier Deployment, first step to proper CD, plus opens better options for CI, plus better Dev env)
Plus u will have documented as code all your OS dependencies
Kind of more advanced alternative to venv
and will open you to all new problems
That's my whole point: the article is wrong. And that makes their arguments and reasoning invalid as they rely on false assumptions
how do I replace the master branch with the second one on Git
I want to delete Master, and rename Test-iloc to: Master
well, deleting a branch is git branch -d Master
obviously, make sure your commits are reachable before you do that
if you don't know what I mean by "reachable", then I suggest you back the whole repo up someplace safe first
Hey @thorny shell!
It looks like you tried to attach file type(s) that we do not allow (.sh). 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.
This demonstrates renaming
#!/bin/sh
set -x
repos=$(mktemp -d -t git-repoXXXXXX)
trap "rm -rf $repos" EXIT
# Master branch -- create it
cd $repos
git init
git branch -m master Master
cat<<EOF > TheFile
I have some lines.
Two, in fact.
EOF
git add TheFile
git commit -m "Create a file"
# Alternate branch -- edit it
git checkout -b Test-iloc
cat<<EOF >> TheFile
Well, OK; maybe three.
EOF
git commit -a -m "modify it"
# Master branch -- delete it
git branch -d Master
git branch -m Test-iloc Master
ls -l
git log -a
git branch -av
sleep 20
How do I configure pylint? When I add the --generate-toml-config flag, it just spews out a bunch of text and I'm not sure what to do with it.
I assume you redirect that to a file
yes, but what should the file be called? And where can I even find the options to enable/disable?
append to pyproject.toml
pylint --help
call it whatever you want. But presumably pylint will look for a particular file name, so it's most useful to figure out what name it looks for, and name it that
or what Moyen said 🙂
why I'm saying pyproject.toml is because the config has keys like tool.pylint.something
what do you mean by append
so this file already exists?
if it doesn't make one.
and I put this file in my project directory?
so you might have already created it for one of those other tools
pylint --generate-tool-config >> pyproject.toml
the >> means redirect to whatever file, but append instead of write.
unless you're using cmd or powershell, in which case idk 🥴
how does that imply it's pyproject.toml
is pylint really poorly documented
why do you think so? 
the spec for pyproject.toml specifies having sections for tool configs like that.
I can't find anything pertaining to configuration and the website looks confusing 😭
aren't most things?
wait is pyproject.toml a general python thing?
https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html
that's a long page.
yeah.
Hi !
I'm developing a virtual assistant, and AI shall we say that,, anyone want to give some ideas?
or participate in the making?
check out
ok I will research that
cant send that link*
pm me !
Ill be waiting
ideas to do
got ~550 lines of code already
I want more
like Garra - Quero mais
@long surge, https://peps.python.org/pep-0518/#tool-table
Modern Python packages can contain a pyproject.toml file, first introduced in PEP 518 and later expanded in PEP 517, PEP 621 and PEP 660. This file contains build system requirements and information, which are used by pip to build the package.
from https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/
hello. How can I split log msgs between stdout and stderr with structlog?
Is it possible to have a poetry-managed package that has a setup.cfg without needing duplication between the [metadata] section of setup.cfg and the [tool.poetry] section of pyproject.toml?
Perhaps scrap the cfg file altogether and use internal referencing within a project section in the toml?
miniconda: is this something i should use as a linux user? or am i better off using virtualenv or something like that?
I wouldn't use anaconda or miniconda unless you know you need to use them. They sound complicated.
i'm following instructions for setting up someone else's packages (e.g. some pytorch model) and there are recommendations to use anaconda to manage it, i'm wondering if those are really geared towards someone on windows who is missing good tooling support
when i last seriously touched python, maybe 5-6 years ago, the recommendation was some long song and dance about running everything in its own virtualenv that i think is now outdated
unfortunately I don't really know anything
It's not outdated. Anaconda uses virtualenv under the hood
Anaconda simply combines a virtualenv and a few pre-installed packages
when we use virtualvenv, we use pypi under hood usually...
...when we use anaconda, we use conda. Which is different open source source of packages. Conda is alternative storage of packages to Pypi.
there is some common trend, to install datascience/machine learning stuff from conda
Hi
I am developing a simplified regex tool which will be easier to use regex for popular things like email, phone, date, extration, searching...
I am developing a Python package first time any suggestion will be appreciated also if interested in contribution.
Thanks
🙂 in modern lazy times there is a trend to abandon venv in favour of docker containers / docker-compose
the most crazy people abandon docker-compose in favour of running in kubernetes locally (already tools appear for this like dev spaces / tilt, with different easy to run locally clusters)
IDEs have ability to develop from within containers with hot realoading 🙂
a way cooler than venv, since we can have as a code OS level binary deps, or side car containers with databases.
Because Python version and library handling is so god awful
and all those pipenv/ poetry modern solutions are slow as fuck
one minute to resolve deps at the start of a project?!? for first dependency?!
common xD
So I have multiple small setup.py files for cythonizing different individual cython files
Normally I used a windows powershell script (or a bash script for linux) to compile each of these individual files
I want to instead make a python script to handle this stuff so it would be cross-platform, instead of maintaining individual compiler scripts
Reason I mention all that is I was wondering if would be possible to do something like this:
Individual setup.py```py
from Cython.Build import cythonize
from setuptools import Extension, setup
extensions = [Extension("Name.Of.Library", ["src/Name/Of/Library.pyx"])]
setup(
ext_modules=cythonize(
extensions,
build_dir="build",
language_level=3,
),
options={"build": {"build_lib": "src/"}},
)
```and I want to be able to essentially define that into a function, import it, and run it from my script instead of calling subprocess.Popen to handle running python /src/Name/Of/File.pyx build_ext
I'm just not sure how to basically run the function with build_ext
My docker container is reporting 16GB of memory usage, but the memory usage on the host is only 12GB how can this be?
dedupe
hm?
memory deduplication.
basically shared memory
things like the kernel are shared across all containers
Also, that’s a ton of memory
ok, but how does my container have more ram in use than the host has in use?
the container doesn't see the deduped memory. It just sees it as memory. The host sees all.
It sees the memory for what it truly is(n't)
memory compression could also be in effect
does anyone know a programming software that allows you to highlight a bit of code and collapse it into a small title which you can click on to expand?
modern code editors are capable of that - https://code.visualstudio.com/docs/editor/codebasics#_folding
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
visual studio 😅
im using atom because i couldnt get pycharm to work for some reason
i'll just use visual studio ig
I guess even vim supports it with some magic plugin or something
I think atom got abandoned
You've got 4 months left
VS Code does everything Atom does and more
I also used to use Atom but just accepted that once MS bought GitHib that Atom would be deprecated some day soon
at least it's not sublime
Anyone having problems with conda? it seems to be taking a long time to install.
Does any1 here know how i can add a cc gen to my python script and a validator?
hi guys, anyone experience with monitoring facebook and instagram? I am searching for partners and would love to get some input on how to achieve this.
assert cipher == [1, 1], f"cipher={cipher} (should be [1,1])" :I get "SyntaxError: invalid syntax" But only on macos not on windows or linux. How to fix it on macos?
ah I have set up python 2 instead of python3 in the github pipeline
I think it is just that 🙂
is there a way I can check if someone downloaded a file in my system using python?
What do you mean by downloaded?
Is there any website that gives an overview over commonly used technologies?
I am not talking about the "main" technologies like NodeJS for a MERN-Stack. I am talking about "additional" tech like:
Docker, Kubernetes, Terraform, Jenkins, Sentry; testing libraries; SQL abstractions (ORM, object relational mapping); also stuff like the usage of .env files or "keep a changelog".
Like - I know of the mentioned techs, but have just recently learned about the existance of Jenkins. And I am sure there are many other technologies / tools that are used in production but that I know nothing of.
Would also be great to see an explanation of a real world project that uses some of the mentioned technologies, why they decided to use them and how they are used.
so ci/cd
-e, --editable <path/url> Install a project in editable mode (i.e.
setuptools "develop mode") from a local project
path or a VCS url.
pip install -e . does this mean my pip install updates itself when I change the code?
can anyone help me setup constraints on package_data based on operating system in a setup.cfg based package?
yes, try it and see
im going in
Can you add a single directory (which is a package) to the PYTHONPATH without added all other directories in the same parent directory?
no, PYTHONPATH is for directories that contain modules and packages. if you have a mylib/ directory with 100 .py files in it, you can't select just 1, they will all become visible when you set PYTHONPATH=mylib
I am currently looking to implement terraform ci/CD and can't decide whether to use Atlantis or builtin gitlab-ci. Does anyone have feedbacks between these 2 solutions?
Atlantis is ChatOps, Gitlab is GitOps
you should try to choose GitOps first
you would like to see for each commit verification, if deployment became succesful or not and all tests ran succesful, you would like to see ability to rollback yourself to previous succesful deployment (and to know which was succesful), you would like to compare git history between succesful to newely broken states, what was changed
Atlantis is convinient of course... but it can be auxilary system only in my opinion. Just a tool to provide additional access to developers, so that they would own infrastructure more
Vscode auto complete for .so modules?
Ok maybe I just don't get it how to ever ask this.
So I've been working on creating a python module with boost python. It works have a makefile that makes me a hello.so that I'm able to call functions and make classes from, yata yata. But in vscode there is no auto complete for my .so module.
The thing is I know the doc string for my .so exist because in python interactive shell I can view it.
$python3
import hello
help(hello)
// this will show me the doc string for the module...
But vscode can not give me a auto complete. I've tried pylance, pylint. But nothing I do in my settings.json will give me auto complete for the module.
I've read something about a python stubs or .pyi files and they are supposed to give auto complete for .so modules.
Has anyone been able to get autocomplete in vscode to work for .so modules? How did you do it?
Any advice would be greatly appreciated.
And if you are lost about whatever it is I'm talking about just ask for clarification. I may have to go and ask stack overflow but sometimes they are rude so I'm really hoping someone will understand what I'm asking.
Well I think that these chatops things is not really a thing. It's just that you type a comment instead of hitting a merge button to apply. I don't really care about that difference. In any way the state would never be stored in the git repo so I don't really get your point
#editors-ides or #type-hinting might be better place to ask this. also consider making the question a bit terse to help people help you easier.
FWIW .pyi are typing stubs to help the type checker when the library itself can't have the type hints
The point in all devs having shorter path to access and try. It imitates for them access to local staging terraform plan and apply command.
Increases ownership of terraform code
not really sure if I agree with this pov but I can understand it
There is difference between ChatOps and GitOps regretfully
in ChatOps you don't have a history of verified commits that passed tests/deployment, you don't have advantage of seeing git difference between succesful and now broken state
you can try implement it being present though
well only the plan / apply is handled through comments. everything else is in the repo and the said plan in CI logs
deployments should be having git history too.
only then you would see when your infra code is succesful and when not
it gives advantages to rollback to previous succesful state, to previous succesful commit
seeing difference what changed for infra code as well
instead of trying to provide 99.999999% quality, invest little effort into giving yourself easy ability to rollback back 🙂 and fixing in whatever time is necessary.
i think i've seen repos on GitHub marked as "mirror". I followed these instructions https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository and did not get "mirror"s, they are just separate repos which are snapshots at the point they were made. Am I imagining that GitHub marks repos as mirrors?
for example: how were these repos created? https://github.com/search?q=mirror%3Atrue
I think you just imported a repository
github no longer allows creation of mirrors
It used to be a thing you could ask staff to do and convert an existing repo into a mirror.
The new solution (if you have control over the remote) is to configure a post receive hook to push to github
yeah, i was reading stackoverflow answers that said the same thing.
Why would they not?
It makes perfect sense to have a repo on some source control other than github and then have mirrors for it.
Easy answer: Microsoft bought Github
sphinx.autodoc is quite vast
I can't imagine how much functionality I missed using mkdocstrings
I want to embed images in my docstrings. The problem is that the images are stored in docs/img, is it possible to cross reference the image URL relatively in the docstring?
Actually I want VSCode to show them. But using relative paths doesn't work, it needs to be a web URL. Should I instead put the link of the image in my repo inside the docstring?
Do anyone know how to delete a virtual environment?
Do u know the command in commandprompth?
That's like a 30 sec google search away, but rmdir /s
Hey guys I'm using the Notification capability in the Plyer module in Python, is there a way to run a certain piece of code when you click or interact with the Notification.
Anyway to determine payload size in postman?
For the GUI?
you would run this code in the javascript "tests"
sorry not very familiar with this process or JS. Is there a website for this or do I need to develop a script?
there is a section in postman that lets you write tests for a request. those tests are written in javascript
Got, thank you!
Is there any python package manager that can work nicely without it being installed at the system or user level?
I want to be able to install the package manager in a venv, then just run pkgmanager install? Reason being that I want lockfiles, or at least something better than pip freeze > requirements.txt
!pypi pipenv is my go to
Can't live without it
All installation instructions require pip install --user. I want something that can work inside a venv that I make
Yeah after you do pipenv shell, you can then do pip install
Don't need the --user as its already in a venv
Interesting. These package managers work better inside virtual envs than I expected
pdm
yep they all are just python modules. however all of them except pdm use pip internally.
and actually pdm might use pip internally too.. let me check
yeah nope it still uses pip internally
Yes. Been playing around with it and it does all of the things I want it to
i like that it doesn't "take over" your project like poetry
it just manages packages
also pep 582 is cool
!pep 582
Agree entirely about both things. Never liked poetry, but pdm seems great so far
anyone have some good suggestions on a free, sqllite modelling tool, I kinda liked Moon modeller, but it doesnt support sqllite in the free version
Hello! How i can stop someone to text here?
pony orm has a nice web-based modeling tool that also generates pony orm classes that you can copy and paste into your python program
unfortunately it doesn't support async natively yet, but with anyio it's not that hard to run queries in background threads
(the built-in sqlite3 module doesn't support async anyway)
What do you mean?
Hi, suppose I have a feature branch already pushed to remote repo. I need to rebase it to master remote branch. What is the cleanest way to do this?
When I try to rebase, git will always suggest git pull after and the commits look duplicated…
Checkout to feature and do git rebase master
hi, when I do this, git tells me the branches has diverged and to do “git pull”, but afterwards, hell breaks loose as commit history has duplicates
git fetch -A
git rebase -i origin/master
that will open your editor to let you pick, reorder, drop, squash, edit, or fixup commits.
the more you reorder or fixup, the more conflicts you'll have to fix later.
Please I need help with django, I’m try to send an email with mailjet with django but it returning error “connection unexpectedly closed “
@gentle solstice thank you!
is sphinx still the go-to documentation generator? looking for something to standardize on at work. low friction is a must, but i also want to avoid wasting time on some new fad that won't stick around
I'd say "plain text" is the go-to documentation generator, but that's just me
I haven't played much with sphinx, but I doubt anyone would call it "low friction"
it seems complex
nah i need at least auto-generation from docstrings
I'd use doctest for that tbh
then at least you'll know your documentation is correct.
and markdown output so the repo's README.md is the entry point
doctest is kind of orthogonal to this, but a very good suggestion
I guarantee you, if you spend a bunch of time on fancy doc-generation stuff, your docs will suck anyway.
they will not be maintained, and may wind up worse than useless.
yeah, i know. i'm trying not to spend a bunch of time. set up the pre-commit hook once and have it generated from source
doctest, man
and it's only for library code, not our whole codebase.
nothing else (that I know of) has a chance of being maintained
of course I'm assuming that you'll actually run the doctests on every build 🙂
pre-commit, yeah
i'll take a solid look at whether doctest can be the whole solution, thanks
the strike against it (for our use, not a flaw) is that we have typescript repos, too, and if one tool can handle both, it's a huge plus
having a consistent set of standards, output format, build process, etc. across languages is a huge advantage if we can get it
as generic documentation yeah, but we also have openapi stuff specific to documentating backend apis. comes inbuilt into fastapi, redoc and something else generated automatically.
Hello, does anyone know what python module to use for physics units?
I want to work with a module that:
-has a large number of pre-existing units
-has an easy way to create a new unit
-has an easy way to convert a unit to another
I tried scimath (don't know how to create a new unit) and unum (not that big database so a lot of time to create new units) does anyone know of any other modules that work for them ? (or help me with creating new units in scimath if you know how)
a separate but related question: is there an automated way to do a "regression test" on the public interface of a package? i don't want someone (coughcough me) to innocently improve the name of a function parameter and break a caller in a different repo who passes it by keyword
wouldn't boring old unit tests catch that?
Yeah I guess, gfe, was just lazy to go through more documentation, I found what I wanted, I think pint works pretty well
sure, if i know how to write a unit test that can catch any change to the interface and remember to write one for every method/function
and if i use the IDE's "refactor" function to do the ill-advised name change, the unit test will get helpfully refactored, too 🙃
uh, if that's not what your unit tests are doing already, then what are they doing?
then don't do that
seriously?
if that's a real risk, maybe move the tests to a separate project
I assume most IDEs will confine their refactoring to a single project
move the tests to a separate project? 
yep
i want my coworker who handles devops to still be my friend
it's an unusual step, but you seem to have an unusual problem
thanks for your help @thorny shell, i'll consider the advice
astropy has some subset of this behavior https://docs.astropy.org/en/stable/units/index.html
there are also bindings to udunits2 but i don't think you can create custom units with it https://cf-units.readthedocs.io/en/latest/
If anyone who can code really well in Python please dm me to help me create a system for my school’s Canteen!
Trying to run a simple fastapi app using uvicorn and docker. When I use txt uvicorn app.main:app --host 0.0.0.0 --port 8000 The server runs and I can get a response at the address. Doing the following in docker seems to not be working as the address is showing txt Firefox can’t establish a connection to the server at 0.0.0.0:8000. bash (env-jarrodh-dev) jarrod@jubuntu:/media/jarrod/D/Projects/jarrodhdev$ docker build -t myimage . Sending build context to Docker daemon 9.216kB Step 1/6 : FROM python:3.10.7 ---> e285995a3494 Step 2/6 : WORKDIR /code ---> Running in a4b4c729a524 Removing intermediate container a4b4c729a524 ---> d951c1ee0196 Step 3/6 : COPY ./requirements.txt /code/requirements.txt ---> 3ea538106cca Step 4/6 : RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt ---> Running in 3f06215d9f68 Collecting anyio==3.6.1 --SNIP PIP INSTALLS-- --END SNIP-- Removing intermediate container 3f06215d9f68 ---> 17ea74b9f562 Step 5/6 : COPY ./app /code/app ---> 1b67559a1a45 Step 6/6 : CMD ["uvicorn", "app.main:app", , "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"] ---> Running in 98ee463d8ab4 Removing intermediate container 98ee463d8ab4 ---> 76c30d9a2453 Successfully built 76c30d9a2453 Successfully tagged myimage:latest (env-jarrodh-dev) jarrod@jubuntu:/media/jarrod/D/Projects/jarrodhdev$ docker run -d --name mycontainer -p 8000:8000 myimage f17c18e2f0485dbad623ae93a93a29eac5103a80495d6d8aa80dbfb175312c64 I can build the image and run the container, but it just doesnt seem like the server is running... Here is my Dockerfile ```docker
FROM python:3.10.7
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
CMD ["uvicorn", "app.main:app", , "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"]
are you typing http://0.0.0.0:8000 into your browser? try http://localhost:8000 instead, or http://127.0.0.1:8000 which is what localhost usually resolves to. 0.0.0.0 is not a real ip address that you can access. see https://en.wikipedia.org/wiki/0.0.0.0
In the Internet Protocol Version 4, the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target. This address is assigned specific meanings in a number of contexts, such as on clients or on servers.
Still cannot connect. When I use 0.0.0.0 without Docker, it does work. But I tried localhost:8000 and got nothing
try 127.0.0.1
still "Unable to connect"
you can also use curl to make sure it works from the command line. curl 'http://localhost:8000'
iirc uvicorn emits access logs by default. do you see any? or does it look like the python program isn't receiving your input at all?
try also adding EXPOSE 8000 in the dockerfile, and run with docker run -P
I'm not getting anything from uvicorn in the console maybe because I ran the container headless?
no, you should
is uvicorn actually in your PATH in the container?
FROM python:3.10.7
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
CMD ["uvicorn", "app.main:app", , "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"]
oh that's it
How would I add that
I'm followign the tutorial on the FastAPI docs, but it didnt mention that
idk, i never had this issue myself and your dockerfile looks fine
just running through ideas
when you run uvicorn on the console, you should see nice logging output, at least indicating app startup
try inspecting container IP and use that instead of localhost
do you see none of that when you run the container? you should
Ok adding EXPOSE 8000/tcp and trying again
also, ensure port is exposed when you do docker ps
-p should definitely listen on localhost at the port you specify though
yes, it should
I've never used EXPOSE statement before
Ok I ran the container without headless mode and got this output, probably means I need to edit PATH in dockerfile? ```bash
(env-jarrodh-dev) jarrod@jubuntu:/media/jarrod/D/Projects/jarrodhdev$ docker run --name mycontainer -p 8000:8000 myimage
/bin/sh: 1: [uvicorn,: not found
no, this looks like a weirder issue
it's looking for the program [uvicorn,, as if that CMD command was a single string being passed to /bin/sh
...what the heck
so to answer your question: it doesn't work because uvicorn never even starts
i also didn't realize what you meant by "headless" mode, you are using -d which yes will prevent logs from being shown on the console
oh wait
you need to look in docker logs for that
if that's the problem, this is a bug in docker's input validation and error handling
but good catch
...that's a docker bug imo
the empty argument caused it to parse the whole input incorrectly as a string. wat??
yeah, it should complain on building
though CMD statement is used on container creation, no?
Yeah I'm suprised no errors showed up
man, docker doesn't even have a public bug tracker from what i can tell
i am definitely going to switch to podman as soon as they have good buildkit support
Does it have a github for creating issues?
docker
Oh yeah theyre on github.
Does seem odd that such a big entity doesnt have a simple bug rreport feature
not surprising imo, it's a for-profit company that happens to run several related open-source projects
the problem is that it's hard to know which component of docker to actually file the bug report with
@wary oasis does it still happen if you enable buildkit? https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds export DOCKER_BUILDKIT=1 and add # syntax=docker/dockerfile:1 to the top of the dockerfile
Seems like I enabled docker_builkit (console output looks different when building) but still getting the same problem when trying to run the container ```txt
docker run --name mycontainer myimage
/bin/sh: 1: [uvicorn,: not found
Add a space after [
docker run --name mycontainer myimage
/bin/sh: 1: [: missing ]
``` 🙃 ```docker
CMD [ "uvicorn", "app.main:app", ,"--proxy-headers", "--host", "0.0.0.0", "--port", "8000"]
Space before ] too
different error intersetingly
You should consider using gunicorn and configuring most of your cli options with env vars
Different error once agina haha ```txt
docker run --name mycontainer myimage
/bin/sh: 1: [: uvicorn,: unexpected operator
with space at beginning and end
docker just doesnt know what to make of it
You've got 2 commas next to each other
Yeah, I figured that out eariler. I was just testing if anything changed when using docker_buildkit enabled
You could just make it a single string.
Really? I did think it was weird to have to do it all in parts
I am brand new to docker, just following the small tutorial in the FastAPI deployment docs
The container basically runs $ENTRYPOINT $CMD
I am reading the official docker getting started tut now
By default, the entry point is sh -c, and the command is python
A lot of containers make their cmd /.docker-entrypoint.sh which runs or sources /.docker-entrypoint.d/*.sh
does anyone perhaps know how to join a roblox game using the ro_py api? ( i don't know which channel to say this in )
i think this is objectively worse than specifying a list of args btw
also i asked them about buildkit because this is clearly a docker bug, and i was curious about where in the docker "stack" the bug occurred
clearly it's somewhere in the dockerfile parser
show your code and explain what exactly it is that you are doing
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
How can I edit a specific commit
I wanna change some lines from a specific commit
yeah, undo the commit, make a new one that's just like it
hm maybe not 😐
if the commit you want to edit is the most recent one, it's pretty easy -- just make your changes, stage them, then do "git commit --amend".
But if it's older, you'll have to do an interactive rebase, which I can't walk you through 😐
[and of course, if you've already published the stuff you want to change, you probably shouldn't edit at all, and instead just publish a new commit that fixes the problems]
well yes its an old commit
but I cant publish a new commit
because I added lots of lines that I gotta test before production
so i just wanna adjust an old commit
I'm annoyed that I can't find straightforward instructions for this in that git-scm book; I thought it was pretty slick
this is a better explanation, but it's still not beginner-friendly: https://git-scm.com/docs/git-rebase#_interactive_mode
if you choose to do that, I strongly suggest you practice on a throwaway repository first
or even use a decent GUI that makes this easy (I only know of one, but trust me, you don't want to use it)
oh sure
the safest way is to just clone your existing repo elsewhere, and go crazy on that clone
if you hose it, so what?
if you finally get it all working nicely, then you can publish from it
k
gonna try
just cloned the repo
gonna rebase now
ok so I've just did a rebase but I got this
which one to modify lines
you probably want "e".
Like I said, I can't walk you through this.
That's why I recommend that you practice on a throwaway repo.
I can't even click on it lol , I'm using vscode
set the command to edit on the commit you want to edit (instead of pick), save the file and close it
then the git command line will proceed
it's just like editing a commit message. git waits for the file to be saved and closed before proceeding.
git will then pause the rebase process at the commit you marked with edit, then you can do whatever you want, e.g. git commit --amend
then do git rebase --continue to proceed
Hi all,
Trying to think of the best way to do this. Want to make a discord bot that uses Docker, but uses a package that I'm actively developing locally. How would I achieve this? Mount as a volume? I understand volumes aren't recognized in the DockerFile, so would I just pip install in some entry script? Or should I use a separate image for just a python library?
could you rephrase it more coherently
what are you trying to achieve?
I want to use docker, but have an external package that I install as an editable dependency that is not in my working directory (pip install -e)
still completely not understandable

editable dependency, you mean you wish to run your docker container with hot reloaded dependcy from elsewhere in your filesystem?
if yes, then it is just a volume
Yes that is what I want
so to install it though where would this happen? In an entry script? I understand you can't reference the volume paths in the Dockerfile itself
ergh. just use docker-compose?
version: '3.8'
services:
app:
build: .
logging:
driver: "json-file"
options:
max-buffer-size: "4m"
mode: "non-blocking"
command: sh
environment:
DOCKER_HOST: tcp://dind:2375
volumes:
- ".:/code"
dind:
image: docker:20.10.12-dind
expose:
- 2375
environment:
DOCKER_TLS_CERTDIR: ""
it boilerplates all your docker settings into yaml
for example also pointing volumes to run it
then raising your docker container would be just docker-compose up command 🙂
Just learning about docker bridge netowrks, is that what this is? ```bash
jarrod@jubuntu:~$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:c1:c3:a3:66 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
7e98d42ebdec bridge bridge local
662ae9e2ad44 darklab_github_runner_default bridge local
2a9eef2d7717 host host local
3c7efd0e1fb6 make_default bridge local
4f099c884091 none null local
checking my current raised docker networks 
three networks are defaults
and two networks were raised as default bridge networks to my docker-compose alignment of containers
tbh, no idea. but logically it should be one of those networks in theory
Ahh new command unlocked! docker network inspect bridge confirms ```txt
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
xD
i am bad at networks, all i know that host network makes container running in same network space as of a host
and bridge network makes isolated sub network to me to run some group of containers (default option), which exposes only through ports to host and other external networks
with expose in bridge network i expose one container to another one without revealing it to external network
That sound familiar to what I'm reading, and I think the default is "bridge" meaning normally containers cannot communicate unless they are on the same bridge netowrk
yeah. exactly.
that's why we can point in docker-compose network settings same network name 😉
then it will create bridge network
to which we can connect multiple containers
Yeah I am going to run nginx, ddclient, and my website in a docker-compose.yml and I need to network nginx with the app
technically same can be done with regular docker, but why to bother when we can boilerplate it into yaml
Yeah docker-compose seems very useful
oh, you don't need anything to do if you write them all in one docker-compose
it creates by default same shared bridge for them
Oh I like that!
well, except probably exposing their ports to each other, with expose: port for internal communications 🙂
That makes sense
i just finished writing docker-compose for self hosted github runner. Feeling yay.
finally raising this self hosted runner without interactive actions
pexpect library for the win, to turn crappy software into semi-usable software
Hi there,
I'm not sure if this is the right channel, but I would like to ask if someone has any experience regarding integration of SAP SuccessFactors?
How do people normally handle GitHub projects? If I posted my database seeder, would people leave comments or make minor improvements? I don't want overhauls of the code, but I'm striving to get more of an authentic GitHub experience and don't know where to turn.
A brief introduction to common Git workflows including the Centralized Workflow, Feature Branch Workflow, Gitflow Workflow, and Forking Workflow.
if alone dev = centralized workflow
if organization = usually feature branch workflow
if open source = usually forking workflow for external devs, and feature branch workflow for really close inner cycle.
if many devs, big project, kinky git users = then gitflow
if super kinky git users and just experienced devs = they can go for trunk workflow
I meant more in regards to here. I am a solo coder doing it as a data science project hoping to get at least someone interested in what the prospects could be for an educational facility.
miraculously writing content interesting to other people
with experience it should come eventually. When you became professional, your material at some point should become interesting to other people if you will form it correctly for colloboration/document it understandably to others.
(or just being TikTok/Youtube person with a hunch to media stuff, then you could make as interesting material of less professional quality)
and well... making somewhere article about it to boost at least initial kick of users, just mentioning in code communities.
Okay, so more specifically, which channel here would be a good one?
it depends on what you project does
I see #databases. I guess that would be a good place to start because it seeds random data into databases.
And then allows the user to query it and whatnot. It's designed to allow a data scientist to search for trends in a completely randomized environment where one could not simply predict outcomes (in theory).
how it is going to be different from https://factoryboy.readthedocs.io/en/stable/introduction.html ? (this lib has compatibility with SQLALchemy, DjangoORM and other libs to autogenerate data with being auto saved into db as singular or batch of random values)
https://factoryboy.readthedocs.io/en/stable/orms.html
https://factoryboy.readthedocs.io/en/stable/orms.html#sqlalchemy
Because it will be coded by a less experienced coder and do less things, most likely.
I don't write it to do what has never been done. I do it to provide work upon which can be improved.
what is the "authentic github experience"? it sounds like you just want some code review
(you can post it here and someone might be happy to review it if they're not busy)
we used to have a separate channel for posting projects but it became spammy
I see projects with various comments and issues and pull requests. Things like that.
I've never been forked, so I'm a virgin.
i would be quite skeptical about stranger writing library more user/beginner friendly in syntax, more readable, more stable than already ready solid solution in this field
so u would have to convince people, why your solution is trully better in some aspect
(in your article for example 🙂 )
You've got me all wrong. I'm not trying to corner the market. I'm using this concept as a springboard.
pull requests and comments are usually something that only happens between co-developers on the same project. "social coding" is largely a myth, the real world of programming is that it's most people working on difficult tasks that other people aren't working on, or working on their own hobby projects.
if people start using your software, they will eventually start filing bug reports. triaging bug reports isn't really something to aspire to imo.
That would make sense that I've bought into some sort of mythic coding concept.
why not? bug reports make software living. making it more ready solution
Maybe I'll just stick to talking to people about like, "What should a database program that deals in widgets provide for the end user?" and just go from there.
i'm not sure why darkwind is discouraging you so much here
people write their own versions of things that already exist all the time
it's a great way to learn, if nothing else
well, point taken.
and sometimes you have a new or different idea about how to do something, and other people actually start using it
@rapid sparrow That is the evolution too. It will have ways to interact with users that are created, and items.
Basically, I want to build it into a seeder AND database application where you deal with a fictional company and how to make telephone lists for cold calls, check product inventory, etc.
Very early in the works.
publishing software as open source is good in general. you're just not likely to end up engaged in some highly intellectual social communal programming experience. open source dev and maintenance can be a challenge. but it's also tremendously rewarding to finish something, and publish it, and see other people enjoying what you've published.
that said, if you do want feedback, it seems like maybe you're putting your idea ahead of having a practical use case for it
so i'm with darkwind on maybe tempering your aspirations a bit
well, at least he knows about existing alternatives now. It should help plotting better course to the uniqueness of a project
indeed
there's nothing wrong with programming for fun, but it's important to keep in mind that, if you are writing code for other people to use, you should keep in mind what those other people might want. keeping your goals in mind is very very important when working on any long-term project, software especially because it's so easy to get distracted and just mess around with 100 things and never get anywhere.
(messing around with 100 things is also a great way to learn, but maybe not the most efficient way)
A sandbox app serving as an application for a fictional company to buy and sell widgets and deal with customers isn't a practical use case?
I probably haven't sold it very confidently, I'll admit.
what would be the use case?
is this like an extended programming exercise? as if you were contracted by some company to build their call center system, but it's a made-up company?
Yeah! That's a good way to put it.
With a built-in database seeder because I didn't want to use an alternative. Lol
At most, it's probably going to be a resume proof of concept.
i admire your creativity. this could be a good exercise in software architecture.
however, keep in mind targeting a made-up task makes it easy to cheat and adjust the task if and when things get difficult. you also aren't forced to contend with "unknown unknowns". it's also literally not useful to anyone unless you wanted to try to build a game of some kind around it. so i would argue that this is not a good resume project, and if you are looking for a resume project i suggest doing something more practical.
there might however be very practical individual components in here
Okay, some gems in the dirt, so to speak.
indeed. also it's not dirt in and of itself, but it might not be the best use of your time and energy
e.g. the test-database seeder is an interesting project, although maybe a bit boring and like darkwind said, good ones already exist. database seeding isn't really a challenging or interesting task from a design perspective
however, making a little game where you have to work in a call center without getting fired... that might be fun 😛 (or just stressful to play, lol)
I think my task now is interacting with the seeded database.
Like, pulling random customers and putting them on a list, for example. Maybe generating a webpage to view them on.
sure, if you want to just learn basic things like "how do i read from a database and move data around" then sure, i think this is a good project
right. you can practice things like making web dashboards and designing apis
The seeding is essentially done for now. Though, probably not done cleanly. Lol
the fact that it's a fake call center becomes less relevant if you start to build nontrivial real software around it
So, I should spend less time on installation and seeding and instead focus on the actual components of database management.
i would say so. get it to a point where it works well enough for what you need, then move on to other tasks
this will be time very well spent if you learn how to use and administer databases and how to use popular packages like sqlalchemy
maybe fake data isn't ideal, but you already did that part. so it's not worth undoing work you've already done
Is SQLAlchemy one that seeds as well? I'm looking through the website now.
Seems like it is. I'm looking at a script that has a Customer class that appears to be creating data.
If nothing else, I learned about a new tool for seeding a database and thus less to have to focus on when dealing with the "game" of how to not get fired at a call center. 😄
Though, probably working on a script instead of being on calls would be the antithesis of good call center work if we're getting really into it.
what do you mean by "one that seeds as well"?
oh
sqlalchemy does not generate fake data for you
people use libraries like factory boy in conjunction with it, which is what darkwind was saying
actually that sounds like a really fun game. "try to automate your job while also continuing to do your job and not get fired"
your score is the % of time at work spent not working while still meeting performance targets
like one of those "program an ai and fight other players" games combined with one of those old flash games where you run a restaurant
The only game I've made so far is a "choose your own adventure" text-based game in Javascript that I've been debating putting in Django but that is daunting to re-write it.
Usually game like that would be probably making sense putting first into frontend frameworks like Vue.js/React/Angular perhaps
Frontend is more meant to augment games main stuff, for single player stuff
Django is needed only if u need server side to it
Making board of scores, profile, making it multiplayer game
Dang it. I had a place asking if I code in React.
Guess I will have to for that, huh?
Thanks for the pointers, @rapid sparrow and @tawdry needle! I appreciate the honing of my focus.
U a welcome. Also saying that learning curve is smaller and easier for Vue.js, but React is thrice more popular in job market. As backend Dev it was enough for me to try Vue. Js, but if I had aimed for serious Frontend career, I would have probably went for React
Wrote article about running CI agnostic parallel tests in Github Actions for backend applications:
https://github.com/darklab8/darklab_article_parallel_pytest
I would be interested in feedbacks if you would find it interesting.
Does anyone know why this doesnt work in Colab, when I run it on VSCode it works! I need to use colab in order to train my CNN faster
Hiya, I'm looking to set up github actions to be able to release my package on PyPi automatically. I am following this page from the python packaging user guide: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
It tells you to put some secrets in github and to put a yml file in .github/workflows. How does pypi know what version to release? Now it just tries to re-release an existing version, and that, of course, fails:
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
This filename has already been used, use a different version. See
https://test.pypi.org/help/#file-name-reuse for more information.
All I did now was adding some secrets from (test)pypi to github and adding this to a file in .github/workflows:
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution to Test PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
no idea what is recommended in the guide but how about finding a way to trigger release when new git tag is submitted to repo, and using latest git tag as new release name for the package?
Yeah that would make sense
This yaml file is so disgusting to work with, you basically copy stuff and hopes it works
Yaml is not at guilt. At guilt ability to execute it only when publishing new version to the cloud.
there are two choices to resovle it
- Writing your own scripts, you can fully test locally, and just inputing
interfaceto their invokation into pipeline. (Throughargparsechanged arguments if necessary). Comfortable since you can check and test each job individually. - I think i saw somewhere a way to execute GA pipeline locally, perhaps this can be explored too
I'm not saying yaml is at guilt, at guilt is my puny human brain. I'm just saying I find it disgusting to work with.
Because you don't own the process enough. Test it fully locally
just insert result into pipeline code
That's part of the problem, the thing to test is "does it do X when I push a commit". That's not possible to test locally, because by definition pushing to remote is not local
I think github maintains its own version number and uses that maybe?
just echo all the predefined CI variables and see for itself
What are all the predefined CI variables?
Oh, you mean I should just run the commands in the yaml file locally?
I'll guess I will create a test package/repo to test setting this up
What a clusterfuck
i mean, that i think it is great, when your CI just executes your commands from makefile
which you can execute locally fine too
it makes certain predictability?
and easy to test situation 🙂
same approach used in GA too
https://github.com/darklab8/darklab_article_parallel_pytest/blob/master/.github/workflows/ci.yml
gathering all those commands as python package already 
if necessary, CI only overrides some parameters like --image={{github.blabla}} for my argparse CLI
https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables all those variables
${{ github.ref }} and etc
I see, you actually seem to have some grasp on what happens behind the screens
Also I only just find out that what you set as uses is actually just a reference to a github repo
So uses: checkout@v1 uses tag v1 of the actions/checkout repo
Ah, OK, I am slowly understanding more. I was confused by this YAML syntax:
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
This of course is just python -m build --sdist --wheel --outdir dist/ but I was confushed by everything being on its own line 🤦♂️
OMG I am an idiot
you can have it all in single line
having it on separate lines just for the sake of -> making sure it fits into screen and, when you add new arguments, it leaves less footprint in git diff and commits changes
I have specified the version right there in the setup.py of course
Of course this gets used when I run python -m build
There are 63 different ways to write multi-line strings in YAML.
LOL did I say anything about YAML being disgusting?
Find the right syntax for your YAML multiline strings.
I'm looking for a compact device to run a .py and output a basic gui to a display. Basically need something to replicate the functionality of an Arduino except I don't want to learn another language.
I'd go with raspberry pi but they're totally sold out in my country. Any advice for alternatives?
Maybe this meets your needs? https://github.com/peterhinch/micropython-nano-gui you could also ask in #microcontrollers for more advice
Oooh thank you. Is micropython so different? I've heard it's far less capable and more hassle than its worth. Power consumption isn't a concern and tbh I just want tools I'm familiar with
It's not something I can speak to unfortunately. I've never used micropython, only C++ with microcontrollers. I have heard of it though, so figured I'd throw it out there.
Again #microcontrollers may have people that can answer that. You could also ask in the Adafruit Discord server
excellent tyvm
Still struggling a bit with github actions. I'm following https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ and based on that I've added the following job to my workflows file:
build-n-publish:
name: Build and publish to Test PyPI
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
steps:
- name: Install pypa/build
run: >-
python -m
--wheel
--outdir dist/
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
Triggering works like expected, however, the "Install pypa/build" step fails:
Run python -m build --sdist --wheel --outdir dist/
ERROR Source /home/runner/work/mypackage/mypackage does not appear to be a Python project: no pyproject.toml or setup.py
Error: Process completed with exit code 1.
This does make sense, since there is no setup.py in mypackage/mypackage; it's in mypackage... It's not clear to me why it uses mypackage/mypackage as the working directory, or how to fix this. Any suggestions?
Ah, I think I know what's going on, the mypackage/mypackage path is not the subfolder in my dir, it's the default working directory. However, the repo is not checked out because that was done in a different job and apparently jobs have independent state.
Hey, im trying to deploy my flask app to DigitalOcean but im lost.
I created a droplet to run a py script with cronjob every 24h.
I created a webapp with my flask webapp
How do I now connect these so that the py script returns get updated into the db from my web app?
Thanks for any help or resources / documentation
if i understood correctly what you described, then you are wishing your python script to query endpoint of your flask web app in JSON format, so that it would be in JSON format inserted into flask, then this data inside flask would be used to send some SQL queries into database
yes, the py script scrapes some data using selenium and that data then gets inserted into my db ( sqlalchemy)
Do you know how to set this up?
well, i have literally project that as one of its part does that
i did not attach selenium module yet though
scraps with only other means fo rnow only
i had code for selenium scrapping too, but did not refactor into my 2.0 version yet
https://github.com/darklab8/darklab_darkbot/tree/master/scrappy scrappy microservice
module bases for example, it has auto launched task to update db from time to time.
deployment involves miriads of tools solving different kind of tasks. docker->docker-compose is a good entry technology giving biggest initial boost with relatively smallest effort.
Well, as possible alternative start, you can also use Ansible. This technology synergies with Docker to yield more powerful C-c-combo! I think you should better use docker-compose alone though.
What?
Selenium is browser driver
there was a hidden dm msg from him, my answer was to it:
[8:08 PM]
hey man
[8:08 PM]
do you have some resourcess regarding deployment ?
[8:09 PM]
I can't get it to work with DigitalOcean :/
Also, selenium works in headless (in background without GUI) mode pretty much fine from within containers. (chrome fits into containers too)
alright I have a read, thank you! ( sry for dm)
I know. My point is, Ansible is 100% different from Selenium. You might as well be talking Apples and Paint
he asked question with what to deploy it to DigitalOcean
Docker-compose and Ansible are both fine starting options to deploy it into DigitalOcean
Just docker compose and some scripts. Ansible is for when you get a fleet of stuff and even then, Kubernetes might be better option vs Ansible
can't really argue with that, but Ansible is still kind of experience that should be tried before Kubernetes.
Ansible/Salt are all to explore automation of Linux to final stage while remaining still in Linux. It is still same abstraction level.
Kubernetes is abstraction a level ahead of it
People should understand Linux to full capacity before jumping to layer on top of it
for deeper understanding of processes
it is like recommending to learn raw SQL before jumping to full ORM
Linux is raw SQL, Kubernetes is ORM.
Ansible isn't required to learn Linux
some configuration management tool is required in order to learn how to automate Linux.
You are like saying, learn RAW SQL so you can do Graph Database
No, you write scripts. Watch bash #!/bin/sh echo "Hello"
Since most configuration in Linux is just installing a few packages
bash scripts are reaching quickly maximum to their scalability in terms of code growth. I would say they reach it when code is more than oneliner.
even scripts in python reach it quickly too for installation purposes. as makefile they work nicely though.
Better to use language/ecosystems meant for configuration management. Because they scale for stuff bigger than 5-10 commands. Plus soo much of reusable stuff in this ecosystem 🙂
For docker, most of time you just your configuration management is just "install docker"
Ansible is fine if you are old school and running large fleet of Linux machines but it's not required for most modern setups esp on Public Clouds
It is not required, but it is important learning experience. ¯_(ツ)_/¯
and thus learning Ansible isn't required. And if they are running Kubernetes, they have management layer that's not Ansible
if I host a flask app, the app "runs" all the time right?
so If I would put a "sleep(24h)" in a while loop it would run once through the loop each 24h right? 😄
as i said i disagree. Because they are skipping important step in between being learnt and less aware of how system works and can be automated.
so learn Linux, Learn Docker, then decide if you want to learn more Linux management using Chef/Puppet/Ansible/SaltStalk or learn Kubernetes or learn a public cloud
you automate if you are running some massive fleet on Linux Machines with alot of people desperately don't want to do. See Kubernetes
i am using kubernetes as main infrastructure deployment tool and pretty much aware of its advantages, but even with it you would wish to have Ansible or its alternative at your disposal.
What is going to install Kubernetes for your Homelab and CI/CD, if you don't have means to pay for managed kuberentes costing 80$ per month just to spin up its bare minimum at AWS
I know plenty of groups running Linux VMs without Ansible at all. They use Azure/AWS script injection to set config script at start up time
you write a quick script to do it, copy to boxes and run it. Ansible is needed is when you have possibility of config drift or massive fleet of machines
i think u a just config management hater for some reason. somewhere at the point in your life config management tools definitely maimed your soul.
you can't see its advantage to have more scalable and more maintanable code with config management. Scripts have limit they can cut.
I have busted Powershell script to run/install microk8s on some Ubuntu boxes
Yes, the former Sysadmin/Exchange Engineer of 70k mailboxes and now Sr DevOps/Platform Architect has no idea why you would use Configuration Management. That Rabbit guy is completely clueless or he's really good at seeing trends and Ansible is not modern future.
and as i mentioned, i said already that Ansible(and other config management tools) is not really required after jumping to kubernetes. But I will stand on it being important learning experience before jumping to layer of abstraction higher. Because developer needs to be aware of all posibilities, tools to have at his disposal. Understanding better processes in between.
Will it die off? of course not, old stuff never dies. Is it modern future people need to know? Not unless Linux Sysadmin is in your future.
Learning Linux -> Learning Docker -> Learning Kubernetes 🤮 is better future
Ergh. At some point people would be going straight Docker -> Kubernetes experience, and will be even less aware how Linux works. Sure this is what for technologies advance, to simplify things further. But at this point of state, i think knowing systems working under hood is better to find simple solutions easier.
Linux is useful because most people will need to manipulate Linux in docker. Just moving stuff around like moving node dist output into root and such
The problem with all of it is kind of similar to how stuff in python works and Data Structure and Algorithm displine (if to give alternative analogy). Do you need to know how under hood array, dictionaries work at memory level to write some stuff? or even how it is turned into assembler commands and scheduled into chain of commands to be executed at CPU processor?
Surely you don't need. But each additional piece of knowledge for underlaying technology underneath it, makes your understanding deeper, allowing more performance optimization at conscious level performed ¯_(ツ)_/¯
If you want but time is finite so at some point you leave the details to someone else.
can't disagree with that. But quite often this approach yields good results to me.
At least before jumping to Frontend framework technologies, i made sure to learn as much as possible of old school HTML, CSS, vanilla JS, browser API posibilities.
It served me well, seeing through frontend framework syntax sugar and seeking features i knew there should be reimplementing some technology, or seeing that this technology was not implemented in frontend framework at all.
Learning basics/fundamentals leads to better awareness of what is going on.
If you don't need docker then just set up a cron job to run the scraper... That's about it unless there is more to your question?
yeah I struggle in general to deploy this to DigitalOcean 😄
do you have a documentation / tutorial on how to do so?
The official Flask documentation only covers other Services ( google,aws,heroku)
This looks like it covers the basic deployment steps https://dev.to/ajot/how-to-deploy-a-flask-app-to-digital-oceans-app-platform-goc
I recently went through the process to put my side project howbigisthebaby.io on Digital Ocean's new...
thx, in the last step they want you to put "5. Edit the run command to this - gunicorn --worker-tmp-dir /dev/shm app:app"
But DigitalOcean only acceps these varibales as Key:Value pairs.
Do you know what I need to write then?
is it py key : gunicorn value : --worker-tmp-dir /dev/shm app:app
- I deployed it without that variable and got an "install package error: "greenlet".. any idea 😄
I doubt that's right but really have no idea how DO handles this, sorry! Hopefully someone else will chime in
The point of docker compose to simplify deploying process to one command docker-compose up 🙂
Easily replicable deployment to Dev and Prod
Hi, I have a problem creating a PIP package for a project with Cython, which is described here: https://stackoverflow.com/questions/73766918/creating-python-package-which-uses-cython-valueerror
this is quite urgent, so please have a look 🙂
is it possible/how do you use pip to install a package as a command, as in, make a folder in /usr/local chmod +x a file and add the folder to the PATH
adding the folder to PATH is not something will do (it will warn you that it's not on the PATH though)
as for installing the commands for a package, that's controlled by the entry_scripts of a package
okay i think i kinda get it https://packaging.python.org/en/latest/specifications/entry-points/ is the new replacement for https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-scripts-keyword-argument
Should my pre-commit with isort, black, etc. only check for errors or also fix them?
As in, should I run these tools with —check in pre-commit or not.
Hi all, following some articles in CircleCI to integrate into my project, but it seems that they always use another docker image from circleci to build and run tests. Why wouldn't they build from your own DockerFile? Does your DockerFile only matter for deployment to the VPS?
just check for errors imo
Question: Is it possible to iterate through a directory of files, consider them python files and attempt to call a static function within them(assuming they have that function)
Technically yes
Practically it is sounding as potential bad decisions
You can use glob.glob("*.py"), then importlib.import_module(file[:-3])
assuming it's in the path.
Does PDM allow you to install different python versions? I've got package installation down but I'm struggling with sorting out how to use it to install versions of python.
pdm doesn't handle installing python itself, just packages. use pyenv or asdf-vm or python-build to install separate python versions. sometimes your system package manager will also provide specific python versions, usually with a suffix like python-310 or python@3.10
so you would first install your desired version of python using whatever tool makes sense. then you would use that version of python to install pdm.
Thank you very much
It's a blender generation thing
Basicially, I am generating python scripts to import materials and generate the node graph
And I have one master script that needs call them
Does anyobody know how to generate files in a repo from CI ? I am basically looking to integrate terraform-docs within my CI for it to generate the readme file.
What I am thinking is to .gitignore the README.md and generate it within the pull request but I am not sure if this it the right approach 🤔
If created a docker container with my flask app now.
How do I deploy this now to digitalOcean? 😄
( and I bought a domain :P)
Really new to the entire deploy / server stuff, but got told using docker is best
So I followed a tutorial, and the docker runs fine in the console on the droplet, but wen I open the ipv4 + port address I get " site took to long to respond" ..?? help pls
I haven't used DO but my first thought is networking stuff. Do you have to open the port on a firewall, etc.
I would also check the logs on your docker container to see if your requests are getting through and if there's an error
If it is Ubuntu, u could be tempted having adjusted or disabled ufw
Actually just debug access to service locally with curl
curl http://localhost:port/
Hey yeah, I actually got it to work now. Still not sure whats going on tbh
why tf does codecov/patch action keep on failing?
https://github.com/demberto/PyFLP/blob/master/.github/workflows/ci.yml
this is my workflow file
I accidentally committed (only locally) a file I shouldn't have (a database). What's the easiest way to fix that? My desired state is the same commit except this file should be in .gitignore.
git rm --cached some.db
# make the changes in .gitignore
git add .gitignore
git commit --amend --no-edit
Oh hey, that works, nice! I thought I'd have to roll something back, didn't realise you could just remove the file from being indexed.
to be clear, git commit --amend essentially splits off a new commit in the commit graph. the old commit is left there, but without anything pointing to it (no branch or tag), so it will eventually be expired from the reflog and finally "garbage collected" by the git engine.
let's say you have a commit history starting with A, and you make a bad commit X:
A ← B ← C ← D ← X (branch:main)
when you run git commit --amend, you make a new commit Y
A ← B ← C ← D ← Z
︎︎↖ Y (branch:main)
and basically leave the old commit X without any branch attached to it
so this does roll back in the sense that you are making a new commit with the changes rolled back, and then rewriting history
Hey @edgy tapir!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
My flask webapp project :
~/ProjectFolder
| --Dockerfile
| --app.py
| --scrape_data.py
| --chromedriver.exe
| __/.venv
| __/my_project
| -- __init__.py
| -- models.py
| -- forms.py
| -- db_connector.py
| -- database.db
| __/routes
| -- allmyroutes
| __/static
| -- allmycss/stuff
| __/templates
| -- allmyrtemplates
The "scrape_data.py" scrapes a site using selenium and calls a "write_to_db" class in "db_connector" => send data to db
I now want to add a cronjob which runs "scrape_data.py"every 24h.
But I don't know how to get this done.
For deployment I am using DigitalOcean 1-click Docker App
Thanks in advance
Dockerfile:
FROM python:3.8-slim-buster
COPY . /app
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
ENV FLASK_APP=app.py
ENV FLASK_ENV=development
EXPOSE 5000
COPY . .
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
Un, not that familiar with that. It sort of seems to me like docker containers are intended to be more ephemeral
A good survey of the different approaches to cron + docker https://www.howtogeek.com/devops/how-to-use-cron-with-your-docker-containers/
K8s has better cron jobs
@indigo zenith @gentle solstice there is also in python cron solution, hooking yourself to Celery beat periodic executed tasks. (Side car container for celery beat producer and worker are added)
And apscheduler
Anyone here with AWS EC2 experience?
A guide for how to ask good questions in our community.
Hey guys I want to learn GCP is there any course you guys can recommend for someone who doesn't have any prior experience on neither cloud nor GCP..
have you checked https://cloud.google.com/training#learning-paths ?
better to ask your specific question than asking if there's an expert
It’s a VM, what is there to know?
I want to create an EC2 using my own iso
im using cibw to build a package and everything builds properly, but the job fails because a single linux_x86_64 wheel gets built as well
any ideas?
How can I do that?
You will have to make a custom image and upload it.
It’s pretty advanced, documentation is best source
Recently I engaged in a project to make a bot for a game, but I got in a problem that I can't solve: every time I read the game screen, the game closes (possibly the anti-cheat crashing the game), do you guys recommend anything that I can do to read the game screen without being detected?
could you elaborate?
is packaging on topic in here? like setuptools distutils etc?
Hey guys, I need a help ! How to switch to master branch in Git Bash ?
git switch master
# or for older versions
git checkout master
i build wheels for every platform properly, but then pypi returns 400 because a linux wheel is uploaded as well
Thank god codecov does merge my coverage reports automatically
So I have this docker-compose file that runs a reverse proxy (nginx proxy manager). I'm just wondering how I should handle adding a new app to my website. E.g: I'm making a clock app that tells the current time that will be hosted at clock.mydomain.com. So I will config the reverse proxy to route requests to that domain to point to my clock app running in another docker container. Can / should I add the clock as a service to the same docker-compose? If I have other services running as part of the compose, can I make changes to one service without interrupting the others? Or Would I need separate docker-compose files to to that?
Example: I have the proxy manager and clock app running from one docker-compose, but then I want to add a third app / service. Will adding a new service disrupt the other 2 if they are in the same docker-compose file?
I recommend having all containers of one microservice in one docker compose
If they are Frontend and Backend as separate entities (and makes sense to have separate Deployment cycle), keep them in different docker composes and join with same named docker network.
That makes sense, each app would be a completely different, not sharing databases or anything
Usually if adding service to same compose assumes u will relaunch them together
For more advanced zero down time deployment, people use container orchestration systems like kubernetes. It has multiple abstractions on top of containers and their fleets. Easily deploying across servers becomes possible, and load balancing
Each service will depends on the proxy manager being up. But besides that, there will be no reliance on other apps, so optimally I could stop or delete an app without effecting other things
I have heard the name, but I'm still figuring out docker haha
https://github.com/darklab8/darklab_darkbot
Yeah, I do same. This repo has 4-5 microservices. Same amount of composes
I joined composes into one network nevertheless
For easier communications between services in different composes. Wishing to keep DNS name resolving, instead of using IP addresses
Yeah I went with this approach too yml networks: default: name: scrappy external: true Because I'm using the proxy manager, I'm putting everything on the same network as that so that I can simply route things to http://clock:8080 since they are all on the same bridge network
Hmm Can someone spot the problem here?
Oh I think I need to use the dockerfile directive
got it ```yml
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
networks:
default:
name: bridge
I work out of dev_script.py and as things progress move functions/code to relevant files
But I always find I end up jumping through a bunch of hoops to import things correctly
especially if package/ isn't a top level folder in the project, but is a subfolder somewhere. then I have a bunch of things like import py.src.package.module
Maybe directory layout is not the problem and I should be using some other pattern to do active development
sometimes I follow a similar pattern, calling individual bits of code from a git-ignored dev.py module
in most cases, I just place the code where I think it should be, and let pycharm import it for me
Don't create unneeded hierarchies. Try to keep all your modules in a single folder if possible
Hell I put my outermost public API (2 functions) in __init__.py to avoid creating another module and init.py remains almost empty anyways
as long as you import it into __init__ to make it available
has anyone experiences with running selenium webdriver on an ubuntu server? (flask app)
Locally it works fine but on server I get "No chrome executable found on path" error.
If you're on a newer version of Ubuntu look for newer instructions
u a supposed to install chrome to server 
which is possible at least like this
apt update
apt install -y wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb; exit 0
apt-get -y -f install
may be in other commands too
Hi guys, I want to create a dev environment using proxmox. What I mean is I want to use visual studio code -> connect to a LXC container and create dev environment where I install the python3.7 or 3.10. I hate fighting with dependencies on my windows machine. Install npm, and many more stuff.. sorry i'm all over the place.
That's good... WSL2 is also good. And if you use Docker, I like this: https://hub.docker.com/r/linuxserver/rdesktop
WSL2 is probably where I'd begin though, it's pretty quick and simple to set up
i just use CLI Interface of docker-compose to have raised container that grabs current project folder as volume inside for hot reloading
and then connect into it with VSCode plugin for remote container connection
hm can't do that.
Since its a webapp, and not a vm, I can't log in a root user :/
What? U aren't root of your own Dev machine? 
digital Ocean forum:
App platform is a managed way to host applications – you give the location of your git repository or container image, and it deploys the app for you. You can configure features like custom domain names through the console after deploying your app. It’s unlike a droplet (https://cloud.digitalocean.com/droplets) which give you your own virtual machine. There isn’t a way to log into app platform, since it’s not a VM ```
This shit can ran docker containers
just put chrome into your docker container
is chrome = chromedriver.exe ?
no. Chrome is browser
Chromedriver its puppetmaster to control installed Chrome
Selenium is library to control Chromedriver
Chrome has its own chrome.exe
I'm learning about pyproject.toml and on PEP 518 https://peps.python.org/pep-0518/ it is said that pyproject.toml specifies "build system requirements" to "build" the project. What does it mean by "build"? I thought python was interpreted, not compiled.
have you ever installed a package using pip install?
and @indigo zenith thanks for the suggestions. I ended up re-using an old laptop, installed Proxmox, setup lightweight Alpine LXC containers or VMs
Do I need to put the google-analytic tag in every page, or is it fine if I put it into my base template ?
obviously, just add to some shared template between them xD
it is same code for all pages anyway
u would be breaking DRY principles and going WET otherwise
yeah I thought so to... was just wondering why Im not seing anything yet. Probably just takes some time
I am trying to run a github actions manually and for whatever reason when I try to run it seems like its not running at all and does nothing. I dont see a failure a started or anything.
this is my first time writing a github actions script
here is the github actions that I am using
name: Compile GUI for Ubuntu
# run this job manually
on: workflow_dispatch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# used to checkout different branches
- uses: actions/checkout@v3
with:
# checkout my specific branch
ref: main
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: pip install dependencies
run: pip install -r requirements.txt
- name: compile with pyinstaller
cd ./src/python/
python -m eel gui_main.py ../web --onefile --noconsole --clean```
I basically want to a github action that I can manually trigger that uses the code that I have in the main branch to compile the python code and then push the compiled executable to a new branch called executables
feel free to @ me
Maybe the line endings (lf vs crlf)
right
I think that is indicating a trailing newline was added. Not the same thing as the line endings I mentioned earlier.
whats the cleanest way to push from a github actions bot to another branch?
I have been seeing people say do things such as
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"```
I am wondering if there is a clean way to do it like
git config user.email "${ github_actions_bot_email }"
git config user.name "github-actions[bot]"```
found it!
it was git config user.name github-actions git config user.email github-actions@github.com
i am having an issue with pipenv. I need to update one library
if i update with pipenv update lib it updates so many libs, that it breaks tests
if i update with pipenv update lib --keep-outdated it is not updating the necessary lib, it only updates some libs around (much fewer)
how to update my lib only more reliably with pipenv?
nvm, found very useful thread
Hi,
RE: Python Sphinx Documentation
Is there a way to have the github external source code embeded in a sphinx page?
# This works but needs the file locally or relative to the source. I don't want that
.. literalinclude:: example.py
# I want something like this (i.e. external link but this does not work despite it being just a .py file)
.. literalinclude:: https://raw.githubusercontent.com/bentraje/blender-python/master/animation-rigging/constraint_param_from_armature_export.py
I already tried adding 'sphinx.ext.linkcode', 'sphinx.ext.viewcode' in the config file but it still does not display the code.
P.S. posted this on the available help channel but unfortunately didn't receive anyreply 😦
I don't expect this to ever work as expected, given how tangled up this code is. I moved on to poetry ages ago, primarily because of this.
https://github.com/pypa/pipenv/issues/2412#issuecomment-988588499 🗿
🤣 I am still trying to upgrade one library
Already even tried deleting
It keeps records in changed state lock
have you tried... not using pipenv 
Legacy. Not my choice
couldn't you update the version spec in the Pipfile and then try pipfile lock or something?
or does that update the versions for the others as well?
hmm. it will I guess 
I am fan of pip install -r requirements.txt -c constraints.txt -r requirements.dev.txt to be honest. Together with docker for Dev env it is all I usually need
I have used pipenv only once for cdktf and it was not pleasant
Well. In Pipfile it is already having lock >=1.16 which is supposed to be sufficient for updating it to latest
Lock is good idea though, I remember there is mentioned in one of projects docks regenerative command
It should be probably this to bypass this
i've found that generating a requirements file is sometimes not that straightforward
it's not (yet) possible to incorporate a constraints file when generating a requirements file, unless you literally insert -c in the requirements.in file, which isn't possible when using pyproject.toml. so it's entirely possible to generate a requirements file that does not meet the constraints!
i auto generate constraints.txt with pip freeze, while filling requirements file manually with top level dependencies
and technically it is possible to incorporate constraints file
u mentioned -c correctly
you can't do that in pyproject.toml
my projects are docker web projects, not an issue
so you need to first extract the pyproject deps and all the extras to a temporary requirements.in file, insert -c at the top, and run pip-compile on that. messy
would be great if pip-compile had a -c option itself
Eventually resolved my dependencies
with making rule for deps version only of one blocking to upgrade library
and upgraded everything forward according to available rules
Kind of good in some sense tool, because it forces to move u forward xD
I was looking around to find tools that would scan and analyze your Python code to possibly find bugs or security issues, right now I've come across Amazon CodeGuru and SonarQube, but these are some bigger enterprise tools whereas I was looking for something preferably open-source. Anyone know of any?
I'm already using black, isort, and flake8 for formatting, import sorting, and general linting, but figured finding bugs and/or security issues would be helpful on top of that
try mypy/pyright
!pypi bandit
!pypi safety
I did just come across safety, going to have to add all of these to my pre-commit and GH Actions workflows
Thanks, guys!
There is a whole list there: https://owasp.org/www-community/Source_Code_Analysis_Tools
Personally, I like semgrep
If you are using vscode, pyright is built right into it. And mypy is a bit of a mess to put it nicely
Doesn't Dependabot do this already?
Afaik most services like codacy codefactor just run pylint and a bunch of tools you already know to gather "metrics" and "insights"
yes, but many people don't use GH
so they can't use that
Many people don't use GH?
I haven't seriously found a project from pypi taking me to gitlab or something since like eternity
think private projects that are hosted in on-prem/private GitLab
So why does sphinx autosummary not add module level docstrings in the table it generates?
where can i ask about making bots
because all the "auto" stuff in sphinx in general is kind of tacked-on, it's really meant for hand-crafted docs
i was just wrestling with autosummary last night, :recursive: didn't appear to have any effect and i couldn't figure out why
apparently there's a sphinx extension to generate epydoc-like api reference pages, i would love that
it can be achieve with a template
although i believe autogenerated is too much control lost for smaller apis
I dimly recall reading something that made me eager to revisit Sphinx -- https://hynek.me/articles/productive-fruit-fly-programmer/
Not sure that addresses what you mentioned, but it's probably worth a glance
yeah i actually kind of love/hate sphinx and restructuredtext.
I've never used 'em in anger
love because of what it can do, but hate because of how clunky and awkward it sometimes can be
i think the sphinx user experience has improved a lot recently
it's still a little awkward to use a python script to generate a makefile, but the file itself is small and readable and easy to customize
plus sphinx-build i think now does its own "make-like" thing where it doesn't rebuild unchanged pages
and some of the HTML themes are pretty good
in hindsight, we probably should have been writing docstrings in sgml. but failing that, the real killer feature of rst and docutils is the ability to define your own semantic markup directives, and sphinx includes a huge amount of useful directives built right in
the only reason that sgml/xml would be preferable to rst is that you can arbitrarily nest tags in sgml/xml, but rst syntax is fairly "non-composable" (e.g. you can't easily apply bold or code formatting to the text of a hyperlink). whereas most markdown implementations do a pretty good job of this
I don't think I've ever seen SGML used anywhere in the last 20 years
if I had to write SGML I'd complain
there are some documentation tools based on it, although idk if they're in wide use
it's literally markup language, i hate that it and its descendents were co-opted for serializing structured data
that too
in his defense Tim Bray is a wonderful writer and blogger 🤣 (he invented XML)
cool, i haven't read anything of his
i mean okay... the closing </ thing is kind of annoying
def add(x: float, y: float) -> float:
"""Add two numbers.
<param name='x'>First number.</param>
<param name='y'>Second number.</param>
<return>A number.</return>
<example>
add(1, 2)
<example>
"""
aren't they technically optional in sgml?
def add(x: float, y: float) -> float:
"""Add two numbers.
:param x: First number.
:param y: Second number.
:return: A number.
.. code-block::
add(1, 2)
"""
the rst is definitely cleaner-looking
but you basically can't do that with markdown at all, there's no option for adding your own semantic directives
honestly I wouldn't write that sort of documentation unless there were a gun to my head
afaict, there's never any mechanism to ensure it stays accurate, hence nobody maintains it, hence it's wrong, hence I never even bother reading it
doctest is the only per-function doc I'll write, for exactly that reason
Reference docs are really useful for onboarding people into using your library/tool. Look at something like FastAPI, the lack of reference documentation can be quite annoying. This is the only nice way to do comprehensiveish reference documentation
Docs written by a non-dev of the project are generally better imo
wouldn't surprise me
they'll make fewer assumptions
and will ask obvious but important questions like "yeah, OK, but that problem does this function solve?"
agree - for the project I've actually found them useful, they're more marketing than they are anything else
people maintain it if it's a required part of code review
bad docs are entirely a cultural problem
imagine trying to use pandas or numpy without per-function reference docs
indeed
my gripes are around internal tools, not third-party libraries
the latter have good docs almost by defintion: if they didn't, I wouldn't use them 🙂
somehow I feel like drawing @dry hatch 's attention to this discussion
hi, do you guys know free cloud servers?
How do I fix "Something went wrong. Please restart WSL with the following command and try again..." for Ubuntu Terminal 20.04 LTS