|
The Fool posted:The benefit is to be able to develop in an environment as close to production as possible. Yeah, I'm the one constantly preaching that idea on this very forum. However, I don't think its necessary for a python application. A python 3.7 interpreter is a python 3.7 interpreter. The one inside your docker container is not going to have different behavior from the one in your virtualenv. Maybe I can see it if you're on windows and you're deploying to linux, but even thats a stretch. I would, however, have CI tests that tests your whole docker-compose (or k8) infrastructure. The Fool posted:You also wouldn't develop "inside a container", you'd either push your code through vc and a hook would bring it in to docker, or your dev docker configuration would have a volume pointing at your code on your workstation. Then what's all this talk about using a remote interpreter / remote debugging with pycharm?
|
# ? Apr 8, 2019 23:00 |
|
|
# ? May 16, 2024 02:48 |
|
Docker is compelling if your application has non-python dependencies, and your team uses heterogeneous, potentially shared, development machines My particular use case requires GPU access and we have a hierarchy of dev machines - from MacBook Pros/Linux gaming laptops to in-house multi-GPU linux servers to AWS GPU instances. Docker papers over the various hardware setups. It also allows for pretty fine-grained isolation, down to exposing individual GPUs to a given instance, so this helps a lot with maximizing usage of the in-house servers.
|
# ? Apr 9, 2019 00:47 |
|
shrike82 posted:Docker is compelling if your application has non-python dependencies, and your team uses heterogeneous, potentially shared, development machines Yeah, this makes sense.
|
# ? Apr 9, 2019 01:25 |
|
shrike82 posted:Docker is compelling if your application has non-python dependencies, and your team uses heterogeneous, potentially shared, development machines Or depends on some weird academic research code that takes four days to flip a 50-50 coin to determine it'll run on this laptop or not and you can't find the time to rewrite the ancient thing because it would take half a yearbut is not publishable because it's not "novel" and ...
|
# ? Apr 9, 2019 06:33 |
|
I was thinking the same thing, but I don't know alot about docker. My python deployments are pretty much provider provisioning w/ user data -> sdist -> scp -> ssh tar xf && pip install. But I have some crazier packages with c where it would make sense to get more familiar with docker, if not just for the sake of getting with the times.shrike82 posted:Docker is compelling if your application has non-python dependencies, and your team uses heterogeneous, potentially shared, development machines dougdrums fucked around with this message at 07:05 on Apr 9, 2019 |
# ? Apr 9, 2019 06:58 |
|
Counterpoint: one of my coworker insists on using separate Vagrant machines for different projects, running them on Windows. In theory, Docker would be better here. However, the real downside is that he doesn't use virtualenvs because of it (and wouldn't with Docker, either). Unfortunately, some of the servers we use for ETL are provisioned by customers, so you get a funny mix of Windows Server, and various Linux distributions. But since he's not used to using virtualenv, he just loving installs everything globally. I told him to use virtualenvs on one of the servers, so he did. Next thing he deployed on the same loving server? Installed packages globally. This wouldn't happen if he just used virtualenvs, which are good enough in most cases and even work on lovely half-maintained Windows Servers that we RDP to via two intermediate virtual desktops. I want to take his virtual machines away. Badly. Also, just use Linux for development, ffs.
|
# ? Apr 9, 2019 20:21 |
|
Trying to install python-tcod on a Linux Mint 18 machine and run into this error when I run "pip3 install tcod":code:
death cob for cutie fucked around with this message at 20:28 on Apr 9, 2019 |
# ? Apr 9, 2019 20:26 |
|
I'm trying to repro a bug using docker and it's been a true PITA. Docker's rubbing me the wrong way, STS. Multiple unauthorized reboots, BIOS setting changes, ghost servers running long-deleted code etc. Don't care it's popular - this isn't polite behavior. Don't like.
Dominoes fucked around with this message at 21:08 on Apr 9, 2019 |
# ? Apr 9, 2019 21:05 |
|
Dominoes posted:I'm trying to repro a bug using docker and it's been a true PITA. Docker's rubbing me the wrong way, STS. Multiple unauthorized reboots, BIOS setting changes, ghost servers running long-deleted code etc. Don't care it's popular - this isn't polite behavior. Don't like. That's pretty unusual...
|
# ? Apr 9, 2019 22:51 |
|
Stay safe ghost server
|
# ? Apr 10, 2019 03:06 |
Caching at the edge server, survey says ...
|
|
# ? Apr 10, 2019 03:12 |
|
Dominoes posted:I'm trying to repro a bug using docker and it's been a true PITA. Docker's rubbing me the wrong way, STS. Multiple unauthorized reboots, BIOS setting changes, ghost servers running long-deleted code etc. Don't care it's popular - this isn't polite behavior. Don't like. Unsure how to say this but sounds like a PEBKAC to me Maybe we should do a containers thread, your ghost servers sounds like lack of familiarity with the system.... multiple reboots? Are you running this on windows or something?
|
# ? Apr 10, 2019 04:39 |
|
Hadlock posted:
If there’s not one it could probably be pretty useful
|
# ? Apr 10, 2019 13:37 |
|
I may write up an OP for one here later this week. Watching developers gently caress around with "dockers" is like a sweaty nerd trying to figure out how to finger bang an unlucky girl in the back of a car for the first time ...probably need a love line thread for them We have a devops thread but it's overly broad and generic
|
# ? Apr 10, 2019 14:01 |
|
Hadlock posted:I may write up an OP for one here later this week. Watching developers gently caress around with "dockers" is like a sweaty nerd trying to figure out how to finger bang an unlucky girl in the back of a car for the first time I think a docker/container specific thread would be a good idea. The topic has come up quite a bit in the last week across multiple IT and dev threads.
|
# ? Apr 10, 2019 17:09 |
I'd totally sub it. I still can't get my head around how volumes work and really what a container even is, like obviously it's not an entire VM image, it's like ... just a single app within an image, and you can have like 5-6 of them docker-composed together in the same environment, like one is your database and the other is your python app, but if you ssh into one it's like a parallel universe where it can't see any of the other ones and the db in the python env will be out of sync with whatever is in the db container? But in prod it all just magically works? I mean I'm being deliberately obtuse here for effect but I do really wish I had a more visceral understanding of the concepts involved. Really sucks when you're having the guy who hired you explain it to you for the third time and you're watching his face fall as he comes to grips with the idea that he's made a huge mistake *Sound of Silence plays*
|
|
# ? Apr 10, 2019 17:51 |
|
I don’t know much about containers and so take this with a grain of salt, but as a general concept roughly I think you can think of it as virtualization of the OS rather than virtualization of the hardware.
breaks fucked around with this message at 18:58 on Apr 10, 2019 |
# ? Apr 10, 2019 18:55 |
|
Data Graham posted:I'd totally sub it. Containers are easy to understand if you understand python because containers are an OS level namespace and as we all know : quote:Namespaces are one honking great idea -- let's do more of those! Linux provides a method (see the unshare command)to separate processes, networking, etc into its own namespace just like how you can variables/functions/objects in their own namespaces (modules, classes, global, function) in python. Linux also provides a method for limiting the resources (CPU, etc) available to a namespace (see cgroups). Now, build a bunch of scripts around those two concepts, and all of a sudden you've got Docker containers! Containers are what you call the conceptual thing you get when you smash namespaces and resource limiting by namespace together with a bunch of scripts.
|
# ? Apr 10, 2019 20:21 |
|
I use a NodeJS site interfacing with Flask to send commands to my Python script. The Python script is on multiple VMs and the NodeJS site is in one central location. When I am running the Python script on some VMs, it outputs the following. This isn't consistent across the VMs though with some of them doing their thing In silence. I assume this is a setting somewhere given the Python is all identical. code:
|
# ? Apr 10, 2019 20:33 |
|
The Fool posted:I think a docker/container specific thread would be a good idea. The topic has come up quite a bit in the last week across multiple IT and dev threads. Ok I'll start one I have some good resources for understanding containers at the kernel cgroup level plus some other stuff. Whatever I'm light on others can fill in the details
|
# ? Apr 10, 2019 23:59 |
|
Sad Panda posted:I use a NodeJS site interfacing with Flask to send commands to my Python script. The Python script is on multiple VMs and the NodeJS site is in one central Fixed it. Werkzeug logging needed tweaking. Next question... Do people find that inner functions are a good idea? I'm cleaning up my code and notice that in some of my classes there are functions which are only called from inside other functions in that class. They seem to logically belong to them. What downsides do inner functions have? The only one I can think of is that if you decide that you need to access them directly then you'd have to refactor.
|
# ? Apr 12, 2019 18:15 |
|
They're fine if they make sense. Mostly I use them for closures or function factories, but sometimes it makes sense just from a code organization point of view. There is a slight performance cost since a new function object is created every time the parent function is called. Just for ease of reading I will sometimes pull them out if they get too long as it gets harder to read because the indentation level can get hard to keep track of. If I do pull it out and it's not used anywhere else, I'll probably slap a hyphen on the front of whatever name I give it just to have an indication that it's private.
|
# ? Apr 12, 2019 20:05 |
|
I never use inner functions. I dislike how they look. Function definitions in global scope only, likewise for class methods. I also never use lambdas. They always look inelegant, to my eyes
|
# ? Apr 13, 2019 05:34 |
|
Lambdas in python are purposefully awful which is unfortunate.
|
# ? Apr 13, 2019 05:43 |
|
Today I learned about https://docs.python.org/3/library/contextlib.html#contextlib.suppress andPython code:
|
# ? Apr 13, 2019 08:05 |
|
Loezi posted:Today I learned about https://docs.python.org/3/library/contextlib.html#contextlib.suppress and Basically anything where you're dealing with a resource that should eventually be released can use it. Off the top of my head, sqlite connections, thread Locks, and socket servers all can make use of the "with" statement, which is essentially shorthand for the traditional try-finally block that you would use to ensure an open resource is released when it is no longer needed. In more concrete terms, any object which implements the __enter__ and __exit__ methods is a context manager, and will work with "with". susan b buffering fucked around with this message at 09:47 on Apr 13, 2019 |
# ? Apr 13, 2019 09:35 |
|
Loezi posted:Today I learned about https://docs.python.org/3/library/contextlib.html#contextlib.suppress and Is that the same thing as doing a try/except: pass? E: it is. Shoulda read the link. Boris Galerkin fucked around with this message at 09:53 on Apr 13, 2019 |
# ? Apr 13, 2019 09:50 |
|
Writing context managers and decorators for your own concepts is good and fun.
|
# ? Apr 13, 2019 20:13 |
|
For example, I'm writing a thing now that abstracts away different backends that mostly have the same API, but not exactly. For this one function all these backends take a parameter `handle` as an int value...except one which takes the int parameter as a specifically formatted string. So, my code works like this: I have an abstract base class that the wrapper class for each backend inherits from and implements all the abstract methods. So, a method in the abstract base class might look like this: Python code:
Python code:
Python code:
I like writing these things.
|
# ? Apr 13, 2019 23:19 |
|
I wanna get better at Django. Anyone got a solid tutorial they would like to share? I set up a Django CMS like 2 months ago, I forget most of what I learned. I remember the virtualenv stuff but not much else.
|
# ? Apr 14, 2019 04:59 |
|
I have my script running on a variety of VMs. I'm trying to work out a way to update them all centrally through a command. I've got a requirements.txt and if I'm on the machine can just go to the command prompt and do a pip install -r requirements.txt which works perfectly. I tried to automate this with the following line of code.Python code:
|
# ? Apr 14, 2019 13:43 |
|
The Xkdc Larper posted:I wanna get better at Django. Anyone got a solid tutorial they would like to share? The official tutorial is pretty good. Really, the best way to get better at any framework is to make lots of stuff with it. That being said, it sounds like maybe you need help with more than just django? virtualenv's are not just a django thing...
|
# ? Apr 14, 2019 18:17 |
|
It may be overkill but I think this is a common Ansible use case.
|
# ? Apr 14, 2019 18:37 |
|
Sad Panda posted:I have my script running on a variety of VMs. I'm trying to work out a way to update them all centrally through a command. I've got a requirements.txt and if I'm on the machine can just go to the command prompt and do a pip install -r requirements.txt which works perfectly. I tried to automate this with the following line of code. Use pssh to run this in parallel on multiple machines. unpacked robinhood posted:It may be overkill but I think this is a common Ansible use case. I think this might be overkill unless Ansible is already in use. If you already use Ansible, by all means, do this.
|
# ? Apr 14, 2019 20:55 |
|
Clustershell is also pretty nice.
|
# ? Apr 15, 2019 00:15 |
|
Which version would be better to start learning if I wanted to get into python? v2 or v3?
|
# ? Apr 15, 2019 07:15 |
|
3 almost without a doubt; you get tons of great new features and performance improvements, and even programmers of 2 are encouraged to use the future module to make their code compatible with 3 because everyone is expected to upgrade **eventually** 2 if you're working with a bunch of people who are still using 2 and refuse to update to 3
|
# ? Apr 15, 2019 07:23 |
|
3 unless you have very specific reasons to be using 2 at this point. Kind of like asking if you should run Windows XP or Windows 10
|
# ? Apr 15, 2019 07:41 |
|
Noted. Thanks guys, I'm gonna give codecademy a try and see how things roll. I've never actually coded/programmed anything before but it always bothered me that I just assumed I couldn't do it without actually giving learning it a fair shake.
|
# ? Apr 15, 2019 07:50 |
|
|
# ? May 16, 2024 02:48 |
|
Test mocking question. I have a module that i have to mock wholesale, by patching sys.modules. This works but in my code i have an except modulename.ExceptionName and I can't figure out how to trigger it. I've put an exception of the same name in my mock object but I'm assuming the namespacing is wrong at the time it runs because it never catches. Ideas?
|
# ? Apr 15, 2019 08:38 |