Skip to content

Commit

Permalink
Adapt git* files
Browse files Browse the repository at this point in the history
  • Loading branch information
aversey committed Jul 25, 2024
1 parent e8e2981 commit 132dfaa
Show file tree
Hide file tree
Showing 20 changed files with 332 additions and 22 deletions.
24 changes: 24 additions & 0 deletions python/hopsworks/core/git_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.core.git_api import (
GitApi,
)


__all__ = [
GitApi,
]
24 changes: 24 additions & 0 deletions python/hopsworks/core/git_op_execution_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.core.git_op_execution_api import (
GitOpExecutionApi,
)


__all__ = [
GitOpExecutionApi,
]
24 changes: 24 additions & 0 deletions python/hopsworks/core/git_provider_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.core.git_provider_api import (
GitProviderApi,
)


__all__ = [
GitProviderApi,
]
24 changes: 24 additions & 0 deletions python/hopsworks/core/git_remote_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.core.git_remote_api import (
GitRemoteApi,
)


__all__ = [
GitRemoteApi,
]
24 changes: 24 additions & 0 deletions python/hopsworks/engine/git_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.engine.git_engine import (
GitEngine,
)


__all__ = [
GitEngine,
]
94 changes: 94 additions & 0 deletions python/hopsworks/git_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import json

import humps
from hopsworks_common import util


class GitCommit:
def __init__(
self,
name=None,
email=None,
message=None,
commit_hash=None,
time=None,
type=None,
href=None,
expand=None,
items=None,
count=None,
**kwargs,
):
self._name = name
self._email = email
self._message = message
self._hash = commit_hash
self._time = time
self._type = type
self._href = href
self._expand = expand
self._items = items
self._count = count

@classmethod
def from_response_json(cls, json_dict):
if json_dict:
json_decamelized = humps.decamelize(json_dict)
if "count" in json_decamelized:
if json_decamelized["count"] == 0:
return []
return [cls(**commit) for commit in json_decamelized["items"]]
else:
return cls(**json_decamelized)
else:
return None

@property
def name(self):
"""Name of the user"""
return self._name

@property
def email(self):
"""Email of the user"""
return self._email

@property
def message(self):
"""Commit message"""
return self._message

@property
def hash(self):
"""Commit hash"""
return self._hash

@property
def time(self):
"""Timestamp for the commit"""
return self._time

def json(self):
return json.dumps(self, cls=util.Encoder)

def __str__(self):
return self.json()

def __repr__(self):
return f"GitCommit({self._name!r}, {self._message!r}, {self._hash!r})"
24 changes: 24 additions & 0 deletions python/hopsworks/git_op_execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.git_op_execution import (
GitOpExecution,
)


__all__ = [
GitOpExecution,
]
24 changes: 24 additions & 0 deletions python/hopsworks/git_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.git_provider import (
GitProvider,
)


__all__ = [
GitProvider,
]
24 changes: 24 additions & 0 deletions python/hopsworks/git_remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.git_remote import (
GitRemote,
)


__all__ = [
GitRemote,
]
24 changes: 24 additions & 0 deletions python/hopsworks/git_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from hopsworks_common.git_repo import (
GitRepo,
)


__all__ = [
GitRepo,
]
10 changes: 5 additions & 5 deletions python/hopsworks_common/core/git_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
import logging
from typing import List, Union

from hopsworks import (
from hopsworks_common import (
client,
git_commit,
git_file_status,
git_op_execution,
git_repo,
util,
)
from hopsworks.client.exceptions import GitException
from hopsworks.core import git_provider_api
from hopsworks.engine import git_engine
from hopsworks.git_file_status import GitFileStatus
from hopsworks_common.client.exceptions import GitException
from hopsworks_common.core import git_provider_api
from hopsworks_common.engine import git_engine
from hopsworks_common.git_file_status import GitFileStatus


class GitApi:
Expand Down
2 changes: 1 addition & 1 deletion python/hopsworks_common/core/git_op_execution_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

from hopsworks import client, git_op_execution
from hopsworks_common import client, git_op_execution


class GitOpExecutionApi:
Expand Down
6 changes: 3 additions & 3 deletions python/hopsworks_common/core/git_provider_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import json

from hopsworks import client, git_provider
from hopsworks.client.exceptions import GitException
from hopsworks.engine import git_engine
from hopsworks_common import client, git_provider
from hopsworks_common.client.exceptions import GitException
from hopsworks_common.engine import git_engine


class GitProviderApi:
Expand Down
4 changes: 2 additions & 2 deletions python/hopsworks_common/core/git_remote_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
#

from hopsworks import client, git_op_execution, git_remote
from hopsworks.engine import git_engine
from hopsworks_common import client, git_op_execution, git_remote
from hopsworks_common.engine import git_engine


class GitRemoteApi:
Expand Down
4 changes: 2 additions & 2 deletions python/hopsworks_common/engine/git_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import logging
import time

from hopsworks.client.exceptions import GitException
from hopsworks.core import git_op_execution_api
from hopsworks_common.client.exceptions import GitException
from hopsworks_common.core import git_op_execution_api


class GitEngine:
Expand Down
2 changes: 1 addition & 1 deletion python/hopsworks_common/git_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import json

import humps
from hopsworks import util
from hopsworks_common import util


class GitCommit:
Expand Down
Loading

0 comments on commit 132dfaa

Please sign in to comment.