Skip to content

Add job tagging to API#2774

Merged
wslulciuc merged 25 commits into
MarquezProject:mainfrom
davidsharp7:api/add_job_tags
May 7, 2024
Merged

Add job tagging to API#2774
wslulciuc merged 25 commits into
MarquezProject:mainfrom
davidsharp7:api/add_job_tags

Conversation

@davidsharp7

@davidsharp7 davidsharp7 commented Mar 17, 2024

Copy link
Copy Markdown
Member

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)

Signed-off-by: sharpd <davidsharp7@gmail.com>
@boring-cyborg boring-cyborg Bot added api API layer changes client/java labels Mar 17, 2024
@netlify

netlify Bot commented Mar 17, 2024

Copy link
Copy Markdown

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

Signed-off-by: sharpd <davidsharp7@gmail.com>
@codecov

codecov Bot commented Mar 19, 2024

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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?

@davidsharp7 davidsharp7 Apr 24, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member

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?

@davidsharp7 davidsharp7 Apr 25, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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!

Comment thread api/src/main/java/marquez/db/JobDao.java Outdated
Comment thread api/src/test/java/marquez/api/BaseResourceIntegrationTest.java Outdated
@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
Copy Markdown
Member

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.

@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
Copy Markdown
Member

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.

@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
Copy Markdown
Member

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?

Comment thread api/src/test/java/marquez/api/TagResourceIntegrationTest.java Outdated
davidsharp7 and others added 6 commits April 24, 2024 06:25
Signed-off-by: sharpd <davidsharp7@gmail.com>
Signed-off-by: sharpd <davidsharp7@gmail.com>
Signed-off-by: sharpd <davidsharp7@gmail.com>
Signed-off-by: sharpd <davidsharp7@gmail.com>

@davidjgoss davidjgoss left a comment

Copy link
Copy Markdown
Member

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

davidsharp7 commented Apr 25, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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!

Comment thread api/src/main/java/marquez/db/JobDao.java Outdated
Comment thread api/src/main/resources/marquez/db/migration/V68__add_jobs_tag_mapping.sql Outdated
davidsharp7 and others added 3 commits May 7, 2024 15:04
Signed-off-by: sharpd <davidsharp7@gmail.com>
Signed-off-by: sharpd <davidsharp7@gmail.com>

@wslulciuc wslulciuc left a comment

Copy link
Copy Markdown
Member

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
jonathanpmoraes referenced this pull request in nubank/NuMarquez Feb 6, 2025
* add job tagging to API

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix various tests that were failing

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix merge commit

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix liniting

Signed-off-by: sharpd <davidsharp7@gmail.com>

* update based on pr feedback

Signed-off-by: sharpd <davidsharp7@gmail.com>

* lint tag test code

Signed-off-by: sharpd <davidsharp7@gmail.com>

* lint tag  code

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix log typo

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix logging

Signed-off-by: sharpd <davidsharp7@gmail.com>

* update based on PR feedback.

Signed-off-by: sharpd <davidsharp7@gmail.com>

* correct db field error

Signed-off-by: sharpd <davidsharp7@gmail.com>

---------

Signed-off-by: sharpd <davidsharp7@gmail.com>
Co-authored-by: Willy Lulciuc <willy@datakin.com>
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