Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Streamlit 앱에 실험 데이터 분석을 위한 기능 추가 #41

Merged
merged 12 commits into from
Nov 23, 2024

Conversation

gsgh3016
Copy link
Contributor

@gsgh3016 gsgh3016 commented Nov 22, 2024

📝 Summary

데이터 관련 실험 시, 새로운 열이 생길 가능성이 높습니다.
현재 Streamlit 앱의 데이터 탐색 > 문제 형태로 확인 기능을 바탕으로 새로운 탭과 레이아웃을 추가합니다.
실험 데이터를 위한 파일 업로더, 실험 데이터 탭, 실험 데이터 > 문제 형태로 확인 기능을 추가했습니다.

✅ Checklist

  • 관련 이슈가 명시되어 있습니다.
  • 테스트가 완료되었습니다.
  • [ ] 문서 업데이트가 포함되었습니다.
  • 코드 리뷰를 위한 사전 검토를 완료했습니다.

📄 Description

1. 데이터 경로

기본 데이터 로드와 유사하게, 데이터 경로를 환경 변수로 관리합니다.

# .env
STREAMLIT_EXPERIMENT_DATA_PATH={your_experiment_result_path}
# analysis_dashboard.py
import os
from dotenv import load_dotenv
...
load_dotenv()
...
exp_df = pd.read_csv(os.getenv("STREAMLIT_EXPERIMENT_DATA_PATH"))

2. 새로운 파일 업로더 및 탭 생성

image

기본 학습 데이터를 df 변수에 저장, 실험 데이터를 exp_df 변수에 저장하여 따로 관리합니다.
따라서 새로운 파일 업로더와 탭 기능을 추가합니다.

3. key_manager 객체 생성 → 탭 별로 key 값을 따로 관리하도록 수정

탭 별로 고유한 Element ID를 생성하도록 탭 이름을 인자로 렌더링 함수에 넘겨줬습니다.
추후 Streamlit 앱 기능 추가 및 재사용 시 StreamlitDuplicateElementKey 에러를 방지할 수 있습니다.

4. 렌더링 모듈화

display_data_tab 함수로 기존 tab2 렌더링 구조를 모듈화하여 새로운 탭인 tab4에서 재사용하도록 코드를 수정합니다.

5. 전체 열을 순회하면서 새로운 열 렌더링

실험 데이터 탐색 > 문제 형태로 확인
문제 형태로 확인

실험 데이터 칼럼 이름 정보를 전부 순회하면서 기본 데이터 칼럼에 없을 경우, 렌더링하는 기능을 추가했습니다.

💡 Notice (Optional)

해당 기능이 제대로 동작하기 위해서는 데이터 저장 및 환경 변수 세팅이 필요합니다.
Description의 1. 데이터 경로에 세팅 방법을 작성했습니다.

Streamlit 앱 기능과 관련 없지만, Streamlit 기능 개발에 용이한 vscode 설정 파일을 추가했습니다.
analysis_dashboard.py에서 코드 라인에 breakpoint를 잡고 vscode 상단에 디버깅을 선택합니다.
스크린샷 2024-11-23 오후 2 55 01

🔗 Related Issue(s)

close #39

@gsgh3016 gsgh3016 self-assigned this Nov 22, 2024
@gsgh3016 gsgh3016 linked an issue Nov 22, 2024 that may be closed by this pull request
5 tasks
Copy link
Contributor

@eyeol eyeol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

작업하느라 고생하셨습니다. 코멘트 확인 부탁드립니다.

streamlit_utils/data_util.py Outdated Show resolved Hide resolved
streamlit_utils/data_util.py Outdated Show resolved Hide resolved
analysis_dashboard.py Outdated Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
analysis_dashboard.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jagaldol jagaldol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streamlit과 그렇게 친숙하지 않아서 코드를 봐도 어렵네요

우리 중 @eyeol 님이 가장 잘 알거 같아서 @eyeol 에게 approve를 맡기겠습니다!

제가 보기엔 일단 이상이 없어 보입니다! 👀

- Element ID가 달라지면서 세션에 저장됐던 변수 값을 읽지 못하는 것 확인
- key_manager 관련 코드 삭제
- 탭 별로 렌더링 모듈화 시, 탭 이름을 인자로 넣도록 변경
@gsgh3016
Copy link
Contributor Author

현재 @eyeol 가 언급한 버그 및 기타 검색 관련 버그 수정했습니다. 관련 내용 PR 설명에 보완하겠습니다.

Copy link
Contributor

@eyeol eyeol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 내용 확인했습니다. 고생하셨습니다.

@gsgh3016 gsgh3016 merged commit 6dbfcb5 into main Nov 23, 2024
3 checks passed
@gsgh3016 gsgh3016 deleted the feature/39-streamlit branch November 23, 2024 07:53
@gsgh3016 gsgh3016 added Priority: Low 천천히 진행해도 되는 작업 Type: Enhancement 기능 개선 작업 Status: Completed 완료 labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low 천천히 진행해도 되는 작업 Type: Enhancement 기능 개선 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] DataFrame 열에 의존하지 않는 Streamlit 레이아웃 추가
4 participants