Beispiel #1
0
    def _generate_csharp_code(self, dest, model_name):
        # Register the template
        exec_dotnet(['new', '-i', self.custom_template_dirpath])

        # Create the new project using the specified template
        exec_dotnet([
            'new', '{}model'.format(self.template), '-n', model_name, '-o',
            dest, '--force'
        ])

        # Restore project
        exec_nuget([
            'restore',
            os.path.join(dest, '{}.sln'.format(model_name)), '-ConfigFile',
            os.path.join(dest, 'nuget.config')
        ])

        # Copy azure-pipelines folder
        pipeline_dirname = '.azure-pipelines'
        src = os.path.join(self.base_template_dirpath, pipeline_dirname)
        copytree(src,
                 os.path.join(dest, pipeline_dirname),
                 ignore=ignore_patterns('tpl_*'))

        # Generate template
        rootdir = self._git_rel_path(dest) or model_name
        self._generate_templated_files(dest, model_name, rootdir)
Beispiel #2
0
    def package(self, platform, skip_archive):
        os.makedirs(self.package_dir_path, exist_ok=True)
        os.makedirs(self.inference_dir_path, exist_ok=True)

        template_path = os.path.join(TEMPLATE_PLATFORM_DIR_PATH, platform,
                                     CSHARP_LANG)

        # Register DLIS template
        exec_dotnet(['new', '-i', template_path])

        # Create inference project in temp dir
        exec_dotnet([
            'new', platform, '-n', self.model_name, '-o',
            self.inference_dir_path, '--force'
        ])

        self._package_dlis()
        print('Packaged the model with {} template.'.format(platform))
Beispiel #3
0
    def _package_dlis(self):
        proj_data_dir = os.path.join(self.proj_dir_path, 'data')
        inference_nuget_config_path = os.path.join(self.inference_dir_path,
                                                   'nuget.config')
        build_dir_path = os.path.join(self.inference_proj_dir_path, 'bin',
                                      'x64', self.build_mode, 'publish')

        # Publish dependency runtime
        exec_nuget([
            'restore', self.inference_sln_path, '-ConfigFile',
            inference_nuget_config_path
        ])
        exec_dotnet([
            'publish', self.inference_sln_path, '--configfile',
            inference_nuget_config_path, '-c', self.build_mode, '--force',
            '-o', build_dir_path
        ])

        # Copy runtime and static files
        copy_tree(proj_data_dir, os.path.join(self.package_dir_path, 'data'))
        self._copy_dlls(self.proj_bin_path, self.package_dir_path)
        self._copy_files(build_dir_path, self.package_dir_path)
Beispiel #4
0
 def test(self):
     self._build_project(self.sln_path)
     exec_dotnet(['test', '--', 'MSTest.DeploymentEnabled=false'])
Beispiel #5
0
 def _build_project(self, sln_path):
     exec_dotnet(['build', sln_path, '-c', self.build_mode, '--force'])