Skip to content

Commit f6b9941

Browse files
PJEstradaPJEstrada
andauthored
Support Pytorch & Tensorflow Formats on Datasets (#4)
* feat: add explore() * fix: increase limits for ids fetching * feat: add parallel fetch * add pypi publishing Co-authored-by: Pablo <[email protected]>
1 parent 954a8f2 commit f6b9941

File tree

6 files changed

+401
-339
lines changed

6 files changed

+401
-339
lines changed

.github/workflows/publish_pypi.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Docker Images
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
Publish-SDK-pypi:
7+
runs-on: ubuntu-latest
8+
env:
9+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
10+
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
11+
steps:
12+
- name: Check out repository code
13+
uses: actions/checkout@v2
14+
- name: Get Release Tag
15+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
16+
- name: Test
17+
run: |
18+
echo $RELEASE_VERSION
19+
echo ${{ env.RELEASE_VERSION }}
20+
- name: Set Release to Diffgram SDK version
21+
run: |
22+
export DIFFGRAM_SDK_VERSION=${{ env.RELEASE_VERSION }}
23+
- name: Echo
24+
run: echo ${{ steps.tag.outputs.result }}
25+
- name: Install Twine
26+
run: |
27+
sudo apt-get update -y
28+
sudo apt-get install -y twine
29+
- name: Build Dist
30+
run: |
31+
cd sdk
32+
python setup.py sdist bdist_wheel
33+
- name: Upload with Twine
34+
run: twine upload dist/* --skip-existing --username ${{ secrets.TWINE_PASSWORD }} --password ${{ secrets.TWINE_USERNAME }}

sdk/diffgram/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import os
12
__name__ = "diffgram"
2-
__version__ = "0.3.4"
3+
__version__ = os.getenv('DIFFGRAM_SDK_VERSION')
34

45
from diffgram.core.core import Project
56
from diffgram.file.file import File

sdk/diffgram/core/core.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,18 @@ def __init__(
4949
self.host = host
5050
self.directory_id = None
5151
self.name_to_file_id = None
52-
5352
self.auth(
5453
project_string_id = project_string_id,
5554
client_id = client_id,
5655
client_secret = client_secret)
57-
5856
self.file = FileConstructor(self)
5957
self.train = Train(self)
6058
self.job = Job(self)
6159
self.guide = Guide(self)
62-
self.directory = Directory(self)
60+
self.directory = Directory(self, validate_ids = False)
6361
self.export = Export(self)
6462
self.task = Task(client = self)
65-
63+
6664
def get_member_list(self):
6765
url = '/api/project/{}/view'.format(self.project_string_id)
6866
response = self.session.get(url=self.host + url)

sdk/diffgram/core/diffgram_dataset_iterator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class DiffgramDatasetIterator:
66

7-
def __init__(self, project, diffgram_file_id_list):
7+
def __init__(self, project, diffgram_file_id_list, validate_ids = True):
88
"""
99
1010
:param project (sdk.core.core.Project): A Project object from the Diffgram SDK
@@ -14,7 +14,8 @@ def __init__(self, project, diffgram_file_id_list):
1414

1515
self.project = project
1616
self._internal_file_list = []
17-
self.__validate_file_ids()
17+
if validate_ids:
18+
self.__validate_file_ids()
1819
self.current_file_index = 0
1920

2021
def __iter__(self):
@@ -37,6 +38,8 @@ def __next__(self):
3738
return instance_data
3839

3940
def __validate_file_ids(self):
41+
if not self.diffgram_file_id_list:
42+
return
4043
result = self.project.file.file_list_exists(self.diffgram_file_id_list)
4144
if not result:
4245
raise Exception(

0 commit comments

Comments
 (0)