본문 바로가기

python

Prefect 파이썬과 Prefect를 이용한 배치 프로세스 자동화 Prefect를 사용하여 데이터 워크플로우를 자동화하고 관리하는 방법을 알아봅시다. Prefect란 무엇인가? Prefect는 파이썬으로 구축된 현대적인 워크플로우 오케스트레이션 플랫폼입니다. 데이터 워크플로우를 자동화하고, 조정하며, 모니터링하는 것을 목적으로 설계되었습니다. Prefect는 배치 프로세스를 스케줄링하고, 데이터 파이프라인이 원활하게 실행되도록 보장하며, 오류를 우아하게 처리하는 데 이상적입니다. 시나리오: 엑셀 데이터 처리 및 API 요청 이 시나리오에서는 엑셀 파일에서 데이터를 로드하고, API에 POST 요청을 하는 배치 프로세스를 자동화하는 방법을 Prefect를 사용하여 다루게 됩니다. 다음과 같은 단계를 포함합니다: 엑셀 .. 더보기
Start Django project with Python DI manager poetry Poetry 설치 공식 문서 참고 Introduction | Documentation | Poetry - Python dependency management and packaging made easy Using alternative installation methods will make Poetry always use the Python version for which it has been installed to create virtualenvs. So, you will need to install Poetry for each Python version you want to use and switch between them. python-poetry.org 프로젝트 디렉터리 생성 mkdir goboard.. 더보기
python data class """" 클래스를 정의 할때 __init__ 에서 속성을 정의 하게 된다. 해당 속성이 많아질수록 불편 할 수 있다. dataclass 를 사용하여 타입 힌드만 작성 하도록 함으로써 객체의 속성을 자동으로 생성 하도록 할 수 있다. """" from dataclasses import dataclass class Person_01: def __init__(self, name, age): self.name = name self.age = name # dataclass 를 활용 해보도록 한다. # 초기화 함수를 가진 클래스를 자동으로 만들어준다. @dataclass class Person_02: name: str age: int #init -> 초기화 함수 #repr -> 런타임환경에서 출력 #eq -> 객체.. 더보기
Python application with Docker Image build and Run - create python app - (app.py) """ 샘플 app.py 에서는 아래 lib 가 필요 없으나, lib 설치 예시를 위해 작성 한것. """ import aiohttp import yaml from aiohttp import ClientSession from bs4 import BeautifulSoup import asyncio def hello(_str): print(_str) if __name__ == '__main__': hello("Hello! Docker") - created requirements.txt aiohttp==3.5.4 beautifulsoup4==4.7.1 PyYAML==5.1.1 - created Dockerfile - (DockerFile) # 파이썬 3... 더보기
python file line read and set import pathlib file_name = "sample.txt" current_path = pathlib.Path(__file__).parent with open(current_path.joinpath(file_name)) as f: set_samples = set(map(str.strip, f)) #파일을 라인단위로 읽어 set 으로 만든다. 더보기
Commands for Python with Git project Command for python with git project 더보기
python 다중 상속 """ 다중 상속 """ class Person(object): def talk(self): print('talk') def run(self): print('person run') class Car(object): def run(self): print('car run') # 다중 상속시 왼쪽부터 적용 된다, 메서드 오버라이드시 순서가 왼쪽부터 한번만 호출 된다. # class Robot(Person, Car): class Robot(Car, Person): def fly(self): print('fly') robot = Robot() robot.talk() robot.run() robot.fly() 더보기
python class """ - person class 를 extends 하여 baby 와 adult class 를 만든다. - person class 는 기본적으로 age 속성을 가진다. - person class 는 drive 기능을 가지고 있다. * 18세 이상이면 운전이 가능 하며, 아니면 운정을 할 수 없다. - baby class 의 age 값은 18 이하 여야 한다. - adult class 의 age 값은 18 이상이어야 한다. - 자동차 클래스는 모델 과 running, ride 기능을 가지고 있다. -- ride 는 person 객체를 인자로 받아 운전 기능을 수행 하도록 한다. """ ## Base class 가 될 person class class Person(object): def __init__(se.. 더보기