Elasticsearch, Airflow 활용하기 - 1. 환경설정

2025. 3. 3. 01:33·ML_DL/MUJAKJUNG (무작정 시리즈)
728x90
반응형

1. 가상환경 생성 및 라이브러리 설치 (conda activate 제발 먼저 하자)

  • Elasticsearch 로컬 다운로드
 

Download Elasticsearch

Download Elasticsearch or the complete Elastic Stack (formerly ELK stack) for free and start searching and analyzing in minutes with Elastic....

www.elastic.co

 

conda create -n ainews python>=3.12
conda activate ainews

# fastapi 관련
pip install fastapi pydantic uvicorn

# elastic 관련
pip install elasticsearch

# airflow 관련
mkdir airflow && cd airflow
pip install apache-airflow

2. 폴더 구조 생성

  • 각각 별도의 폴더를 구성하고, 각자가 하는 일은 해당 폴더 내에서 이루어질 수 있도록 한다.
│   .env
│   .gitignore
│   README.md
│   
├───airflow
├───backend
│   │   news_main.py
│   │   
│   ├───services
│   │ │ newsapi.py
│           
├───data
└───elastic
    │   article_to_es.py
    └── es_client.py

3. 뉴스 API 파일 생성

 

News API – Search News and Blog Articles on the Web

“Ascender AI has a mission to apply AI to the media, and NewsAPI is one of our most valuable resources. Ascender is redefining how users interact with complex information, and the NewsAPI feed is an essential showcase for our technologies.” Braddock Ga

newsapi.org

import requests
import os
from dotenv import load_dotenv

load_dotenv()
API_KEY = os.environ.get('API_KEY')
KEYWORD = "AI" 

def get_articles():
    url = ('https://newsapi.org/v2/top-headlines?'
        f'q={KEYWORD}&'
        'sortBy=publishedAt&' # 기사 업로드 순
        f'apiKey={API_KEY}')

    response = requests.get(url)
    return response.json()
저작자표시 (새창열림)

'ML_DL > MUJAKJUNG (무작정 시리즈)' 카테고리의 다른 글

Elasticsearch, Airflow 활용하기 - 3. Airflow 환경설정  (0) 2025.03.04
Elasticsearch, Airflow 활용하기 - 2. Elasticsearch 설정  (0) 2025.03.03
이미지 분류 모델 작성하기 (feat. wandb)  (0) 2025.02.19
프로젝트 업그레이드 1탄 - 프로젝트 생성  (0) 2025.02.06
[Llama3 파인튜닝] 코드 업데이트 및 실험 2  (0) 2024.12.25
'ML_DL/MUJAKJUNG (무작정 시리즈)' 카테고리의 다른 글
  • Elasticsearch, Airflow 활용하기 - 3. Airflow 환경설정
  • Elasticsearch, Airflow 활용하기 - 2. Elasticsearch 설정
  • 이미지 분류 모델 작성하기 (feat. wandb)
  • 프로젝트 업그레이드 1탄 - 프로젝트 생성
swwho
swwho
일상을 데이터화하다
  • swwho
    하루한장
    swwho
  • 전체
    오늘
    어제
    • 분류 전체보기 (188)
      • ML_DL (39)
        • MUJAKJUNG (무작정 시리즈) (18)
        • 딥러닝 공부하기 (21)
      • 데이터사이언스 (1)
        • EDA (1)
        • 데이터과학을 위한 통계 (0)
      • 데이터엔지니어링 (2)
      • 논문리뷰 (2)
        • Computer Vision (2)
      • Python 활용하기 (12)
      • 코딩테스트 (127)
        • Python (109)
        • MySQL (14)
      • Git (3)
      • MySQL 활용하기 (0)
      • 일상 이야기 (1)
  • 블로그 메뉴

    • 홈
    • 태그
  • 최근 글

  • 250x250
  • hELLO· Designed By정상우.v4.10.3
swwho
Elasticsearch, Airflow 활용하기 - 1. 환경설정
상단으로

티스토리툴바