#tools-and-devops
1 messages Β· Page 12 of 1
I'm not sure what this section is trying to explain then
That you can use a context manager to automatically remove the temp file when you exit it
hi everyone is there anyone who have experience in maya Python Scripting or mel? i need some small help.
whats up
very nice
keep up
I'm new to git and I'm trying to reset back to an old commti (just learned that revert doesnt work like that). When I reset things work but it's only locally- how would I push those to the main branch? I can't stage commit push as I have some conflicts and I don't think it works like that in general.
i hope you are single contributor to this branch
in this case you can always git push --force-with-lease
in order to overwrite history
if u aren't single contributor, don't do it. main/master branch is supposed to be not overwritten in its commits
git revert commit is only allowed in them with working in collaboration with others
u are allowed overwriting history in feature branches u own only (if working in collaboration)
im the only contributor i only use this repo to backup my notes
"fatal: The current branch main has no upstream branch."
okay, then it is legit
write answer of git remote -v
origin https://github.com/mygithub/repo.git (fetch)
origin https://github.com/mygithub/repo.git (push)
write answer of git status ? π€
write answer of git status when u encounter your problem
or this problem "fatal: The current branch main has no upstream branch."
copy answers ^_^ git already highly likely told you how to fix this error
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
π€ your git repository manages to tell that u don't have main branch yet
do you not have main branch remotely?
did u push repository to remote before?
what is default branch? is it master or main
also, how can u created this git repository π was it created manually via git init, or you git cloned it from remote
it's main
i made a repo in a folder then moved the .git files into my note taking app folder (obsidian)
cause i followed a tutorial
how did you made a repo in folder
So, what can u see if you photo your remote GUI?
https://github.com/mygithub/repo.git what this address shows in GUI? by default?
can u show more precisely π
do you wish to overwrite/delete it completely with new git repo state?
nah i have the id of an old commit from yesterday. i want to just take that commit and make that my new main branch
so yeah i think thats what you mean
nah i have the id of an old commit from yesterday.
failed to comprehend this sentence
I made a commit yesterday (which didnt have conflicts) and i want to revert all changes i made since that commit yesterday. so i essentially want to remove the current files and replace them with the ones from the commit yesterday
anyway, looks like u wish to overwrite remote completely with your new local state created via git init to remote
deleting remote completely and overwriting with your current local state, correct?
yes
okay, then just use git push --force --set-upstream origin main
error: failed to push some refs to 'https://github.com/stillmygithub/myreposname.git'
when i use that command
π€ lazy to create repository replicating this situation
git push --delete origin/main ?
ahh i get what you mean i dont have a repo with the old commit
yeah, u have different initial commit starting your tree
thanks for the help man i got to go sleep or i will be dead tomorrow. hope i figure it out. have a good night!
u can always just delete your repository remotely and create new one with empty state (no license or readme! or anything)
then u will be able to push git push --set-upstream origin main
does anybody here know about using printers with python and could maybe help me? I need to be able to print a pdf (or postscript) from a printer and configure the settings for the print without admin permissions. Basically what word does when you wanna print a file. How can I do that? I have the win32print library but I can't figure out how to do it without admin perms since the only way i found it works is with "SetPrinter". I would really appreciate any help!! Sitting on this problem for a while already and can't find anything
cant give specific advice for fly.io. But looks like there is either no virtual environment with gunicorn installed and/or its not activated in your terminal session
you might run a pip freeze there to check if its there
I was able to get it running now. They allow us to define our Docker image and deploy the docker image instead
hi! for create libraries what do you recommend? poetry, hatch, pdm?
i strongly suggest specifying your dependencies in a requirements.in file and using pip-compile to generate a "locked" requirements file from that: https://pypi.org/project/pip-tools/
(note: you should run pip-compile inside the docker image to ensure that the platform and os specifics are reflected correctly)
I've deployed several projects to Fly and any time I have tried to use their magic configurations for common stacks (like Gunicorn + Flask) I regret it. I think using your Dockerfile is better long-term anyways.
If I currently use and understand Poetry, do you think I should check this out?
no need, poetry will do it with poetry export
i personally use hatch because i like it, but a lot of people use poetry and some people use pdm, they are all "good"
Cool, I really need to dig into Poetry and learn more of the depth of the tool. Thank you for the nudge. I agree, pinning and locking dependencies is a good pattern, even for solo projects.
thanks for your answer, i'll continue my research, but hatch has one vote π
i think poetry might have more features included
hatch feels a bit like a "WIP" project still
and some things like exporting a locked requirements.txt requires extra work, whereas it's just included in poetry
it has more things built in, which might be equivalent to easier
Poetry is what we use at our company. It works well, but I'm a super shallow user.
i need to create a simple library for internal use so i need something to create that in very little time
i will research peotry
poetry*
thanks!!!
I use poetry all the time and recommend it, fwiw
for the various libraries ive written, pip + setuptools is pretty easy to use especially with recent improvements like better dependency resolution and adoption of the pyproject.toml standard, though that's not to say i disapprove of the other options
for example, here's the minimum needed to make a package installable: ```toml
my_package/
init.py
...
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "my-package"
version = "1.0.0"
dependencies = ["click>=8.1.7", ...]
Installing for development: pip install --editable .``` see also setuptools quickstart, package discovery, and MANIFEST.in if you use data files
to be fair you still need a separate tool for managing virtual environments (venv), and if it's going on a package index you also want to build distribution files (build) and upload those distributions (twine or ci/cd like trusted publishing), so the convenience of one tool might be an easier choice for you
Is anyone using VSCode Devcontainers with Python?
i do, dont ask to ask though, just ask
I already asked 2 times the Help channel and they both got closed without answers. Just trying to understand where can I get some help about VSCode Devcontainer and Python
here is a good enough place, this channel is for containers and other stuff
if nobody answers -> then may be your question is not providing all necessary info, or having overly specific problem nobody dealt with, or 100 other reasons why it could be happening
based on you still not asking the question, i predict problem with formulating your question π
anyway, just ask your question already. not really able to help with current amount of provided information (or lack of it)
I'm trying to make a simple Devcontainer with only Pylint and Black formatter, but for some reason I can not get the formatter to trigger manually or on save. https://gist.github.com/ivoencarnacao/b748bb96ff75d67eb62240b4ff149a90 ps. Thanks for the patience with me!
There's a reason we stop that link from being posted. Do not bypass our filters.
What do you mean?
π okay. linking this server analog should work too
it looks like we are using Dev containers in entirely different ways π€
my usage did not require this config
may be we aren't even using same plugin
could u show your plugin icon and name?
I tried with flake8 and autopep8, neither did format manually or on save.
Pylint, works though
could u show your plugin icon and name?
and may be describing how u launch it
i mean plugin of devcontainer
Sorry, I don't understand what you mean!
you say u use dev containers with vscode
I assume it is plugin (and i think it is plugin different from the one i use)
could u show which plugin do u use for this service
I think we're talking different things
well, can't say for sure since u don't link (or screenshot) what u use.
This is what I use. https://code.visualstudio.com/docs/devcontainers/tutorial
I already pasted the gist with what I use.
Yeah, we use same plugin
I just use it differently
never made devcontainer.json
i used docker-compose to raise my containers each time and connected directly π€
nevertheless fun feature to try i guess π€
i have some question if i can define different containers though
hmm...
no, docker-compose is more reliable and IDE cross platform
not going to make dependency on obscure IDE plugin configuration
Guys has anyone ever faced this issue when building a ci/cd pipeline in azure app service using GitHub actions. IT was working before but its saying ive hit the artifactsΒ quota. I already implmeneted some solutions in some stack overflow posts like including a step to delete the artifacts and setting the log retension period to 1 day. The delete artifacts step is not giving any errors, but this is still coming up
I have a GitHub workflow in which mypy tests fail on the Windows part of the project.
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
name: Mypy
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Install Dependencies
run: |
pip install mypy
- name: mypy
run: |
mypy slodon/
it's because of the line runs-on: ubuntu-latest, what is the best of fixing this error?
Should I just change the run according to the system?
run: | mypy slodon/windows
run: | mypy slodon/linux?
maybe you would want to do that
maybe?
yeah, i am not too experienced with github workflow configs. but this is something i will do . if you are trying to run it for both windows and linux, just define 2 files
I'm kind of looking for a better solution, or an acceptance from someone.
Hi, I'm trying to merge and I got some conflicts and since they are determined to be complex I cant resolve them thru the web editor. The problem is that I can't re-produce it like I can't get to the point in my local vscode environment where I could see my merge conflicts and I'd be able to resolve them, how can I reproduct the conflicts locally so I can solve them.
ensure that your two local branches are at the same commits as the branches you were originally trying to merge.
The problem is that I just wanna get to the stage where I can possibly fix the merge conflicts, because I can't do it in the webeditor on github because it is too complicated, so how do I get the conflicts locally so that I can actually see what I have to fix?
Solved it now
thanks
Now I merged it btw, but something's wrong with mypy, It just doesnt show up for some reason.
name: Mypy
on: [push, pull_request]
jobs:
linux:
runs-on: ubuntu-latest
name: Mypy-linux
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Install Dependencies
run: |
pip install mypy
- name: mypy
run: |
mypy slodon/slodonix/slodonix/exceptions
mypy slodon/slodonix/systems/wayland
mypy slodon/slodonix/slodonix/slodonix_wayland.py
mypy slodon/slodonix/systems/x
mypy slodon/slodonix/slodonix/slodonix_x.py
mypy slodon/slodonix/slodonix/tween.py
windows:
runs-on: windows-latest
name: Mypy-windows
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Install Dependencies
run: |
pip install mypy
- name: mypy
run: |
mypy slodon/slodonix/slodonix/systems/windows
mypy slodon/slodonix/slodonix_windows.py
@thorny shell
err your windows job is indented inside the linux job
you can also look in the actions tab to see if github recognizes your workflow file but cant parse it
Arent they at the same level?
ohh wait
you're right
the joys of 2 space indentation
Yeah I wouldnt have noticed
Now they are both recognised, is there any way to make an if statement of smth?
im not sure what specifically you want a conditional for, but you probably want to look through the github docs
https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
or if you want the linux/windows job to run based on which files were changed, i'd probably separate them into two workflows and use the paths: option for the push/pull_request trigger types
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push ```yaml
on:
push:
paths:
- 'slodon/slodonix/slodonix/systems/windows/**'
- 'slodon/slodonix/slodonix/slodonix_windows.py'
jobs:
windows:
...``` (not entirely sure if the glob pattern in that example is correct)
I want to run the windows one whenever the os is windows and the linux one whenever it is linux.
.github/workflows/build_releases.yml line 164
if: matrix.info.os == 'windows-2019'```
The only project I know of that does it pulls the info from a matrix
You might be able to access that information from like the github context without a matrix
i was thinking of a matrix too, but im not sure how you'd use different commands for that mypy step, assuming the goal is to merge the two jobs into one
After a brief conversation, it appears that our specific goal is to execute Windows-specific modules on a Windows server, while the Wayland and X components can use the "Ubuntu-latest" environment.
(I'm working with him)
Yeah
If the workflows are going to diverge significantly, just make two different ones
But it is entirely possible to stick both OSes in a matrix, and then use if(s) to hide the ones you don't need
The problem now is that on the mypy-linux workflow for some reason I'm running the files that are specified in the mypy-windows workflow as well. Why?
im not sure why it checked the windows files, but apparently mypy can recognize platform assertions on a module level:
https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks
import sys
assert sys.platform != 'win32'
# The rest of this file doesn't apply to Windows.```
it might be easier to add those assertions and then have the workflow lint the entire package at once, then you don't need to update the workflow for new modules and you can use a matrix instead of OS-specific jobs
because sys.platform is a constant
is python version 3.11.5 is stable , iam developing a webapp in django
3 months ago libraries in general did not support 3.11 yet. Not recommending. 3.10 is more reliable
Is there any tool to test concurrent POST calls? I split terminal window to like 40 panes and sync typed POST command that way. But there must be a better way?
<@&831776746206265384> we have continued having FU problem for your awareness
the user had been banned some time ago fwiw
hi guys
not sure if this is the right channel to post this in but i'll go ahead
i'm converting a python project into an .exe file
for this purpose i'm using pyinstaller
however i get this error when i launch the exe
Traceback (most recent call last):
File "kiesel_gui.py", line 3, in <module>
import kiesel_simulator
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "kiesel_simulator.py", line 5, in <module>
import seasonality_builder as src
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "seasonality_builder.py", line 4, in <module>
import holidays
ModuleNotFoundError: No module named 'holidays'
i had the same problem with openpyxl (i'm using pandas in the py files) and i was able to solve it using a thread from stackoverflow
but for the holidays module there is no previous thread on the internet, can someone help me ?
this is the command that solved it for openpyxl
pyinstaller main.py --hidden-import openpyxl.cell._writer
Does this script work for you without pyinstaller?
Nice
Then probably pyinstaller doesn't support it. Don't know. Maybe you need to remove this package from your scrifor pyinstaller
scrifor ?
well i was thinking,
since i'm using a conda virtualenv with all my packages
isn't there a way to include all packages from the venv in pyinstaller ?
Don't know don't use pyinstaller that often . Actually used it once
Are there any other packages that you use for that script and they work?
if hidden import worked for openpyxl, does adding --hidden-import holidays work too?
@willow pagoda first thing i tried
and it failed
this is why i came here
ok we are getting somewhere
i tried another time
i placed myself in the anaconda env i used for this project
and ran my pyinstaller command
pyinstaller kiesel_gui.py --onefile --hidden-import openpyxl.cell._writer --hidden-import holidays -w
when i launch the exe
i get this error
i tried reproducing on linux using a tweaked version of their quickstart example and got the same No module named 'holidays.countries' error, and judging from their source code it seems to mostly be python modules and some locale data files so i went with --collect-all to bundle whatever was missing, now the script appears to run correctly py $ pyinstaller main.py --collect-all holidays ... $ ./dist/main/main date(2015, 1, 1) in us_holidays = True date(2015, 1, 2) in us_holidays = False us_holidays.get('2014-01-01') = "New Year's Day"
im not packaging the same code that you're running so it wouldnt make much sense to use your pyinstaller command
to this command
but try replacing the --hidden-import holidays with that
ok
ok i launched the command
brb
ok thank you, the gui launches now
the only pb is that it doesnt do the simulation i want it to do and there should be a matplotlib window popping when i press some button and it doesnt for some reason i dont know
maybe to debug i can take off the -w flag and have aterminal window to see the logs?
bro it's impossible to see the logs in a terminal... this thing driving me crazy
72046 INFO: Looking for dynamic libraries
C:\Users\ianne\anaconda3\envs\kiesel\Lib\site-packages\PyInstaller\building\build_main.py:194: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
__import__(package)
74755 INFO: Extra DLL search directories (AddDllDirectory): []
74755 INFO: Extra DLL search directories (PATH): []
80622 WARNING: Library not found: could not resolve 'impi.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_blacs_intelmpi_lp64.2.dll'.
80626 WARNING: Library not found: could not resolve 'sycl6.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\omptarget.sycl.wrap.dll'.
80626 WARNING: Library not found: could not resolve 'msmpi.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_blacs_msmpi_lp64.2.dll'.
80626 WARNING: Library not found: could not resolve 'impi.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_blacs_intelmpi_ilp64.2.dll'.
80626 WARNING: Library not found: could not resolve 'msmpi.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_blacs_msmpi_ilp64.2.dll'.
80626 WARNING: Library not found: could not resolve 'pgmath.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_pgi_thread.2.dll'.
80631 WARNING: Library not found: could not resolve 'pgc.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_pgi_thread.2.dll'.
80632 WARNING: Library not found: could not resolve 'pgf90.dll', dependency of 'C:\\Users\\ianne\\anaconda3\\envs\\kiesel\\Library\\bin\\mkl_pgi_thread.2.dll'
i noticed that in the logs of my pyinstaller command
maybe that's what makes my matplotlib button not run
Hey, I really want to get started with learning microservices and kubernetes . I've had decent amount of experience building applications using monolith or 3-tier architecture using python (django mostly with some fastapi), golang and a little typescript and have used docker as well. Could someone some good resources to get started?
Kubernetes recomendation is easy to give, here is a good book to jump start your experience
P.S. if u feel insufficient learning of docker, Docker Deep Dive book can fix it
as for architecture and microservices.
from your description i got a feeling of insufficiency to build monoliths at the necessary level yet.
Recommendation to read Clean Architecture first, in order to have better hang of structure manipulation at a single application
understanding better code gathering into reusable packages and structuring stuff in general
In order to utilize at full capacity, u need to use Golang.
Or if u want to try in python, Mypy in python in strict configuration can help, and usage of Pydantic + smth like Django Ninja/FastAPI
Best trying it in Golang first though, it is just far easier to do it there
Then u could read materials like From monolitoh to microservices and Building microservices
Microservices create additional problems (wormhole of addtional problems)... decreasing problems with code validation for correct cross service communications is a huge boon.
That is why recommended the stuff regarding tech i recommended
WARNING: Don't build microservices until u really learned to write scalable code of a monolith. Microservices create A LOT of additional problems.
P.s. I hope u learned unit testing to a good level π€ I can drop some books for that too
RE: Pipenv up-grade issues
Status: (Just a novice pipenv/virtual environment user) I've been using pipenv to manage a few project's dependencies the last year while diving deeper into Python. I was recently using a version of Pipenv for a few months, without upgrading it. All was fine. Then the other day I decided to up-graded Pipenv when my IDE wouldn't recognize new ve's that I created. After up-grading pipenv and dependencies and running pipenv install in a project created by an IDE I was presented with a long list of "issues" being displayed in my cmd window culminating in a permission error - not being allowed to access some postgres data files.
Question: I did not experience this issue weeks ago with the older version of pipenv when creating a new environment, why am I now presented with pipenv wanting access to postgres data files when to my knowledge access to some postgres files were not required previously?
Thanks for the help.
can't imagine that's anything to do with pipenv itself
I'd look carefully at the IDE
ahh.... not sure how an IDE effects installing a pipenv ve via pipenv install in a project other then the initial and un-populated project was created by the IDE, but it does appear that the sub-category of the IDE (Eclipse) hasn't been supported for about a year. You may be onto something though with your suggestion and I may now be faced with a bigger issue in the middle of a class that I'm trying to complete, switching IDEs. (pulls hair out meme)
in my experience, IDEs are more trouble than they're worth, unless you're using the same one every day
very very complex
it does seem that way especially for someone that isn't a systems expert and/or enjoy staying abreast of the whole dev environment.
how I recover/transition to another dev environment mid-educational class experience when I need to focus on some python libraries will be....
appreciate your attention
it doesn't help that VSC and Pycharm change notably as time passes π
presumably those changes are meant to be improvements, but they're disorienting
Can someone help me put my discord bot code from replit to put it in a vps, i bought a vps but idk how to put my code in
Which VPS did you buy?
hoping it's *nix and not Windows
Honestly I highly doubt they bought one as they instantly sent the message
Can't purchase a VPS in ~15 seconds lol
with lightsail, it's not out of the question
Can't you?
For a beginner who had no clue what a VPS was I would say it's unlikely
clearly
I read a paragraph or two before scrolling back up to check the publication date
a topic that i am moving from #ot0-psvmβs-eternal-disapproval
that depends π both paths are available
- U can ask for client credit card
- u can charge client for money u spent on their server resources (putting this money into invoice to them)
That depends on
- Your hiring contract type, are you employee? Are you b2b enterpreneur? are you freelancer
if you are employee, first path i think is obligation
freelancer... both are usable paths
enterpreneur can utilize both paths too. Depends on his scale of entrereneurism and desired scope of services to provide
So for example... if in the end u are just full time working for someone, first path is prefered
if you are only providing services but not working for them, second path can be prefered (in order to make client more depended on you and providing more obfuscated end result, just giving end result, the working service)
We are just two friends trying to do some biz, and will do some biz in the future too, so yeah freelancer.
i would say for freelancers and enterpreneur, this is all depending on client requirements. I would not be closed to all options and may be even having for each client different way
Also that scale of entrepreneurism bar is pretty low because I hate tinkering with AWS billing, account managing, organization such so
so this is going to be a literal headache eh
if you are freelancer / enterpreneur, it is YOUR CHOICE which services to provide π
u just limit the scope of clients u agree to work with
and it is completely fine
ooooooooh that is sensible
i refuse to work for any money with NFT for example (even if offered 200% of current income)
yeah i can limit that too
like i can decide one principle, we are dumping aws bills on you sya
Freelancers /enterpreneurs can be having exactly presenting web sites that least services they can provide π
or they can just tell it during negotiation with clients, your choice
it is your responsiblity to extract requirements out of client
and to make client to agree to certain contract of what will be done and how much will be paid
yeah, unfortunately
i will dump all these talking parts to my friend
i hate any kind of client interaction and I didnt expect to have this many
for freelancers and enterpreneurs it comes by design (interacting with clients)
employees aren't really escaping this thing too btw, development is a team work.
Any dev from middle rank is expected to interact with other people and extract requirements (mostly from other devs)
i will dodge any role that requires human interaction in the future lmao
there is too much to unpack
thanks for all tips
PS C:\Users\Isteyak\Downloads> docker -v
Docker version 24.0.6, build ed223bc
PS C:\Users\Isteyak\Downloads> docker ps
error during connect: this error may indicate that the docker daemon is not running: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
PS C:\Users\Isteyak\Downloads> history
Id CommandLine
1 docker --start-service
2 cd Downloads
3 docker run hello-world
4 docker info
5 docker info
6 docker logs docker-desktop
7 docker logs docker-desktop
8 "Docker Desktop Installer.exe" install
9 "Docker Desktop Installer.exe" install
10 Start-Process 'Docker Desktop Installer.exe' -Wait install
11 start /w "" "Docker Desktop Installer.exe" install
12 start /w "" "Docker Desktop Installer.exe" install
13 docker run redis
14 docker -v
15 docker ps
no mattr wat i cant set up docker in my p
pc
Maybe uninstall it completely, restart PC, and then reinstall?
i can't recognize all commands, but just to be sure Docker Desktop application is supposed to be running during docker ps command
Is Docker running? In other words, do you see the whale in your system tray?
That's what I'm thinking of
Ye
So weird it works now still curious but don't have time to research on what really went on, Dockr app starts without err and Dockr PS command doesn't give err either
hey guys does can someone help me with tkinter?
I'm done with the introduction of python
and now I'm trying to implant a python project
but since I want to make a graphical interface for it
I need tkinter
but I'm getting overwhelmed with the concepts and subjects of tkinter
so i can use any help
I would try a tutorial or two to start, maybe like this https://realpython.com/python-gui-tkinter/
If you're still stuck share some of your existing code in a help channel #βο½how-to-get-help
Hi guys! Anyone here developing in VSCode using devcontainers? I'm trying to set up kind of a template project for an backend/API application. It been some time since i developed using Python so I could need some input on how to configure my dev environment correctly.
how do I reset the whole .git folder to its current state in the remote repository?
sudo rm -R project_folder ; git clone ssh_url π
if u want specific branch only git reset --hard origin/desired_branch to reset
WARNING: it will reset everything, files included
yeah somebody told me to avoid the reset command...
I tried to create a new branch from an old commit git checkout -b new_branch commit_hash but for some reason its content is not matching the content of that commit hash
not sure how I fix that
in fact its content is exactly the same as the latest commit from the branch of commit_hash
everything is good to use as long as u understand its dangers and when right to use π
it is really bad reseting branch used together with others to older commits
u should use only git revert in those situations
reseting is good only.. if u just reset local state to remote
or u reset your personal feature branches to older commits, then it is fine
thats fair, I'll try revert lets see how it goes
my github copilot subscription is not working as a student even though I have the student devleoper pack
does anyone have the same issue?
how do I set up venv in a devcontainer? should this be done in the Dockerfile or a post-script from the devcontainer.json?
i wanna make a bot that saves all the unknown number in a group that i am member of. the bot will keep running when mobile start and look for unknown number. If get one then save the number to google account with a string. How can I aproch this.
why not just to skip setting up venv in devcontainer π
install stuff in devcontainer as it is without venv
I've come to understand that it is best practice to use venv even inside a devcontainer. In any case, it cannot hurt ... I just want to do it properly.
the answer somewhat depends on what u use for dependency management
It's been a while since I developed with Python so I am trying to set up a template environment from scratch that I can use as a basis for new projects. I.e. I'm not really married to any dependency management
what are afew tools to use python
Hi!
I am trying to move back to a dev role (I was a backend developer ~10y ago) and took the chance to write some tools with python that help me on my daily work. Is there a channel where sharing the repo for these tools is more appropriate?
GitHub and Gitlab both would work. GitHub is more common despite its issues
how to send messege in messenger using py
sorry if my question wasn't clear... I was asking if there is a channel on this server where it is more appropriate to share my repo, so that people can provide feedback and inputs. The code is on github π
Some servers don't allow these type of posts, and have a dedicated #showcase channel for it.
ah, #software-architecture is dedicated to software... well, design topic. in terms of code architecture.
U could try there as a choice
advertisements aren't allowed though, stay on topic π
for the goal of..
having questions regarding design of app in software design
or for career channel as presentability for resume
or smth, just not adds
thanks!
I'm curious on what basis you came to that understanding
I'm not that expert but I can't think of a reason you would want a venv inside a container and I've never seen it done. If you think you need to isolate dependencies inside a container I would guess separate containers would normally be more appropriate
Is this what you're asking for? https://pypi.org/project/messenger-api-python/
can anyone crack a py file that is as app ? if ye dm me
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Hi,
Can I share a Django bnased premium admin template here?
Or just open source projects are allowed?
wish I knew
A lot of people seem to like KodeKloud but I don't have a subscription. Most of my AWS learning has involved study books for their certifications.
YOu may want to follow #tools-and-devops for a few days to see if it looks like the kind of discussion that would be relevant.
I use Kode Kloud for the Kubernetes certification and it seems ok. I don't have a lot to compare it too. They have a pretty active Slack community for each class.
Guys is learning devops and cloud computing where the money is at? I am noticing at work the guy doing all the cloud stuff seems to be the most important. He built all the infrastructure and pipelines using terraform, boto3 and other stuff I don't understand too well. He designed it in a cost effective way
By using kubernetes and microservices. If I learnt how to build infrastructure in a cost effective way is that the most important thing from a business perspective
Cost effective
Auto scalable
Fault tolerant
Observable (monitoring, logging, tracing)
Secure
Minimizing manual actions to automated
Keeping stuff as Infrastructure as a code for better self documentation
There are more parameters than just cost effective π
.devcontainer multi workspaceMount
Hello, has anyone here worked with devcontainers and knows how or if it is possible to mount two folders into the workspace?
somethign like this, but the problem is, that workspaceMount only takes in a string:
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"features": {
"ghcr.io/akhildevelops/devcontainer-features/pip:0": {}
},
"postCreateCommand": "pip3 install --user -r tracker/requirements.txt",
"workspaceMount": [
"source=${localWorkspaceFolder}/tracker,target=/workspace/tracker,type=bind",
"source=${localWorkspaceFolder}/utils,target=/workspace/utils,type=bind"
],
"workspaceFolder": "/workspace"
}
why not to mount whole project folder once into dev container π
best decision for dev containers in my opinion
also for a mono repo?
potentially yes. If u will manage making everything launchable from same single forwarded project folder and having launchable all your monorepo processes just under different command path, it will make you simpler life yeah
having single docker image is kind of simpler
kind of fits monorepo. monorepo = monoimage π
This is more of a #career-advice question but the money is at doing valuable and efficient work. Whether that means you should focus on learning DevOps skills or something else has a lot to do with your interests, talents, social connections,.etc.
Can someone code a small thing for me? I will explain it in Dm and I think it will only take around 20-30min to code
Also there's value in not using microservices when they aren't needed
Hi guys, I have successfully setup jenkins and github, so that each time i push new changes to the v1 branch it will trigger a jenkins pipeline to build and push the image to dockerhub. now i have another vm where i pull the image and run it, and i have a service which would check periodically to pull and restart my docker container if the dockerhub image is updated by the jenkins pipeline. Now when its restarting the api is down for some minutes, I know a solution would be to use a load balancer , but i just want to be sure if this is an appropriate way or is there a better way. I already tried using azure app services but its impossible to disable the default url azure assigns an app instance. So ive decided to setup jenkins and host the api in a vm, then use cloudflare tunnel to proxy requests from a subdomain to the server
Why does it take multiple minutes to restart?
Are you not pulling the image before you restart?
What's wrong with having the app.azurewebsites.net domain floating out there?
I use App Services at work, and it gave me a webhook to hit to prompt an update.
So I have a GitHub Actions workflow that builds and publishes the container, and then hits the webhook to prompt the App Service to download the new container.
And it waits to recycle the container until it's ready, it still finishes all in progress requests, so you don't really have any downtime there.
I'd really recommend that automated workflow that's all-in-one place if you're just looking for the simplest workflow.
yes i understand but we are also trying to cut down costs because we have several applications to deploy and doing that in one vm at the moment i think is a great choice as supposed to creating 3-4 azure app services for it
also we are paying for github enterprise subscription
I am currently researching for a better option, from what ive seen we might have to throw in ks8 into our workflow
You know you don't have to pay separately for each App Service, right?
You buy the "plan" and you can run as many services as you have available resources for on that plan
GHEC is really nice, but it doesn't really give you anything here
Everything I'm talking about I also run on GitHub's free plan
K8s is really cool
Though it can be a pain if you're only running a couple services
I only have like two
I actually switched away from K8s to App Services
no we cant use free plan, its a company and we also have other workflows that use github actions that use up our credits and free allowances
No I -- I didn't say you have to
Just that it doesn't really add any benefits to building containers other than the additional minutes
What's wrong with having the app.azurewebsites.net domain floating out there?
Is there a compliance reason?
Is that the main reason you're not using them?
hmm... i see, maybe you can give me idea how to setup our workflow, its a really huge application which ive built with fastapi, i was using github actions before and we ran out of storage, then i thought of a better option to use jenkins, which i already setup and its working
yes kind of, we configured a subdomain like api.maindomain.com but i want to connect that to cloudflare tunnel because we also have other subdomains connected to that tunnel.
How big is your container?
we were using the free plan and our github actions minutes was almost used up
no, not the size, as you use github actions it will keep track of your usage and in freeplans there is a limit to how many minutes and storage you can use, it refreshes every month
Here's my open-source repo that I have an App Service: https://github.com/letsbuilda/api.letsbuilda.dev
Here's the workflow: https://github.com/letsbuilda/api.letsbuilda.dev/blob/main/.github/workflows/docker-build-push.yaml
It runs this reusable one: https://github.com/darbiadev/.github/blob/main/.github/workflows/docker-build-push.yaml
Which caches the build to and publishes to the GitHub Container Registry
And then after that hits the webhook to prompt Azure to get the new container
Nothing required but the one GitHub repo for the entire build process
And then nothing but a webhook required for the entire deployment process
okay i see
It's a public container, so no creds
But if it was private you'd add a PAT here
AFAIK there's still no packages support for fine grained tokens, so you still have to use the classic PATs
one question, i already have jenkins setup and it works file, i think i can still use that with dockerhub and azure
Yeah
You can manually update in Azure
Or have Jenkins hit the webhook
i do not understand, if i deploy a new azure app service and set the source to be a container image instead of github project, I think azure will watch the container registry and pull my new image once i push to it
right ?
currently jenkins will push the built image to dockerhub
It doesn't automatically pull updates AFAIK, you have to prompt it
I "just" have a CNAME
Is there something specific about Cloudflare Tunnels that makes you want to use them?
what are your thoughts on using kubernetes ?
you know its just easy to map a subdomain to some ip address and port
If you only have one or two containers, just make the App Service for the simplicity
But if you start getting into many containers, it's time for Kubernetes
when i turn that proxy switch on, it gives me another error like bad gateway or so
okay
please i will ping you after some hours, incase i tag you
That's my thing
When I had Kubernetes, I had to setup NGINX, I had to setup Cert Manager, I had to setup ingresses and services and deployments
When I tried out App Services I said "hey here's my container" and it said "okay I'm done"
I didn't even believe it at first. Coming from Kubernetes, I couldn't believe it was that simple
It was a big sigh of relief to not have to deal with all that crap anymore
yes app service really simplifies the process
ive been using app services for some time now and its been great
But I'm not bashing on Kubernetes.
It definitely has it's place.
I'm the infra lead at https://vipyrsec.com/ and we just switched to K8s (from App Services BTW)
Lots of containers and it was going to be a pain to make that many App Services
just
Yes?
Also BTW, App Services will kill your container if it doesn't respond to HTTP requests
yes
So it's a non-starter for non web apps
(just poking fun at the fact we've been on k8s for quite a while :P)
Of course, happy to help
is this a subdomain ?
Yeah
The api subdomain is a CNAME that points to apiletsbuildadev.azurewebsites.net
haha, i dont know why azure didnt provide a way to remove this default domain
it would have been great to use an ip address
Not sure
But what's wrong with it being there?
its making me feel like i have a backdoor to my server , π
the main api domain is protected with cloudflare
if anyone finds out that there is an azure variant they can just make requests to that one
right ?
true
i actually implemented the solution in this blog more than 2 times
for some reasons its not working for me
huh
it didnt workout for me
they solution is basically to enable access to the sire only by defined ip addresses
then you will add all cloudflare's ip addresses
i did all that but its still saying that azure blocked my request
how do i tell azure to pull the images from dockerhub when i push a new image to dockerhub with thesame tag ?
I have turned on ci/cd but its not automatically pulling the new updates from dockerhub
AFAIK you can't
That enables the webhook
So when you're ready to update, you send a POST to the webhook
okay
so i have to do that manually like write code for it ?
maybe i will just include that in my jenkins pipeline as the last stage
.github/workflows/docker-build-push.yaml lines 22 to 28
deploy:
needs: build-push
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: "Update deployment"
run: curl -X POST '${{ secrets.DEPLOY_WEBHOOK }}'```
thank you
it didnt work
i also sent the request manually from postman
but i didnt notice anything
@astral apex it gets triggered if i toggle ci/cd on/off
but when i send post request to the webhook it doesnt work
Look right
What do the logs say?
Do they have a bunch of crap about invalid characters because you didn't quote the URL?
Huh
Not sure
Do you get a response?
From here, I dont think any packets if data is being sent
in your case its sending
I am getting 403 error
My guess would be you need to quote the URL
but i am sending the requests from postman
Are you sure you have the entire URL?
Not really sure with Postman
Don't use it much
yeah
@astral apex I think using docker-swarm or kubernetes would solve this issue
they offer automatic image update
FWIW CD for Kubernetes does practially the same thing
cos the only issue im having right now is updating the image when i push to dockerhub and still keeping the server running
How?
it will always pull
when it starts
it doesn't start (or re start) until you tell it to
kubernetes/manifests/dragonfly/mainframe/deployment.yaml line 19
imagePullPolicy: Always```
oh
is there a way to tell it to start by sending request to some webhook
*to restart
I have it in all of my deployments
I still have to manually login and kubectl rollout restart deployment/mainframe --namespace=dragonfly to actually trigger that pull
okay
maybe i can write a webhook in flask or fastapi
to call that command
do you think that would work ?
I haven't explored that yet, but here we use some GitHub Actions that Microsoft make to interact with our cluster
https://github.com/python-discord/bot/blob/main/.github/workflows/build-deploy.yml#L56-L82
okay
will this load balance all traffic, because remember the aim is to update the containers without causing downtime
is this the case ? @astral apex
What is the "this"?
I was referring to the workflow file you shared
No
The workflow file doesn't have anything to do with how Kubernetes handles the running containers
AFAIK Kubernetes will always automatically try to gracefully restart
You can see when I restarted the bot the old instance stayed "running" while the new one was "pending"
And Kubernetes didn't start "terminating" the old instance until the new instance was "runnning"
Stayed? Staid?
Anyways
I see
So its load balancing the operations
I'd recommend App Service(s) if you're trying to keep it simple
Kubernetes is a LOT to learn
no
There are multiple types of load balancers, but this is not that
There is only one container at a time, so there is no balancing between them
Right therory, wrong term
Im looking for something that works , ive been sitting here since the past 17hours
I may use ks8
Did App Services not work?
Other than the domain
Did you actually have problems with downtime?
I cant trigger the app service to pull my images from dockerhub
That was the webhook thing . When I call the web hook it gives me 403 forbidden error
I already checked , there are no ip restrictions
Huh
Yeah
Not really sure there
I'd work on that one first
Because you already have it running
Before trying to go down the road of setting up a whole 'nother system
Yh
Haha, thats also what people said about jenkins
Its easy to use I think
Why?
(not really I just replaced it with a newer one)
(but Jenkins was really annoying)
jenkins is nice, but there are more modern solutions with gha or gitlab ci or circle ci?
Just got everything I needed from GitHub Actions, with a lot less effort
Yeah, I faces alot of issues while setting it up but I found a solution for all of them
Don't really remember the details, it's been... 6 or 7 years since then
I chose jenkins because its opensource and we dont have to pay for anything but the vms to host it on
same thing with gitlab ci π
or drone ci
We were using app services, but its expensive
Not app services, I meant github actions
Are your VMs cheaper than GitHub?
How many minutes do you use?
If you already have the resources available, you could also look into self-hosted runners
I am not sure but we are running other workflows apart from our api
Okay
I see
But Why not jenkins?
Just one more thing to keep track of and figure out
What?
Doesn't really matter all that much
Idk Why its just almost impossible to trigger a webhook
Hey, I managed to get a 202 accepted status when I call the webhook from postman
Ive been setting an Authorization header all this time π©
Was a mistake

I just tested it, after pushing to dockerhub, when I send the request from postman, it pulls the updated image and restarts the container without downtime
Hi! I'm working on developing a simulation tool for underwater gliders in python and have lately been stuck on an issue. I am required to solve ODEs in my code, but I keep getting different plots when I use scipy.integrate solve_ivp(), odeint(), and RK45(). The matlab function ode45 works well but I am unable to get the same results on python. Any help would be greatly appreciated!
Please, do not cross post
sorry, I wasn't sure which channel I should post it in
We use GitHub actions too.. it has self hosted runners which are free
We just have them with already provided autoscaling solution... and enjoy free gh
Great
I solved my issue anyways, after 18hrs of debugging
Hey, I solved all issues, thank you, I really appreciate your time
The issue Why the curl was not sending was because I didnt wrap the url in quote
Happy to help 
Ah
Oof
Good job getting it fixed
If I do this , I am getting 404 site not found
Huh
Did you add the asuid?
Does the domain show as active?
I think you have to leave proxying off for the initial setup
Double check for typos and accidental spaces and all that
Oh good
Yeah, I generally wait half an hour or so for the DNS and the SSL to get propagated a bit before I enable proxying
Should be fine whenever though
Or sni ssl
Ok
The one thatβs not the default needs extra configuration
Ok
I currently only have a main branch, if I commit all changes of main branch, then create a new branch rewrite where everything is completely different; there are new folders and files, and then I commit the changes to that branch. Now when I come back to main the folders from the rewrite branch (everything else is as expected) are still there. How do I correctly handle this situation?
you committed on main and then created a rewrite branch
so main also has the commit
you'll need to hard reset main to the previous commit
switch to main and then do
git reset --hard HEAD~
I also heard from SO answers that Git does not track folders, how true is that?
yeah, it doesn't track empty folders
a common way to track empty folders is to make a .keep or .gitkeep file in them and track that
I undid two commits, but the impl folder is still there, this folder is from the rewrite branch. What I found out just now is that impl is filled with empty folders with no files that exists in the rewrite branch's impl folder
check for hidden files
ls doesn't show them by default
fixed it
@astral apex i selected ip based ssl for the proxy option to work. Ip based ssl means ill use the certificates from cloudflare and to hide the ip address you have to select this option in the SSL/Tls Tab for your domain on cloudflare
so i worked a huge amount of hours, like 8 hours, then I stashed my changes, but then my laptop had an unfortunate shutdown, now that I come back, all those files are empty and the stash record is missing.
did i lose all my files to corruption?
git stash list
list [<log-options>]
List the stash entries that you currently have. Each stash entry is listed with its name (e.g. stash@{0} is the latest entry, stash@{1} is the one before,
etc.), the name of the branch that was current when the entry was made, and a short description of the commit the entry was based on.
stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
stash@{1}: On master: 9cc0589... Add git-stash
The command takes options applicable to the git log command to control what is shown and how. See git-log(1).
from git stash --help
I've been using the scipy solve_ivp() function to solve a few ODEs. Can anyone tell me why my plots are tracing backwards? The x-axis is time
Without seeing the code your guess is better than ours
For some reason storing 30 gb of metrics on S3 causes Thanos to waste about 500 gb of S3 traffic daily. What settings should I look into to reduce traffic consumption?
I want a little help from anyone with a simple problem in a tool I make!
:ok_hand: applied timeout to @dim tusk until <t:1696446189:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
What do devops do in python? kinda a question but eh
the same stuff as devops in any other language i would assume, i.e. whatever gets an app from development to deployment
something more python specific that i've done is use github workflows (aka CI/CD) for running pytest on push and building/publishing library wheels, alongside https://readthedocs.org/ to host and continuously update my sphinx documentation
I wanna purse a carrer in devops but I legit know nothing about programming
Someone told me to do the aws and azure certs
hmm there much more qualified individuals here that can answer that
though it might also be more appropriate to talk about in #career-advice
Okay
Scripting glue for CI CD means
Cloud provider lambdas that help to augment infra with more custom solutions
Configuring monitoring systems
Making dev tools
Configuring release/deployment system
If they are free of infra stuff and have strong enough backend side then
Using as means to debug databases
Writing libraries, backend
Doing pretty much backend duties if necessary
In my current company DevOps engineer is for good half is pretty much backend developer.
When I get tired of too much infra, I grab more backend, more pure dev duties
When I just wish to relax a bit more, I go and solve some infra thing like fixing autoscaling
DevOps engineering for different companies have different meanings though, exact percentage of Dev, Infra and Ops duties will be different
I know a guy that wishes to do 80%+ or even purely infra only stuff. Apparently he worked in place that provided it to him. That is weird to me, there is always stuff in between
Or as I said I prefer to take a break from infra only duties from time to time and just to code some application, more dev project
Development is kind of more creative u know, involves different set of brain working.
Taking care of infra stuff is going over monitoring systems to find out about issue, reading more docs and writing more simplistic infra code. Different workflow a bit
Both duties have their own merits but I would not have wished only one set of them
Or even Ops duties. Helping to people and taking care of Ops can be nice. I am altruistic enough. But gets tiresome if doing too much too
Preferring to do it only as small part of a day and not every day then I can enjoy it, in getting feedbacks of thanks π
How many hours you be working in a day?
Yea I get bored doing repetitive stuff too,
8-/+. Not sure exactly.
I have flexible schedule, sometime I work more, sometimes less.
I just try to have done enough to write down 40 hours made of work during a week.
Still figuring out work balance thing
Sometimes day can last 12 hours. I am bad at my time management, personal problem pretty much
Often enough I start day only during middle of a day though
You get to choose your own working time?
Yeah. Very flexible schedule.
Highly preferably I would work 8 hours in same day with start and end at any part of a day with any pauses.
In the end it is important only reporting 40 hours during a week, so I can even jiggle hours to other days if necessary
I need to appear at morning standup though
And I am expected to answer... relatively fast enough (within an hour?) During normal workday time
Managable, just say what u did yesterday and what u a doing today
I got used to that
Oh that is fine then
Kind of even nice. I am fully remote, during stand-ups i have at least some live communications with humans and see my colleagues
My Ops is just handling requests (asks for help if smith is broken, or helping to investigate smth) coming to slack channel of requests to DevOps team.
Pure Slack
I just pick stuff I can help there with, that got my interest
Other team members pick stuff they are able to solve
That makes eventually good enough coverage of solved problems
Doing it when wishing to slack off from main duties π
Sometimes more emergency stuff appears though
Infra meltdown somewhere
Then it becomes not optional but needed being solved as soon as possible
those moments can be stressful right?
It can be energy exhausting and going overtime often enough
Important to eat and drink in time π
how to write socket pytho that can ddos a server
don't you get paid extra for overtime
Really bad to be too low on energy, starting to feel too bad then
U know, i don't. But may be I am an idiot that missed how to report it π€
I ll check our docs
Usually we report 1x rate any time
And as I said important only having 40 hours per week
So, If I did more today I can be more lazy tomorrow
Yeah, I am expected to work 5 days in a week
That is why 40 hours
Any overtime for that must be agreed upon with manager for us.
We can, some people are crazy to work much more. I don't wish so
I need time for personal life beraucracy and for self studies and some just for personal mental health
damn but fr if you need time you should get everything done early since you said you was starting work late
That is questionable approach. If I work too much in one day, I can get exhausted too much and not having mental capacity for tomorrow until very late
I try to be careful regrading my mental and physical health, doing stuff when I am feeling alright
Some days are good days waking up early
You wake up with so mch energy out of no where
I am owl. My energy is somewhere at middle of day, evening and sometimes during nights
Bless flexible schedule to be friendly for that
im the opposite my energy is gone after 5pm or so
I care to spend my most productive hours of a day for work. When I am concentrated, full of energy, and in good mental and body health in general
Often enough that can make me many times more productive during certain times
Flexible schedule fully remote work with mind work, important to put effort, not showing imitation of effort
yea
Ima go ahead to sleep now
maybe we can talk tmr
It was nice talking with you
Likewise
pytube: I have a frustrating couple of issues with pytube: when I do from pytube import YouTube, Channel Channel is white and unseen (see img) ; I can use YouTube, but not Channel...anyone seen this and resolved? https://i.imgur.com/KSeFbmn.jpeg
I have tried installing pytube AND pytube3. I have tried removing the cache and installing/deinstalling both
from pytube3 doesnt work
yet https://pytube.io/en/latest/user/channel.html seems to show I can expect to be able to use Channel functionality
I am trying to backup some of my dotfiles to github. I initialized a local git repository in my home directory. How do I ignore all other files except those in a few selected folders in .config/ folder?
you want to ignore all files and folders in .config/
except some selected?
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeβs robots.txt file; (b) with YouTubeβs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
tl;dr: we're not gonna help you with that
nevermind, I instead settled for read-only bind mounts (i bind mounted each needed config folder in another directory then did git init there) to get away from this
- Is there a better place to ask my question? I've tried here and Unofficial Django. 2. How can I see my recent posts (on any server) I quite often lose track of what I have posted where!
update: Looking all over the web I'm beginning to think pytube is mostly unmaintained after a YouTube structure change with shorts etc. Also now the basic functionality gives me HTTP Error 410: Gone , eg video_url = "https://www.youtube.com/watch?v=BDgsF2i6nT0" yt = pytube.YouTube(video_url)
this is helpful https://stackoverflow.com/questions/68680322/pytube-urllib-error-httperror-http-error-410-gone but seems like its not stable these days.
What is anyone else using to interact with Youtube Playlists and Channels (I don't need to download vids, I just want the easiest way to get playlists and thumnails and channel latest vids including shorts)
Does Python have a way to auto reload the browser after changes on file system?
#tools-and-devops message repeated offence. Ignoring warnings. <@&831776746206265384>
I'm working on a package called ess which has a number of subpackages. We are currently in the process of splitting those up into separate repositories to help with maintenance. And we are considering making ess a namespace package to keep the existing structure from the user's perspective. However, we noticed that PyPI does not allow the name 'ess'. (But we have so far deployed to conda and it is fine with the name.) So my question is, can it cause problems if we have a namespace package with a name that is forbidden by PyPI? We would call the various subpackages, e.g., esssans for ess.sans. And we might have a meta package essdr (or similar name) that can be used to install the various subpackages with, e.g., pip install essdr[sans].
Python wouldn't know anything about "the browser" unless it's a Selenium session. You probably need at least a little bit of JavaScript to do whatever you think you're trying to do
Thanks, after giving it some thought I think running a node server is the ideal choice for now
However, I'm curious about other solutions not requiring node.
SSE or websockets could be used in python to detect file changes and send a SSE/WS event to the browser to perform a reload
What I'm creating is a JS framework like react.
My JS framework doesn't need node to compile and has zero dependencies! π
Hey folks, is anyone messing monorepos with multiple pypi packages being pushed? I'm wanting to pursue this via rye actually but i might be a bit in the bleeding edge.
In WSL, whenever I type in this command:
I always get this:
[+] Building 0.2s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 2B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount3246307496/Dockerfile: no such file or directory```
how can i fix this issue
does anyone know what I need to do to configure the launch.json used for the vscode test debugger? (the one used when I click the second button on the right there)
I need to make justmycode into false
in the Debugger pane in the left sidebar, click on the gear icon beside the launch configuration dropdown at the top
that'll open the .vscode/launch.json file in your project where you can configure the Just my code setting
do you have a file named Dockerfile/Containerfile in that directory? if there is, do you have a .dockerignore as well?
Yeah but those are just the launch.jsons for regular debuggers u use on ur own right? its not the debugger used when u debug a test with vscode
Like I've tried changing the justmycode in my launch.json, but it isn't taking for the vscode test debugger
In fact even with an empty launch.json, debugging still works. how can I change launch.json config that vscode uses?
So, i was searching about making a python library to a specific chemical engineering work. is this the right chat to talk abou it?
maybe, if your questions are about which tools to use to help you
good enough. #software-architecture is slightly better though depending on which questions u will be asking
but if you're, e.g., wondering how to structure it, maybe 
nice, i'll ask it there. Thank you guys!
continuing discussion from #software-architecture message since here is more appropriate for package management, i recommend reading:
- the Python Packaging Tutorial for the typical packaging workflow
- Setuptools User Guide
- Declaring project metadata for a list of all keys you can add to your configuration
in short, pyproject.toml is the newest standard for declaring project metadata, and setup.py and setup.cfg are the older methods specific to setuptools
Setuptools automatic discovery mentions two common project layouts:
- src-layout
project_root/ src/ my_library/ __init__.py ... pyproject.toml - flat-layout
project_root/ my_library/ __init__.py ... pyproject.toml
there are arguments for one vs the other, but personally i stick with src-layout and use editable installs during development
this is what a setuptools-based pyproject.toml might look like: ```toml
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "my-library"
version = "0.1.0"
dependencies = ["numpy>=1.26.0", "sympy>=1.12", "matplotlib>=3.8.0"]
description, readme, license, classifiers, etc.after this, organize your scripts into a [package](<https://docs.python.org/3/tutorial/modules.html#packages>) following one of the above layouts, then adjust your imports as necessary (e.g. `from my_library.submodule import function`), and do an editable install so you can test the package:sh
/project_root $ pip install --editable .```
as per the tutorial you can use build and twine to build and publish your library, and for build systems other than setuptools they may have a command-line tool that can do this for you like poetry
some additional links beyond those are:
- MANIFEST.in, if you have any non-python files that your package should include
- Console Scripts, if you want to register some function as a command-line program for convenience
- PEP 440 and SemVer for version naming conventions (SemVer's major.minor.patch scheme is the most important to know, everything else you should refer to PEP 440 since both documents are not entirely compatible)
- berconpy if you want an example of my project structure
oh my, i thought it was a little bit simpler
but let's go, i'm gonna try it
thanks guys
it is more simple than it looks π
I'm in the process of researching code-signing certificates. My goal is to sign an application that has versions for Windows, Mac OS, and Linux. What are some good cross-platform code-signing certificate providers that work for signing Windows, Mac OS, AND Linux applications?
Oh, I see the warning now, apologies. Finding Discord quite confusing- where is there a list of all my messages, regardless of the server and messages that mention me?
there is Inbox that shows everywhere where u a replied across all servers
Hello can i import libs from another file but when i use class or def?
Maybe not a good practice but technically possible, sure
Recently my system's antivirus/security software apparently started to block > pytest activities and cause some warning message to be posted in my Powershell window. From the warning messages it seems to do something with accessing cache file/folder. Is this normal? Is there something "new" occurring with pipenv and or pytest ?? Thanks!
π
use Linux. Best OS to develop web applications that run on Linux servers anyway.
Otherwise, specify which cache folders.
as far as i know, folders of cache like __pycache__ should be freely deleteable at any time. (or for that matter u can even utilize work around of running python without cache)
Is it possible to turn on logging level and having it seen for specific smth at DEBUG level
without turning DEBUG for every single third party library?
https://github.com/vipyrsec/dragonfly-mainframe/blob/main/src/mainframe/server.py#L78-L84
Like this?
You can pass a package name to getLogger and then you can set whatever settings you want
src/mainframe/server.py lines 78 to 84
# Disable uvicorn's logging
for _log in ["uvicorn", "uvicorn.error"]:
logging.getLogger(_log).handlers.clear()
logging.getLogger(_log).propagate = True
logging.getLogger("uvicorn.access").handlers.clear()
logging.getLogger("uvicorn.access").propagate = False```
it did not work
def configure_logger(log_level: str) -> None:
root_logger = logging.getLogger("")
root_logger.setLevel(logus.log_levels_str_to_int[log_level])
ch = logging.StreamHandler()
ch.setLevel(logus.log_levels_str_to_int[log_level])
if settings.LOG_JSON:
formatter = logging.Formatter('{"time":"%(asctime)s","filepath":"%(name)s","level":"%(levelname)s","content":%(message)s}')
else:
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
ch.setFormatter(formatter)
root_logger.addHandler(ch)
logus.my_lib_logger.setLevel(logus.log_levels_str_to_int[log_level])
logus.my_lib_logger.addHandler(ch)
@pytest.fixture(scope="session", autouse=True)
def turn_debug_logging() -> None:
loggers = [
logging.getLogger(name) for name in logging.root.manager.loggerDict
if name.startswith("lib_name") or name.startswith("lib_name") or name.startswith("lib_name")]
for logger in loggers:
logger.handlers.clear()
logger.propagate = True
logger.setLevel(logging.CRITICAL)
configure_logger("DEBUG")
setting everything to CRITICAL worked though
actually no
it made weird logging duplication for some reason
...python logging is difficult. sigh
i am heavily confused
loggers = [
logging.getLogger(name) for name in logging.root.manager.loggerDict
if name in ["lib1","lib2","lib3"]]
for logger in loggers:
logger.handlers.clear()
logger.propagate = True
logger.setLevel(logging.WARN)
I expected this code to disable loggers...
...for some unknown reason it makes for remaining library amount of logging records duplicated proportional to amount of disabled libs
it is not really remotely expected behaviour, is it? π
I know!
i need to print threading, process name just in case. lets check if those are forks or not
Huh
Thatβs weird
Yeah itβs a giant pain
I donβt really understand it either
Sorry I canβt be of more help
printed thread and process names. ID seem to match. yay to no fork bombing.
%(thread)d-%(process)d:%(asctime)s:%(name)s:%(levelname)s: %(message)s
139791544246272-834601:2023-10-11 23:10:34,930:lib_name.status:DEBUG: setting success in django storage >>> task_id=9901825a-06f2-43c5-b8c2-de7a895f9a99
139791544246272-834601:2023-10-11 23:10:34,930:lib_name.status:DEBUG: setting success in django storage >>> task_id=9901825a-06f2-43c5-b8c2-de7a895f9a99
139791544246272-834601:2023-10-11 23:10:34,930:lib_name.status:DEBUG: setting success in django storage >>> task_id=9901825a-06f2-43c5-b8c2-de7a895f9a99
that means it is pure logging smth π€
def configure_logger(log_level: str) -> None:
root_logger = logging.getLogger("")
root_logger.setLevel(logus.log_levels_str_to_int[log_level])
ch = logging.StreamHandler()
ch.setLevel(logus.log_levels_str_to_int[log_level])
if settings.LOG_JSON:
formatter = logging.Formatter('{"time":"%(asctime)s","filepath":"%(name)s","level":"%(levelname)s","content":%(message)s}')
else:
formatter = logging.Formatter('%(thread)d-%(process)d:%(asctime)s:%(name)s:%(levelname)s: %(message)s')
ch.setFormatter(formatter)
root_logger.addHandler(ch)
logus.mylib_logger.setLevel(logus.log_levels_str_to_int[log_level])
logus.mylib_logger.addHandler(ch)
for logger in [logging.getLogger(_log) for _log in ["factory", "faker", "lib3"]]:
logger.handlers.clear()
logger.propagate = True
logger.setLevel(logging.WARN)
configure_logger("DEBUG")
same bug with this
First time for everything
for logger in [logging.getLogger(_log) for _log in ["factory", "faker", "lib3"]]:
logger.handlers.clear()
logger.propagate = True
logger.setLevel(logging.WARN)
configure_logger("DEBUG")
accidentally had configure_logger at the level of the loop π
that is the reason for logging duplication :/
Oop
Hi guys,
I guess most of you know by now about the latest curl vulnerability. Which tools are you guys using to find the Python dependencies that have this vulnerability? I want to do a quick scan on multiple services. I was thinking about using Black Duck but if there's a better tool I am open to suggestions. I would prefer tools that integrate nicely with poetry and pipenv. Thank you!
hi guys, I am currently starting to learn more about repo structure by reading some opensource repos.
there's one folder named /contracts I can't get a hang of it.
What does this folder usually storing? is it abnout types, protocols, etc??
could you share any repos you've seen this directory in?
(#software-architecture might be a better channel to ask this)
yes sure. sorry if I get to the wrong chat π
this is one repo I saw: https://github.com/microsoft/promptflow/tree/main/src/promptflow/promptflow
and this as well: https://github.com/dbt-labs/dbt-core/tree/main/core/dbt
tried to read from their "how to" doc but seems to be leaving this folder out. So I can't really quite get what is their organisational purpose.
those looks like dataclasses (which might also be DB models)
so it's more like a datastructure that the repo want contributors to follow?
thanks π
kinda, those are structs that are used across the project
thank you
these are "data contracts" used in various parts of the application. it's a little idiosyncratic to use it as the folder name, but it's not bad. you might also see it called "models", as in the standard data models used throughout the application.
ah that makes sense π thanks yeah. I saw /models more than contracts probably because it closely related to Pydantic/ ORM.
right, i don't think that distinction is always clear, but maybe it's established practice to distinguish "external data models" and "internal data contracts" in some areas. i don't see those two things as particularly distinct concepts.
imo a contract is something that applies to the interface between two functions or components, consisting of the model(s) that are accepted and returned from that function, as well as pre- and post- conditions. so "contracts" isn't my favorite name for what you see in the dbt repo, and i prefer "models".
another related question, if I have some abstract protocols. Do I still put it here? or is there some folder name I should be using to indicate that?
types.py, protocols, or types/protocols.py all could work imo. with types and typing also interchangeable
in the python stdlib, types is used for concrete types (like ModuleType) and typing is used for abstract types (like Generic), but i think that's partly because types long predated typing. i don't know what the names would be if we were to reinvent both of those things at the same time.
Im writing this script to move my mouse (its not for antik afk if you want we can talk in a VC about what im exactly doing) inside games, my cursor moves when im tapped out but when i tap in games it doesnt move
sorry if this is the wrong channel i didtn found a better one for this
guys how do you ship desktop applications with python?
is installing python on the host computer mandatory?
In practice, yes.
There are tools that purport to turn your python code into a standalone executable, but I've never gotten one to work.
I have, it's quite easy. The majority of these tools just take the python executable, your app, the standard lib, and put them into a zip
What's the best way to handle creating alembic migrations in a dockerized app? Having to spin up a container with an attached volume and a configurable command for the message seems like overkill, is it the only way?
it honestly seems easier to just manually make the version file and run it, is there any reason I shouldnt do that and manually fill out the previous/next variables?
if it was my small project but i worked with postgres?
i would have ran command in another terminal, docker-compose up postgres that raises it with forwarded ports for my host machine
and just run migrations commands locally (that i recorded into taskfile.dev). So final command would have been like task makemigrations
if it was my work project, i would have put commands to make migrations into docker-compose service of application. service would have been named makemigrations
colleagues only would have needed to run docker-compose run makemigrations for them to be generated (it would have raised db for them, ran application correctly and did everything for them)
My teammate makes the migrations run when the Docker image starts -- https://github.com/vipyrsec/dragonfly-mainframe/blob/main/entrypoint.sh#L5
Which I think is dumb, I don't think the app should have an account that allows edit the schema
But I wouldn't generate migrations in Docker
I would always generate new migrations on my host
entrypoint.sh line 5
python -m alembic upgrade head && python -m uvicorn src.mainframe.server:app --host 0.0.0.0 && exec "$0"```
i think making migrations should be one off command in https://taskfile.dev/ or as docker-compose service.
I would not be doing that in staging or prod
because generating migrations is like writing code... it should not happen in prod, it is part of dev env writing code for me.
i would have ensured with CI that they are correct for usage in staging/prod, that i made all migrations and they will work for our staging/prod db
i will be always git committing all my files of migrations from my dev machine
generating migrations in docker as long as docker is on my host is fine to me.
Docker is just another... more feature rich venv alternative to me π
docker running in staging/prod will not have command present to deal with migrations in any way automatically... at serious projects at least. Only at dev env.
Thank you @rapid sparrow and @astral apex , this is a personal project so I'm not terribly worried about running the migrations (though I am trying to use this project as 12-factor practice). It's writing the migrations that has become cumbersome since I've just had to start up a container and run the alembic revision command. Taskfile.dev is new to me, I'm gonna take a look at that
if u need to raise container to run alembic revision.
U could define docker-compose yml
x-definitions:
app: &app
build:
context: .
volumes:
- ".:/code"
depends_on:
postgres:
condition: service_healthy
environment:
APP_DATABASE_HOST: postgres
version: '3.8'
services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
healthcheck:
test: [ "CMD", "pg_isready", "-U", "${PG_USER:-postgres}" ]
interval: 3s
timeout: 3s
retries: 5
app:
<<: *app
command: bash
makemigrations:
<<: *app
command: alembic revision --args
then creating migrations will be just docker-compose run makemigrations, it will create them for you in your project folder then. Without any extra commands. It will await postgres raising completion and then will run them
i prefer to utilize taskfile though (and using to localhost port forwarded localhost), not liking to work from within containers unless necessary (or making it as more easy to replicate dev env for other collegues)
I use PyInstaller and add a βonefile argument.
#bot-commands
How is this password genorator?
import random
op = ("y")
while op == ("y"):
cho = input(" 8 or 11 char:\n---------------\n ")
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",">","<","/","!","@","#","$","%","^","&","*","-","_","1","2","3","4","5","6","7","8","9","0"]
y = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
print("---------------\n your pass is:\n---------------")
if cho == ("8"):
a = random.choice(y).upper()
b = random.choice(y)
c = random.choice(y)
d = random.choice(alphabet)
e = random.choice(alphabet)
f = random.choice(alphabet)
g = random.choice(alphabet)
h = random.choice(alphabet)
fill = (a+b+c+d+e+f+g+h)
print(" ", fill)
if cho == ("11"):
a = random.choice(y).upper()
b = random.choice(y)
c = random.choice(y)
d = random.choice(y)
e = random.choice(y)
f = random.choice(alphabet)
g = random.choice(alphabet)
h = random.choice(alphabet)
i = random.choice(alphabet)
j = random.choice(alphabet)
k = random.choice(alphabet)
fill = (a+b+c+d+e+f+g+h+i+j+k)
print(" ", fill)
print("---------------")
op = input(" again? y/n\n---------------\n ")
print("===============")
why donβt you try using the string module
so instead of have to make a big ass list you can just do
alphabet = string.letters + string.digits
- itβll randomize and u can choose how long u want the password
I'll try. I didn't know how to
I can't get it to pull items out of the string. lists
I figured it out
import random
import string
e = int(input("digits in pass:\n---------------\n "))
print("---------------")
a = string.digits + string.ascii_letters + string.punctuation
b = random.sample(a,e)
c = ""
d = c.join(b)
print(d)
print("===============")
I shortend it a little...
yes, ideally if they're about tools and Dev Ops.
If it's a general "plz help me with my python homework" question, then #1035199133436354600 is the place
@fathom ledge ^^
Itβs about building a docker image but I already have a lead. Thank you!
can a running process see if an ENV variable was added (globally, by a different process)?
in Ubuntu
Hey guys
Traceback (most recent call last): |
File "/app/main.py", line 7, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
I get this message on my uBuntu console after running my Docker image
Iβm not sure how. Maybe itβs because of my Dockerfile
My docker file
# Use the official Python base image
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /app
# Copy your application files into the container
COPY . /app
# Copy the requirements.txt into the container
COPY requirements.txt /app
# Install project dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your project files into the container
COPY . .
# Set the command to run your Python application
CMD ["python", "main.py"]
what's in the requirements.txt?
also, you're copying your application/project files twice
the first COPY instruction is unnecessary and actually harming the layer caching
in Linux, under normal circumstances, processes cannot (and do not need to) change the environment of other processes
you need the SYS_PTRACE capability to be able to do this, IIRC
if you need to change some application config, it's better to communicate the change to the process via IPC or have the process read some config file in an interval or on some signal like USR1
I didnβt know I actually had to write something in there. I thought all of my dependencies would automatically be containerized.
the layers of an image are stacked, so any change in a layer will mean rebuilding all layers after it
copying in the application files (which includes everything not ignored in a .dockerignore) will mean all layers after it are rebuilt because that generally includes code files that are changed often
anyway, that's not the issue at hand
^
Thereβs nothing written in it
I see
requests==x.y.z
best practice is pinning the packages to an exact version as well
β¦and the versions of the transitive dependencies as well
Thanks for explaining this, I think I now know why Im having a certain bug
Do user input programs not work in a Docker image?
Generally, no
You can make Docker execute a CLI, and pass in the args you give it to the CLI
But most of the time containers will be running web servers or batch jobs that don't need input
All right. thanks for the info
They can work if necessary. It is unorthodox additional feature used sparingly depending on needs.
Potential options for usage...
you can hook yourself into container as
- docker exec -it container_id_or_name bash(or sh) if it is present
- to get into shell and accessing some scripts from inside
- useful for average python Django application to access manage.py
- docker attach --sig-proxy=false container_id_or_name
- run commands directly in current stdin of a container and exit with Ctrl+P,Ctrl+Q combination (container needs to be launched opened for stdin + tty manipulations!)
- useful for game servers like Avorion game server or Minecraft server
docker-compose with opened stdin for attachment is launched with flags
stdin_open: true
tty: true
- and the most perverted option, you can even run GUI applications in container. And access them with
- forwarding your GUI into container
- or just using remote desktop options
while first two are more or less used (especially the first one is very common in python and other dynamic languages world), the third one is extremely perverted option π
The easiest option to hook yourself into stdin of container directly, just to run it with tty/stdin enabled as docker run -it stuff
although docker-compose run smth, with written options for that is very straightforward too
Is it normal for a docker image to take hours to build? Literally hours.
Everything else is building fast but itβs the venv with the problem.
I get the message βconnection reset by peerβ when pip downloads a dependency that needs find compatible with the and the rest and it can take about 30 mins to resume download and move on to the next requirements in the requirements.txt file
nope.
the most often reason for me to have that, i have turned on some kind of VPN. I prefer to disable them when using docker
any VPN works really badly with docker often enough
alternative reason could be that you are trying to install stuff not meant to be installed. And u have too weak PC to compile it
i remember some sentry versions require a lot of compiling building and should not be installed
Also installing psycopg2 is not prefered. better installing psycopg2-binary. Monitoring CPU consumption should be enough to confirm this theory
My container can build in like 30 seconds
Though normally it takes a bit over a minute
It doesn't heavily depend on what you actually do inside your container though
Why would you have a virtual environment inside a container?
a dependency that needs find compatible with the and the rest
So you have incompatible dependencies that pip is trying to reconcile?
Fixing your dependencies would make it to where pip doesn't have to try to fix them for you, so you can skip that step entirely
Oh, because I have airflow and my ML-pipeline in a venv. Some stuff that I use with tensorflow extended is not compartible with airflow
Yes, that's why I have it separate. But I don't understand why the project compiled correctly in Pycharm but not when I try to build the image
FROM apache/airflow:2.7.2-python3.8
USER root
WORKDIR /ml-system
ENV PYTHONBUFFERED=1
RUN apt-get update && apt-get -y upgrade && \
python3 -m venv /ml-system/tfx-pipelines/venv
COPY requirements.txt /ml-system/tfx-pipelines/venv/requirements.txt
USER airflow
RUN /bin/bash -c "source /ml-system/tfx-pipelines/venv/bin/activate" \
&& pip install --no-cache-dir --verbose -r /ml-system/tfx-pipelines/venv/requirements.txt
RUN pip install --no-cache-dir "apache-airflow==${AIRFLOW_VERSION}"
I haven't even copied the files to the container :/
I will try this, thanks a lot!
Is this something that can be done in Pycharm? tensorflow extended installed all the dependencies for me and I didn't get to choose.
Do you run a local instance of a large language model (llm) to help you write python code? Which flavor do you use? I've been running oobabooga (https://github.com/oobabooga/text-generation-webui) on a debian box and I'd like to run a 34B gguf model (preferably from https://huggingface.co/TheBloke) to help me code. I guess I'd use the llm mostly as a search engine replacement(? other suggestions welcome). If I'm not using python, then I'm probably using java.
What type of huggingface model do you like?
CodeLlama-34B-GGUF (Code completion. Infilling),
CodeLlama-34B-Python-GGUF (Python specialist. e.g. https://huggingface.co/TheBloke/CodeLlama-34B-Python-GGUF),
CodeLlama-34B-Instruct-GGUF (Code completion. Infilling. Instructions / chat.)
or some type of other flavor, e.g.
CodeFuse-CodeLlama-34B-GGUF or
speechless-codellama-34b-v2.0-GGUF?
I mainly code file/data manipulation, mathematical and machine learning type stuff. What model type would be good to choose?
Apparently, thereβs some networking involved when it comes to building a Docker image. I have a program that connects to my local mySQL server on my local machine.
I built a Docker image file for it, pushed it to my Docker Hub, went on my Linode VM, pulled the Docker image from my Docker Hub, ran the image and now the program canβt connect to the mySQL server on my Linode π€
Perhaps your MySQL server is blocking certain IPs?
On my Linode? Thatβs a good observation. I changed the bind address to 0.0.0.0
No, the MySQL sever I mean
Thatβs installed inside my Linode virtual machine right?
I have mySQL installed both on my local machine and virtual machine
Oh you're running both your application and linode on the same machine?
Well I ssh into my Linode VM on my local machine.
Right, but is the MySQL server running on the Linode VM?
Thatβs correct
What did you configure the target address of the DB to be in your application?
Also perhaps you could use docker compose to help make the networking easier
The DB hostname is called βlocalhostβ in my program
Itβs connecting to the hostname βlocalhostβ
In my program which is in reference to the localhost on my local machine.
Can you show us the Python code that connects to your database?
I probably can tomorrow
But every login credential is default on both mySQL servers
Password to connect to the database is exactly the same
Database names are exactly the same on both mySQL servers
funnily, one of the projects i work on had CI run for about an hour each time π©. but we killed the part that took that long, thankfully
I still canβt figure out which ones are causing the problems, I even left it building overnight π.
Pip is doing something called βbacktrackingβ to resolve dependencies but it can take a very long time and itβs a hit or miss.
Someone on Reddit recommended using conda for machine learning deployments to manage dependencies and venvs instead of what Iβm doing.
Iβve been learning tons, thatβs for sure!
Now Iβm wondering if a containerized application trying to connect to a mySQL server on a machine is even practical.
Maybe I should containerize the mySQL server as well as the application? π€
Maybe my program is within the realms of the container and thereβs no way for the application to connect to anything outside of the container
It is
You can
You lack knowledge of docker networking yeah
Iβm trying
Any ran docker creates by default bridge sub network within which is runs. It is assumed other containers will join same network name for sharing network access between each other by DNS names
If u want to access localhost present MySQL, simple solutions could be
- binding container to network host. It will disable bridge functionality
I hate Docker DBs
Mostly because I didnβt understand what I was doing and lost some data
This is what I did.
- or u can just run MySQL in container that joined same network. P.s. all containers defined in compose, share one network by default (equal to protect current folder name + default suffix) and can address each other by service name as DNS hostnames
I still canβt connect to the db. I do have the hostname named as βlocalhostβ and the program is written for it to connect to a server named βlocalhostβ.
Since itβs inside of a container, Iβm thinking the program is trying to connect to the localhost of the Docker container instead of the mySQL server on my Linode VM.
May be issue in that u create docker subnetwork after MySQL was already binded prerhaps. If u would have created docker network in advance, MySQL would have auto discovered it during binding operation
Thanks for the information. I canβt wait to take a another jab at it and resolve this.
Do you know if I can configure the network in my container on Docker HUB?
Start with simple solution of just launching container in network mode host. It will put it into host default network and u will find your localhost binded db easily by localhost hostname
No idea what is Docker HUB. I am a simple man that uses Docker CLI at Linux to access Docker Engine Server demon at same Linux host. No VMs involved
Docker HUB is a repository for Docker images
Ah, that one. Capital letters confused me. Thought it is program name
i build my Docker image from my local machine, push it in there and then pull it out from my Linode VM
There are no containers in docker hub. U store images at docker hub
Containers get created on image start.
U can launch multiple containers from same image
Network params are defined on container start
Oh ok. Good to know.
Launching containers in host network has disadvantages btw. Containers launched in this way are no longer network isolated (from each other and from host). If they bind any port, it is directly same port gets binded at host. Port forwarding is no longer needed
Just as warning that simplest solution has its cons
So, u can get easily container start prevented if it tries to bind port that was already taken
Does anyone have experience with using the Terraform CDK for Python in Azure? If so, is it easier to use and read than HCL?
haven't used it, but i can assure you that HCL is highly readable
it is very consistent and static typed
you aren't promised to have not a shitty code written by infra devs in Terraform CDK
more comfortable, yeah, may be. But highly likely it will not benefit your long term maintanability
How long does it take for a docker image to run thatβs trying to connect to the hostβs MYSQL server?
This question is lacking context. But in general creating a connection to a database should be relatively fast, much less than 1 second unless there are some connection limits in place or the database server is under heavy load.
If you are just running mysql on your own machine and trying to connect to it from inside a container image, it should be just as fast as any other connection, you wouldn't see noticeable overhead. So if you are developing an application and it's taking several seconds trying to connect to the database, something has not been set up correctly
My program creates a log file. Itβs built into a Docker image. When I run the image and it creates the the log file, where does it put it and how can I access it?
Ideally u should switch logging to stdout only if u a able
Docker is not meant to be used with logging files. It is dirty possibility(u can), but not the right way compatible properly with docker ecosystem
Is there a metrics collection/storage solution that allows for syncing/backfilling devices that are only online some of the time?
Like a way to have a device record metrics, and sync it into a central database when it comes online, to be queried from Grafana?
Prometheus doesn't support backfilling at all, other TSDB I found don't seem to have a sync feature either
Would it not be ideal to create a log file for a software thatβs meant to be run automatically on a schedule?
docker already has its own logging management... so your own solution is potentially going to be awkward crutch reinventing, that is not going to be properly compatible with docker logging ecosystem around
How do I access the Docker log file?
It appears the command for that is docker logs
the best way to log using containers is just printing to stdout
- yes, `docker logs containerIDorName is a regular way.
- default logging can be further augmented with usage of logging options
https://docs.docker.com/compose/compose-file/compose-file-v3/#logging
https://docs.docker.com/config/containers/logging/configure/ - docker ecosystem solutions can collect log for you into their databases and show with navigation in GUIs
- Loki / Grafana solution (raisable as single docker-compose)
- or just running container directly in AWS with some means, lightsail, elastic beanstalk, ecs, or eks
- kubernetes solution for logging aggregation (Loki, PLG solution is again deployable as Helm) and etc
- we use at work datadog for logging collection from all docker containers running at aws ecs
Docker ecosystem logging solution support autodiscovery. They could be collecting just straight from all discovered containers automatically
docker logs doesn't print out logs from a file, though. it's just the stdout isn't it?
kind of... docker still has logs written into files somewhere in his folder
so... so it is reading from file
err, yeah, but not a file the user is creating
you can read limited history
yup
to do that you would probably need to exec into the container and read it that way
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3",
"labels": "production_status",
"env": "os,customer"
}
}
https://docs.docker.com/config/containers/logging/configure/
You can make configurations to docker logging. to all default, or to specific one
yeah
https://docs.docker.com/compose/compose-file/compose-file-v3/
at the level of docker-compose overrides are avaiable
I need guidance to learn kubernetes, infra Management and efficient microservices communication. I have good experience with python.
can someone guide me where i can practice, i am confused.
if someone can list some resource / technologies where to focus that will be pretty helpful.
plz tag me when reply to this message.
For kubernetes I think just k8s and helm should be enough, also tiltfile for local development π€
There should be some k8s books that explain the main concepts, and helm is just a templating/release management tool really
helm is nasty to use for personal needs. too much untyped fragile. I think it is great only if u use its results / distributing something as a package
i would have wished something better tbh.
I mean, it depends on how you use it
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs
There is an interesting alternative in just... doing kubernetes via terraform
or through pulumi https://www.pulumi.com/registry/packages/kubernetes/
Can I run this locally? 
provider "kubernetes" {
config_path = "~/.kube/config"
}
Sure. u can use it locally
just feed it kube config, and it will connect to whatever u wish
check first page for all authorization choices
Why would I use terraform for k8s if I just need to do some templating?
E.g. replace a couple of values, run a for loop, etc
- statefulness. you can delete terraform code, and it will erase no longer needed resources absolutely without any left trace
- terraform is consistent and type safe. You can declare in a good way that your code Requires integer values, or list of complex objects, or string or whatever, it will compile it correctly
Aren't k8s manifests type safe?
terraform is great tool in team among many devs because it is ultra consistent.
when we speak about helm, we depend on helm to make it type safe, and how to treat required and complex values.
- you can review changes by terraform plan, what is changed and will be changed! More quality code review that you are doing correct changes
As of statefulness that's really not that good of an upside, since you mostly use k8s to deploy your applications
Same with helm or k8s manifests?
Just use git
no no. When we use Terraform... we can compare how our next change is compared to previously applied state, comparing to what is already running in prod
git is not answer to everything, it only shows diff to previous its commits/tags (we can't be always responsible and rely on that nobody made manual changes)
You can just check what commit you applied before that, in gitlab you could look up all the deployments for example
(we can't be always responsible and rely on that nobody made manual changes)
there are always manual changes drifting around.
It seems that it can be useful for cluster components but for apps I'd prefer helm
seeing diff in to what is Really running in prod is very valuable
Plus that's what probably 90% of people use
What do you mean?
someone could have toggle something via GUI
updated already something to other thing
changed smth. and etc
Doesn't sound like a tool problem to me
terraform will build plan in comparison to real state currently running
Solution is as simple as "don't change anything manually"
there will be always manual changes. Just from person experimenting in staging to introduce new infrastructure (even as a code in some PR)
Or someone did not deploy smth
there is always... state.... problems to what is really now
terraform allows to verify, your plan was deployed and clear now
and see that thing you deploy is next, going to change things compared to prod things now
this is idealistic view that is not scaling onto big organization with a lot of stuff
Ok
we try to achieve at this point... in 99% we do things as a code
but there is always 1% of stuff that can be done due to emergency or experiments or whatever
Experiments should probably not be done on a live cluster
mostly i have problem with someone applying stuff from pull request not manually
but PR was not merged yet
but i discovered it only during terraform plan
Also, not all stuff is locked in versions always... that makes terraform plan building changes just from having downloaded newer stuff
What will be changed just from you applying same code :/ (helps to lock stuff to versions if possible)
That's just not useful for me

