aws-samples / alphafold-protein-structure-prediction-with-frontend-app

Other
15 stars 5 forks source link

Error: Cannot find asset at .../app/dist #5

Closed atishuk closed 1 year ago

atishuk commented 1 year ago

Hi. I'm trying to implement your solution for Alphafold2 WebApp. And I met an issue.
I did everything as you explained in the README.md. At the step "Deploy the application. Backend". In the terminal window of Cloud9 IDE, I moved to the provisioning folder(cd provisioning) and installed Node(npm install). During the next step (npx cdk bootstrap) I received an error:

anastasia:~/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning (main) $ npx cdk bootstrap
/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssetStaging=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),crypto=require("crypto"),os=require("os"),path=require("path"),cxapi=require("../../cx-api"),constructs_1=require("constructs"),fs=require("fs-extra"),assets_1=require("./assets"),bundling_1=require("./bundling"),fs_1=require("./fs"),fingerprint_1=require("./fs/fingerprint"),names_1=require("./names"),cache_1=require("./private/cache"),stack_1=require("./stack"),stage_1=require("./stage"),ARCHIVE_EXTENSIONS=[".tar.gz",".zip",".jar",".tar",".tgz"],ASSET_SALT_CONTEXT_KEY="@aws-cdk/core:assetHashSalt";class AssetStaging extends constructs_1.Construct{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_AssetStagingProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AssetStaging),error}const salt=this.node.tryGetContext(ASSET_SALT_CONTEXT_KEY);if(this.sourcePath=path.resolve(props.sourcePath),this.fingerprintOptions={...props,extraHash:props.extraHash||salt?`${props.extraHash??""}${salt??""}`:void 0},!fs.existsSync(this.sourcePath))throw new Error(`Cannot find asset at ${this.sourcePath}`);this.sourceStats=fs.statSync(this.sourcePath);const outdir=stage_1.Stage.of(this)?.assetOutdir;if(!outdir)throw new Error('unable to determine cloud assembly asset output directory. Assets must be defined indirectly within a "Stage" or an "App" scope');this.assetOutdir=outdir,this.customSourceFingerprint=props.assetHash,this.hashType=determineHashType(props.assetHashType,this.customSourceFingerprint);let stageThisAsset,skip=!1;if(props.bundling){skip=!stack_1.Stack.of(this).bundlingRequired;const bundling=props.bundling;stageThisAsset=()=>this.stageByBundling(bundling,skip)}else stageThisAsset=()=>this.stageByCopying();this.cacheKey=calculateCacheKey({outdir:this.assetOutdir,sourcePath:path.resolve(props.sourcePath),bundling:props.bundling,assetHashType:this.hashType,customFingerprint:this.customSourceFingerprint,extraHash:props.extraHash,exclude:props.exclude,ignoreMode:props.ignoreMode,skip});const staged=AssetStaging.assetCache.obtain(this.cacheKey,stageThisAsset);this.stagedPath=staged.stagedPath,this.absoluteStagedPath=staged.stagedPath,this.assetHash=staged.assetHash,this.packaging=staged.packaging,this.isArchive=staged.isArchive}static clearAssetHashCache(){this.assetCache.clear(),fingerprint_1.clearLargeFileFingerprintCache()}get sourceHash(){return this.assetHash}relativeStagedPath(stack){try{jsiiDeprecationWarnings.aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.relativeStagedPath),error}const asmManifestDir=stage_1.Stage.of(stack)?.outdir;return asmManifestDir?path.relative(this.assetOutdir,this.stagedPath).startsWith("..")||this.stagingDisabled?this.stagedPath:path.relative(asmManifestDir,this.stagedPath):this.stagedPath}stageByCopying(){const assetHash=this.calculateHash(this.hashType),stagedPath=this.stagingDisabled?this.sourcePath:path.resolve(this.assetOutdir,renderAssetFilename(assetHash,getExtension(this.sourcePath)));if(!this.sourceStats.isDirectory()&&!this.sourceStats.isFile())throw new Error(`Asset ${this.sourcePath} is expected to be either a directory or a regular file`);return this.stageAsset(this.sourcePath,stagedPath,"copy"),{assetHash,stagedPath,packaging:this.sourceStats.isDirectory()?assets_1.FileAssetPackaging.ZIP_DIRECTORY:assets_1.FileAssetPackaging.FILE,isArchive:this.sourceStats.isDirectory()||ARCHIVE_EXTENSIONS.includes(getExtension(this.sourcePath).toLowerCase())}}stageByBundling(bundling,skip){if(!this.sourceStats.isDirectory())throw new Error(`Asset ${this.sourcePath} is expected to be a directory when bundling`);if(skip){let hashType=this.hashType;return(hashType===assets_1.AssetHashType.OUTPUT||hashType===assets_1.AssetHashType.BUNDLE)&&(this.customSourceFingerprint=names_1.Names.uniqueId(this),hashType=assets_1.AssetHashType.CUSTOM),{assetHash:this.calculateHash(hashType,bundling),stagedPath:this.sourcePath,packaging:assets_1.FileAssetPackaging.ZIP_DIRECTORY,isArchive:!0}}let assetHash=this.hashType===assets_1.AssetHashType.SOURCE||this.hashType===assets_1.AssetHashType.CUSTOM?this.calculateHash(this.hashType,bundling):void 0;const bundleDir=this.determineBundleDir(this.assetOutdir,assetHash);this.bundle(bundling,bundleDir);const bundlingOutputType=bundling.outputType??bundling_1.BundlingOutput.AUTO_DISCOVER,bundledAsset=determineBundledAsset(bundleDir,bundlingOutputType);assetHash=assetHash??this.calculateHash(this.hashType,bundling,bundledAsset.path);const stagedPath=path.resolve(this.assetOutdir,renderAssetFilename(assetHash,bundledAsset.extension));return this.stageAsset(bundledAsset.path,stagedPath,"move"),bundledAsset.packaging===assets_1.FileAssetPackaging.FILE&&fs.closeSync(fs.openSync(bundledAsset.path,"w")),{assetHash,stagedPath,packaging:bundledAsset.packaging,isArchive:!0}}get stagingDisabled(){return!!this.node.tryGetContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT)}stageAsset(sourcePath,targetPath,style){if(fs.existsSync(targetPath)){style==="move"&&sourcePath!==targetPath&&fs.removeSync(sourcePath);return}if(style=="move"){fs.renameSync(sourcePath,targetPath);return}if(this.sourceStats.isFile())fs.copyFileSync(sourcePath,targetPath);else if(this.sourceStats.isDirectory())fs.mkdirSync(targetPath),fs_1.FileSystem.copyDirectory(sourcePath,targetPath,this.fingerprintOptions);else throw new Error(`Unknown file type: ${sourcePath}`)}determineBundleDir(outdir,sourceHash){return sourceHash?path.resolve(outdir,renderAssetFilename(sourceHash)):path.resolve(outdir,`bundling-temp-${this.cacheKey}`)}bundle(options,bundleDir){if(fs.existsSync(bundleDir))return;fs.ensureDirSync(bundleDir),fs.chmodSync(bundleDir,511);const volumes=[{hostPath:this.sourcePath,containerPath:AssetStaging.BUNDLING_INPUT_DIR},{hostPath:bundleDir,containerPath:AssetStaging.BUNDLING_OUTPUT_DIR},...options.volumes??[]];let localBundling;try{if(process.stderr.write(`Bundling asset ${this.node.path}...
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ^
Error: Cannot find asset at /home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/app/dist
    at new AssetStaging (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:1264)
    at new Asset (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:736)
    at Object.bind (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1200)
    at /home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2867
    at Array.map (<anonymous>)
    at new BucketDeployment (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2848)
    at new FrontendStack (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/stacks/frontend-stack.ts:106:5)
    at Object.<anonymous> (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/bin/provisioning.ts:14:18)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Module.m._compile (/home/ec2-user/environment/alphafold-protein-structure-prediction-with-frontend-app/provisioning/node_modules/ts-node/src/index.ts:1618:23)

Subprocess exited with error 1

I think something wrong with your .gitignore file because there is no alphafold-protein-structure-prediction-with-frontend-app/app/dist folder in the GItHub repository. I checked your .gitignore and found :

dist
!dist/.gitkeep

I think this is not working correct. Can you help me to run your application?

Note from Git-gitignore: (https://git-scm.com/docs/gitignore#_pattern_format)

atishuk commented 1 year ago

Hi. I think the problem is not in .gitignore (but who knows...). The problem is in the directions in README.MD. You forgot to mention that before moving to the provisioning folder, we must run two commands from the app folder.

cd app
npm install 
npm run build 

This way, we can get the dist folder in the /app.