Skip to content
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

Add job tagging to API #2774

Merged
merged 25 commits into from
May 7, 2024
Merged

Conversation

davidsharp7
Copy link
Member

@davidsharp7 davidsharp7 commented Mar 17, 2024

Problem

Currently we have no tag support for jobs.

Closes: #2756

Solution

  • Adding new table jobs_tag_mapping to store the relationship between jobs and tags.
  • Update jobs meta to return the tags as a list.
  • Add POST/DELETE end points to add and delete tags.
Screenshot 2024-03-17 at 22 26 30 Screenshot 2024-03-17 at 22 27 01 One-line summary:

Add job tagging to API

Checklist

  • You've signed-off your work
  • Your changes are accompanied by tests (if relevant)
  • Your change contains a small diff and is self-contained
  • You've updated any relevant documentation (if relevant)
  • You've included a one-line summary of your change for the CHANGELOG.md (Depending on the change, this may not be necessary).
  • You've versioned your .sql database schema migration according to Flyway's naming convention (if relevant)
  • You've included a header in any source code files (if relevant)

@boring-cyborg boring-cyborg bot added api API layer changes client/java labels Mar 17, 2024
Copy link

netlify bot commented Mar 17, 2024

Deploy Preview for peppy-sprite-186812 canceled.

Name Link
🔨 Latest commit bf6621e
🔍 Latest deploy log https://app.netlify.com/sites/peppy-sprite-186812/deploys/663a4ce80f1807000836ffb4

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.57%. Comparing base (ae794a9) to head (10703c1).

❗ Current head 10703c1 differs from pull request most recent head bf6621e. Consider uploading reports for the commit bf6621e to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2774      +/-   ##
============================================
+ Coverage     84.47%   84.57%   +0.09%     
- Complexity     1430     1441      +11     
============================================
  Files           251      251              
  Lines          6462     6503      +41     
  Branches        299      302       +3     
============================================
+ Hits           5459     5500      +41     
  Misses          850      850              
  Partials        153      153              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidsharp7 davidsharp7 marked this pull request as ready for review March 19, 2024 22:51
NOW(),
NOW(),
:tagName,
'No Description'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we would want to hardcode this in the SQL, instead of in our application code to be a bit more flexible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description is a nullable column from what I can see, I'm not sure we need to default it at all?

Copy link
Member Author

@davidsharp7 davidsharp7 Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can leave as null - was just being explicit more than anything but it is inconsistent with dataset/dataset field tagging so makes sense to set to null.

Job job =
jobService
.findJobByName(namespaceName.getValue(), jobName.getValue())
.orElseThrow(() -> new JobNotFoundException(jobName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be quite unlikely given updateJobTags would presumably throw if the job didn't exist? A case of, we get an optional back so we should do something beyond an unqualified get() on it?

Copy link
Member Author

@davidsharp7 davidsharp7 Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah understand what you mean -it will fall over before it gets to this point so why bother? Mainly as that seems to be the de-facto pattern for a lot of the code i.e

execute something -> retrieve object (job, dataset etc) else throw an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following our code style!

api/src/main/java/marquez/db/JobDao.java Outdated Show resolved Hide resolved
@@ -22,6 +22,7 @@ public class JobMeta {
@Getter private final JobType type;
@Getter private final Set<DatasetId> inputs;
@Getter private final Set<DatasetId> outputs;
@Getter @NonNull private final Set<String> tags;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disparity between @NonNull here and @Nullable in the constructor. The builder also doesn't specify - I think nullable makes sense though? For backwards-compatibility, especially.

@@ -43,6 +45,7 @@ public final class Job {
@Getter private final ImmutableMap<String, Object> facets;
@Nullable private UUID currentVersion;
@Getter @Nullable private ImmutableList<String> labels;
@Getter private final ImmutableSet<TagName> tags;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mark this @Nullable here? Would be consistent with other fields.

@@ -33,6 +34,7 @@ public final class Job extends JobMeta {
@Nullable private final Run latestRun;
@Getter private final Map<String, Object> facets;
@Nullable private final UUID currentVersion;
@Getter @NonNull private final Set<String> tags;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class extends JobMeta which already defines tags as a field - I don't think we need to define it again here, but rather pass it through into the super ctor?

Copy link
Contributor

@davidjgoss davidjgoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Not sure why webpack build is failing, as it runs okay for me locally. Could be it's maxing out resources?

@davidsharp7
Copy link
Member Author

davidsharp7 commented Apr 25, 2024

It's a 137 exit code which is OOM so yes you out of resource. Did this a couple of weeks ago and then came right.

@davidsharp7 davidsharp7 self-assigned this May 2, 2024
@MarquezProject MarquezProject locked and limited conversation to collaborators May 3, 2024
@MarquezProject MarquezProject unlocked this conversation May 3, 2024
@davidsharp7 davidsharp7 requested a review from wslulciuc May 5, 2024 05:32
Job job =
jobService
.findJobByName(namespaceName.getValue(), jobName.getValue())
.orElseThrow(() -> new JobNotFoundException(jobName));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following our code style!

api/src/main/java/marquez/db/JobDao.java Outdated Show resolved Hide resolved
Copy link
Member

@wslulciuc wslulciuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited to see tagging support for jobs! (And soon in the Web UI 🚀 )

@wslulciuc wslulciuc added this to the 0.47.0 milestone May 7, 2024
@wslulciuc wslulciuc enabled auto-merge (squash) May 7, 2024 15:55
@wslulciuc wslulciuc merged commit 00b6d35 into MarquezProject:main May 7, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API layer changes client/java
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Tag support for Jobs
4 participants