규도자 개발 블로그

파이썬 함수의 매개변수에 쓰이는 bare asterisk(*)의 의미 def include_router( self, router: routing.APIRouter, *, prefix: str = "", tags: Optional[List[Union[str, Enum]]] = None, dependencies: Optional[Sequence[Depends]] = None, responses: Optional[Dict[Union[int, str], Dict[str, Any]]] = None, deprecated: Optional[bool] = None, include_in_schema: bool = True, default_response_class: Type[Response] = Default(JSONR..
파이썬의 유닛테스트를 한번에 파악할 수 있는 코드 # unittest_example.py import unittest def add(a, b): return a + b def sub(a, b): return a - b def mul(a, b): return a * b def div(a, b): return a / b class DummyTest(unittest.TestCase): def test_add(self): c = add(10, 20) self.assertEqual(c, 30) def test_sub(self): c = sub(20, 10) self.assertEqual(c, 10) def test_mul(self): c = mul(10, 10) self.assertEqual(c, 100) def..
파이썬의 이스터에그 import this 를 써서 실행해보자. 그러면 이런 글들이 나온다. The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors sh..

닿진 않겠지만 I love you tiangolo. https://this-programmer.tistory.com/469 예전에 이런 글도 썼었다. FastAPI에 총 3개의 PR을 날려놨었는데 그 내용인 즉슨 1. openAPI docs로 endpoint들을 조회할 때 schema형태로 parameter를 등록해놔도 description이 누락되지 않게 하는 PR https://github.com/tiangolo/fastapi/pull/4573 -> 이건 schema를 이용해서 엔드포인트를 만들 때 해당 필드가 갖고 있는 description이라는 클래스 멤버를 누락시켜버려서 openAPI docs에 명세가 되지 않아 불편함을 느껴 제작하였고 2. allow_rough_response_model이라는..
airflow에서 각종 operator로 분기처리하기 (feat. SimpleHttpOperator) airflow의 기본적인 tutorial에서 제공되는 BranchPythonOperator처럼 조건에 따라 여러개의 branch를 태우는 방법에 대해서 고민했다. 나는 당연히 SimpleHttpOperator도, BashOperator도 branch operator가 따로 존재할 줄 알았는데 오직 BranchPythonOperator만 존재했다. 왜 branch operator가 중요하냐, 다른 operator는 True와 False만으로 분기처리를 해야하고, 조건에 따른 다음 task는 triger_rule을 이용해 컨트롤해야 하므로 보다 복잡한 분기처리가 불가능하다는 문제가 있었다. 예를 들어 전 b..

github actions의 자세한 실행환경 + 요청 IP 알아보기 업무 중 이런 일이 있었다. 온프레미스로 운용되고 있는 서버에 gitOps를 도입해야 했지만 k8s상에서 노드로 잡혀 있는 서버가 아니었으므로 argoCD같은 걸로 디플로이먼트가 참조하여 서비스를 갱신할 수 있을만 한 manifest파일도 없었다. 결국 github actions상에서 ssh 접속을 통해 이미지를 pull 받는 스크립트를 실행하는 형태로 구현하는 것으로 가닥이 잡혔는데 이상하게 접속이 안되는 것이다. 내가 이럴 때마다 자주 표현하는 방식이 있는데 진짜 때려 죽여도 접속이 안됐다. 그때 사용했던 건 https://github.com/appleboy/ssh-action 여기서 제공하는 action이었다. 그래서 혹시 이 프로..