Open Ningensei848 opened 3 years ago
@Ningensei848 利用される予定のRDFファイルが以下に公開されていましたので、私のほうでも試してみました。 https://github.com/Ningensei848/ML4Keiba/tree/main/data/turtle/result
まず、
$ pip install tqdm
$ python dump.py
を実行すると、約600MBのTurtleファイルが生成されました。
lambda上で使用する形式に変換すると、730MB(sparql.db
ディレクトリ内ファイルサイズ)となりました。
これは私がこのプログラムで想定していたデータサイズを大きく超えているため、無理やり利用することも改修すれば可能ですが(EFSをマウントしてそこに展開して使用する等)、パフォーマンス面も含めて残念ながら oxigraph-sparql-api-serverless
を利用するのは現実的ではないように思いました。
もし oxigraph-sparql-api-serverless
を利用されるのであれば、以下を検討されてはいかがでしょうか。
(1) 使用しない、または使用頻度の低いデータを削除してデータサイズを減らす
(2) 年単位(2011~2020年)で管理されているように見えますので、各年毎に oxigraph-sparql-api-serverless
でエンドポイントを構築する
上記 (2) について、勝手ながら ML4Keiba
から2020年のデータのみ抽出して、oxigraph-sparql-api-serverless
を利用してエンドポイントを立ててみました。
https://u6j5feewv7.execute-api.ap-northeast-1.amazonaws.com/Prod/sparql
もし (2) でも利用を検討される場合は、使えるかの判断に使ってみてください。
1~2週間程度で環境を削除しますので、よろしくお願いします。
If the
dump.ttl
gets too big, it seems to easily hit the 250MB limit.If we use Deploy by Container Image, it seems to reduce the limit to 10GB. How can I rewrite the code?
dump.ttl
が大きくなると簡単に250MB制限に引っかかってしまうようです.コンテナイメージによるデプロイ を利用すれば,制限が10GBまで緩和されるようですが,どのようにコードを書き換えればいいでしょうか?
(参考)私の書いたコード
cf. [`.github/workflows/deploy_to_lambda.yml`](https://github.com/Ningensei848/ML4Keiba/blob/main/.github/workflows/deploy_to_lambda.yml) ```yaml name: Deploy to AWS Lambda on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ main ] paths: - 'data/turtle/**' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: Deploy-to-AWS-Lambda: runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - name: install AWS SAM CLI run: | curl -OL https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip unzip aws-sam-cli-linux-x86_64.zip -d sam-installation sudo ./sam-installation/install sam --version - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} # ttl をまとめて,dump.ttl として出力 - name: Combine turtle files run: | pip install tqdm python dump.py # oxigraph-sparql-api-serverlessでコンパイルする - name: Clone repository run: | git clone https://github.com/uedayou/oxigraph-sparql-api-serverless.git --recursive mv dump.ttl oxigraph-sparql-api-serverless/rdf/dump.ttl # pull docker image from dockerhub and compile - name: compile run: | docker pull ningensei848/oxigraph-sparql-api-serverless:latest docker container run --rm -v $PWD:/code -v $HOME/.cargo/registry:/root/.cargo/registry -v $HOME/.cargo/git:/root/.cargo/git ningensei848/oxigraph-sparql-api-serverless working-directory: oxigraph-sparql-api-serverless - name: Finally, deploy to lambda by AWS SAM CLI run: | sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket $AWS_BUCKET_NAME --region $AWS_REGION sam deploy --template-file packaged.yaml --stack-name ML4Keiba --capabilities CAPABILITY_IAM --region $AWS_REGION env: AWS_REGION: ${{ secrets.AWS_REGION }} AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }} working-directory: oxigraph-sparql-api-serverless ``` On last step: `Finally, when I run deploy to lambda by AWS SAM CLI`, I get the following error. 最後のステップ:`Finally, deploy to lambda by AWS SAM CLI` を実行すると以下のエラーが出る > Error: Failed to create/update the stack: ML4Keiba, Waiter StackUpdateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "UPDATE_ROLLBACK_COMPLETE" at least once > Resource handler returned message: "Unzipped size must be smaller than 262144000 bytes (Service: Lambda, Status Code: 400, Request ID: XXXXXXX YYYYYYYY ZZZZZZZZ , Extended Request ID: null)" (RequestToken: XXXXX-YYYYY-ZZZZZ-WWWWW , HandlerErrorCode: InvalidRequest)