-
Notifications
You must be signed in to change notification settings - Fork 42
fix: enable read gcs file from local #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e633052
feat: add support for using python-udf
jesrypandawa aacfd47
fix: fix sample python config properties
jesrypandawa 165c283
feat: add config mapper
jesrypandawa e9c66a3
fix: register the python config one by one without map
jesrypandawa d6fed9d
fix: fix sample config
jesrypandawa 339f435
chore: bump up version to 0.2.7
jesrypandawa c4477fe
fix: adding exception class and fix test
jesrypandawa 37c9f46
fix: change primitive type for python udf config
jesrypandawa 85e978f
fix: fix python file test
jesrypandawa 6661d74
fix: fix python exception
jesrypandawa fff30de
fix: fix python test read zip exclude text file
jesrypandawa 0a168ca
fix: move register python config inside if statement
jesrypandawa 5631780
fix: enable to read file from gcs on local
jesrypandawa 5e4838b
Merge branch 'feat/add-support-python-udf' into python-udf
jesrypandawa f450bac
fix: create abstraction for python file types and sources
jesrypandawa e3ca695
chore: remove whitespace
jesrypandawa 245177a
refactor: refactor python factory class
jesrypandawa 5fec7db
fix: add exception on interface method and add more test
jesrypandawa c995a58
test: add gcs client test
jesrypandawa 1c15744
feat: add python workflow (#155)
jesrypandawa f7f6ae3
Revert "feat: add python workflow (#155)" (#159)
MayurGubrele dd800b6
chore: replace test files and refactor test
jesrypandawa 9571e5e
Merge branch 'feat/add-support-python-udf' into python-udf
jesrypandawa f87c793
fix: refactor python files and python_release
jesrypandawa aa18b52
refactor: move hadoop libraries to common
prakharmathur82 2e1f15e
chore: refactor python files structure and sample udf
jesrypandawa 7404ae4
refactor: refactor zip structure
jesrypandawa f239da9
fix: fix data zip structure
jesrypandawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...unctions/src/main/java/io/odpf/dagger/functions/exceptions/PythonFilesEmptyException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package io.odpf.dagger.functions.exceptions; | ||
|
|
||
| /** | ||
| * The type Python files empty exception. | ||
| */ | ||
| public class PythonFilesEmptyException extends RuntimeException { | ||
|
|
||
| /** | ||
| * Instantiates a new Python files empty exception. | ||
| * | ||
| * @param message the message | ||
| */ | ||
| public PythonFilesEmptyException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| } |
17 changes: 0 additions & 17 deletions
17
...tions/src/main/java/io/odpf/dagger/functions/exceptions/PythonFilesNotFoundException.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...-functions/src/main/java/io/odpf/dagger/functions/udfs/python/file/source/FileSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package io.odpf.dagger.functions.udfs.python.file.source; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * The interface File source. | ||
| */ | ||
| public interface FileSource { | ||
|
|
||
| /** | ||
| * Get object file byte [ ]. | ||
| * | ||
| * @return the byte [ ] | ||
| */ | ||
| byte[] getObjectFile() throws IOException; | ||
| } |
29 changes: 29 additions & 0 deletions
29
...ons/src/main/java/io/odpf/dagger/functions/udfs/python/file/source/FileSourceFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package io.odpf.dagger.functions.udfs.python.file.source; | ||
|
|
||
| import io.odpf.dagger.functions.udfs.python.file.source.gcs.GcsFileSource; | ||
| import io.odpf.dagger.functions.udfs.python.file.source.local.LocalFileSource; | ||
|
|
||
| /** | ||
| * The type File source factory. | ||
| */ | ||
| public class FileSourceFactory { | ||
|
|
||
| /** | ||
| * Gets file source. | ||
| * | ||
| * @param pythonFile the python file | ||
| * @return the file source | ||
| */ | ||
| public static FileSource getFileSource(String pythonFile) { | ||
| if ("GS".equals(getFileSourcePrefix(pythonFile))) { | ||
| return new GcsFileSource(pythonFile); | ||
| } else { | ||
| return new LocalFileSource(pythonFile); | ||
| } | ||
| } | ||
|
|
||
| private static String getFileSourcePrefix(String pythonFile) { | ||
| String[] files = pythonFile.split("://"); | ||
| return files[0].toUpperCase(); | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
...nctions/src/main/java/io/odpf/dagger/functions/udfs/python/file/source/gcs/GcsClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package io.odpf.dagger.functions.udfs.python.file.source.gcs; | ||
|
|
||
| import com.google.cloud.storage.Blob; | ||
| import com.google.cloud.storage.BlobId; | ||
| import com.google.cloud.storage.Storage; | ||
| import com.google.cloud.storage.StorageOptions; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * The type Gcs client. | ||
| */ | ||
| public class GcsClient { | ||
|
|
||
| private Storage storage; | ||
|
|
||
| /** | ||
| * Instantiates a new Gcs client. | ||
| */ | ||
| public GcsClient() { | ||
|
|
||
| if (storage == null) { | ||
| storage = StorageOptions.newBuilder() | ||
| .build().getService(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Instantiates a new Gcs client. | ||
| * This constructor used for unit test purposes. | ||
| * | ||
| * @param storage the storage | ||
| */ | ||
| public GcsClient(Storage storage) { | ||
| this.storage = storage; | ||
| } | ||
|
|
||
| /** | ||
| * Get file byte [ ]. | ||
| * | ||
| * @param pythonFile the python file | ||
| * @return the byte [ ] | ||
| */ | ||
| public byte[] getFile(String pythonFile) { | ||
| List<String> file = Arrays.asList(pythonFile.replace("gs://", "").split("/")); | ||
|
|
||
| String bucketName = file.get(0); | ||
| String objectName = file.stream().skip(1).collect(Collectors.joining("/")); | ||
|
|
||
| Blob blob = storage.get(BlobId.of(bucketName, objectName)); | ||
|
|
||
| return blob.getContent(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.