Method: Cnvrg::Project.create
- Defined in:
- lib/cnvrg/project.rb
.create(project_name, path = nil, clean) ⇒ Object
Create project
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cnvrg/project.rb', line 64 def self.create(project_name, path=nil,clean) if clean list_dirs = [project_name, project_name + "/.cnvrg"] else list_dirs = [project_name, project_name + "/data", project_name + "/models", project_name + "/notebooks", project_name + "/src", project_name + "/src/visualizations", project_name + "/src/features", project_name + "/.cnvrg" ] end list_files = [ project_name + "/README.md", project_name + "/.cnvrgignore", project_name + "/.cnvrg/config.yml" ] cnvrgreadme = Helpers.readme_content cnvrgignore = Helpers.cnvrgignore_content begin owner = Cnvrg::CLI.get_owner() response = Cnvrg::API.request("cli/create_project", 'POST', { title: project_name, owner:owner }) Cnvrg::CLI.is_response_success(response) response = JSON.parse response["result"] project_slug = response["slug"] config = { project_name: project_name, project_slug: project_slug, owner: owner } FileUtils.mkdir_p list_dirs FileUtils.touch list_files File.open(project_name + "/.cnvrg/config.yml", "w+") { |f| f.write config.to_yaml } File.open(project_name + "/.cnvrgignore", "w+") { |f| f.write cnvrgignore } File.open(project_name + "/README.md", "w+") { |f| f.write cnvrgreadme } rescue return false end return true end |