Exemplo n.º 1
0
def create_code_repo(repo_path: str,
                     url: str,
                     revision: str,
                     connection: str = None):
    try:
        clone_url = get_clone_url(url)
    except Exception as e:
        raise PolyaxonContainerException(
            "Error parsing url: {}.".format(url)) from e

    clone_git_repo(repo_path=repo_path, url=clone_url)
    set_remote(repo_path=repo_path, url=url)
    if revision:
        checkout_revision(repo_path=repo_path, revision=revision)

    if not settings.CLIENT_CONFIG.no_api:
        try:
            owner, project, run_uuid = get_run_info()
        except PolyaxonClientException as e:
            raise PolyaxonContainerException(e)

        code_ref = get_code_reference(path=repo_path, url=url)
        artifact_run = V1RunArtifact(
            name=code_ref.get("commit"),
            kind=V1ArtifactKind.CODEREF,
            connection=connection,
            summary=code_ref,
            is_input=True,
        )
        RunClient(owner=owner, project=project,
                  run_uuid=run_uuid).log_artifact_lineage(artifact_run)
Exemplo n.º 2
0
 def log_code_ref(self):
     self.client.experiment.create_code_reference(
         owner=self.owner,
         project_name=self.project_name,
         experiment_id=self.experiment_id,
         coderef=get_code_reference(),
         async_req=True,
     )
Exemplo n.º 3
0
 def log_code_ref(self):
     code_ref = get_code_reference()
     if code_ref:
         artifact_run = V1RunArtifact(
             name=code_ref.get("commit"),
             kind=V1ArtifactKind.CODEREF,
             summary=code_ref,
             is_input=True,
         )
         self.log_artifact_lineage(body=artifact_run)
Exemplo n.º 4
0
    def log_code_ref(self, code_ref: Dict = None):
        """Logs code reference.

        Args:
            code_ref: dict, optional, if not provided,
                Polyaxon will detect the code reference from the git repo in the current path.
        """
        code_ref = code_ref or get_code_reference()
        if code_ref and "commit" in code_ref:
            artifact_run = V1RunArtifact(
                name=code_ref.get("commit"),
                kind=V1ArtifactKind.CODEREF,
                summary=code_ref,
                is_input=True,
            )
            self.log_artifact_lineage(body=artifact_run)
Exemplo n.º 5
0
def create_code_repo(
    repo_path: str,
    url: str,
    revision: str,
    connection: str = None,
    flags: List[str] = None,
):
    try:
        clone_url = get_clone_url(url)
    except Exception as e:
        raise PolyaxonContainerException(
            "Error parsing url: {}.".format(url)) from e

    if flags and "--experimental-fetch" in flags:
        flags.remove("--experimental-fetch")
        fetch_git_repo(repo_path=repo_path,
                       clone_url=clone_url,
                       revision=revision,
                       flags=flags)
    else:
        clone_and_checkout_git_repo(repo_path=repo_path,
                                    clone_url=clone_url,
                                    revision=revision,
                                    flags=flags)
    # Update remote
    set_remote(repo_path=repo_path, url=url)

    if settings.CLIENT_CONFIG.no_api:
        return

    try:
        run_client = RunClient()
    except PolyaxonClientException as e:
        raise PolyaxonContainerException(e)

    code_ref = get_code_reference(path=repo_path, url=url)
    artifact_run = V1RunArtifact(
        name=code_ref.get("commit"),
        kind=V1ArtifactKind.CODEREF,
        connection=connection,
        summary=code_ref,
        is_input=True,
    )
    run_client.log_artifact_lineage(artifact_run)