Skip to content

Commit 5c03568

Browse files
committed
feat: add profile matching & grading and job matching
1 parent d6131de commit 5c03568

5 files changed

Lines changed: 289 additions & 0 deletions

File tree

hrflow/job/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .asking import JobAsking
22
from .embedding import JobEmbedding
3+
from .matching import JobMatching
34
from .parsing import JobParsing
45
from .reasoning import JobReasoning
56
from .scoring import JobScoring
@@ -17,3 +18,4 @@ def __init__(self, client):
1718
self.scoring = JobScoring(self.client)
1819
self.reasoning = JobReasoning(self.client)
1920
self.storing = JobStoring(self.client)
21+
self.matching = JobMatching(self.client)

hrflow/job/matching.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import json
2+
3+
from ..core.rate_limit import rate_limiter
4+
from ..core.validation import (
5+
KEY_REGEX,
6+
ORDER_BY_VALUES,
7+
SORT_BY_VALUES,
8+
validate_key,
9+
validate_limit,
10+
validate_page,
11+
validate_provider_keys,
12+
validate_reference,
13+
validate_response,
14+
validate_value,
15+
)
16+
17+
18+
class JobMatching:
19+
def __init__(self, api):
20+
"""Init."""
21+
self.client = api
22+
23+
@rate_limiter
24+
def list(
25+
self,
26+
board_key,
27+
job_key=None,
28+
job_reference=None,
29+
board_keys=None,
30+
page=1,
31+
limit=30,
32+
sort_by="created_at",
33+
order_by=None,
34+
created_at_min=None,
35+
created_at_max=None,
36+
**kwargs,
37+
):
38+
"""
39+
Retrieve the matching information.
40+
41+
Args:
42+
job_key: <string>
43+
job_reference: <string>
44+
board_key: <string>
45+
baord_keys: <list>
46+
limit: <int> (default to 30)
47+
number of fetched jobs/page
48+
page: <int> REQUIRED default to 1
49+
number of the page associated to the pagination
50+
sort_by: <string>
51+
order_by: <string>
52+
created_at_min: <string>
53+
The minimum date of creation of the targeted Jobs.
54+
Format : "YYYY-MM-DD".
55+
created_at_max: <string>
56+
The maximum date of creation of the targeted Jobs.
57+
Format : "YYYY-MM-DD".
58+
Returns
59+
Applies the params to filter on Jobs in the targeted Boards and
60+
returns the response from the endpoint.
61+
Response examples :
62+
- Success response :
63+
{
64+
"code": 200, # response code
65+
"message": "Job Matching results", # response message
66+
"meta" : {'page': 1, # current page
67+
'maxPage': 5, # max page in the paginated response
68+
'count': 2, # number of jobs in the current page
69+
'total': 10}, # total number of jobs retrieved
70+
"data": { # list of jobs objects
71+
"predictions":[
72+
[]
73+
]
74+
"jobs":[
75+
{
76+
"key": "xxx",
77+
"reference": "xxx",
78+
...
79+
},
80+
...
81+
]
82+
}
83+
}
84+
- Error response : (if the board_key is not valid)
85+
{
86+
"code": 400,
87+
"message": "Invalid parameters. Unable to find object: source"
88+
}
89+
90+
"""
91+
92+
query_params = {
93+
"board_key": validate_key("Board", board_key, regex=KEY_REGEX),
94+
"job_key": validate_key("Key", job_key, regex=KEY_REGEX),
95+
"job_reference": validate_reference(job_reference),
96+
"board_keys": json.dumps(validate_provider_keys(board_keys)),
97+
"limit": validate_limit(limit),
98+
"page": validate_page(page),
99+
"sort_by": validate_value(sort_by, SORT_BY_VALUES, "sort by"),
100+
"order_by": validate_value(order_by, ORDER_BY_VALUES, "order by"),
101+
"created_at_min": created_at_min, # TODO validate dates format
102+
"created_at_max": created_at_max, # TODO validate dates format
103+
}
104+
105+
params = {**query_params, **kwargs}
106+
response = self.client.get("jobs/matching", params)
107+
return validate_response(response)

hrflow/profile/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from .asking import ProfileAsking
44
from .attachment import ProfileAttachments
55
from .embedding import ProfileEmbedding
6+
from .grading import ProfileGrading
7+
from .matching import ProfileMatching
68
from .parsing import ProfileParsing
79
from .reasoning import ProfileReasoning
810
from .revealing import ProfileRevealing
@@ -35,3 +37,5 @@ def __init__(self, client):
3537
self.searching = ProfileSearching(self.client)
3638
self.reasoning = ProfileReasoning(self.client)
3739
self.unfolding = ProfileUnfolding(self.client)
40+
self.matching = ProfileMatching(self.client)
41+
self.grading = ProfileGrading(self.client)

hrflow/profile/grading.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import json
2+
import typing as t
3+
4+
from ..core.rate_limit import rate_limiter
5+
from ..core.validation import (
6+
KEY_REGEX,
7+
ORDER_BY_VALUES,
8+
SORT_BY_VALUES,
9+
validate_key,
10+
validate_limit,
11+
validate_page,
12+
validate_provider_keys,
13+
validate_reference,
14+
validate_response,
15+
validate_value,
16+
)
17+
18+
19+
class ProfileGrading:
20+
def __init__(self, api):
21+
"""Init."""
22+
self.client = api
23+
24+
@rate_limiter
25+
def get(
26+
self,
27+
algorithm_key: t.Literal[
28+
"1d07451c0f33091869bd3c6d336dfa4e5c63af74",
29+
"daaa0f61b72a68b985f31d123ad45b361adc91e4",
30+
],
31+
source_key,
32+
board_key,
33+
profile_key=None,
34+
profile_reference=None,
35+
job_key=None,
36+
job_reference=None,
37+
):
38+
"""
39+
💾 Grade a Profile indexed in a Source for a Job
40+
(https://api.hrflow.ai/v1/profile/grading).
41+
42+
Args:
43+
source_key: <string>
44+
The key of the Source where the profile is indexed.
45+
key: <string>
46+
The Profile unique identifier.
47+
reference: <string>
48+
The Profile reference chosen by the customer.
49+
job_key: <string>
50+
job_reference: <string>
51+
board_key: <string>
52+
53+
Returns
54+
Get information
55+
56+
"""
57+
query_params = {
58+
"algorithm_key": algorithm_key,
59+
"source_key": validate_key("Source", source_key, regex=KEY_REGEX),
60+
"profile_key": validate_key("Key", profile_key, regex=KEY_REGEX),
61+
"profile_reference": validate_reference(profile_reference),
62+
"board_key": validate_key("Board", board_key, regex=KEY_REGEX),
63+
"job_key": validate_key("Key", job_key, regex=KEY_REGEX),
64+
"job_reference": validate_reference(job_reference),
65+
}
66+
67+
response = self.client.get("profile/grading", query_params)
68+
return validate_response(response)

hrflow/profile/matching.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import json
2+
3+
from ..core.rate_limit import rate_limiter
4+
from ..core.validation import (
5+
KEY_REGEX,
6+
ORDER_BY_VALUES,
7+
SORT_BY_VALUES,
8+
validate_key,
9+
validate_limit,
10+
validate_page,
11+
validate_provider_keys,
12+
validate_reference,
13+
validate_response,
14+
validate_value,
15+
)
16+
17+
18+
class ProfileMatching:
19+
def __init__(self, api):
20+
"""Init."""
21+
self.client = api
22+
23+
@rate_limiter
24+
def list(
25+
self,
26+
source_key,
27+
profile_key=None,
28+
profile_reference=None,
29+
source_keys=None,
30+
page=1,
31+
limit=30,
32+
sort_by="created_at",
33+
order_by=None,
34+
created_at_min=None,
35+
created_at_max=None,
36+
**kwargs,
37+
):
38+
"""
39+
Retrieve the matching information.
40+
41+
Args:
42+
profile_key: <string>
43+
profile_reference: <string>
44+
source_key: <string>
45+
source_keys: <list>
46+
source_keys
47+
limit: <int> (default to 30)
48+
number of fetched profiles/page
49+
page: <int> REQUIRED default to 1
50+
number of the page associated to the pagination
51+
sort_by: <string>
52+
order_by: <string>
53+
created_at_min: <string>
54+
The minimum date of creation of the targeted Profiles.
55+
Format : "YYYY-MM-DD".
56+
created_at_max: <string>
57+
The maximum date of creation of the targeted Profiles.
58+
Format : "YYYY-MM-DD".
59+
Returns
60+
Applies the params to filter on Profiles in the targeted Sources and
61+
returns the response from the endpoint.
62+
Response examples :
63+
- Success response :
64+
{
65+
"code": 200, # response code
66+
"message": "Profile Matching results", # response message
67+
"meta" : {'page': 1, # current page
68+
'maxPage': 5, # max page in the paginated response
69+
'count': 2, # number of profiles in the current page
70+
'total': 10}, # total number of profiles retrieved
71+
"data": { # list of profiles objects
72+
"predictions":[
73+
[]
74+
]
75+
"profiles":[
76+
{
77+
"key": "xxx",
78+
"reference": "xxx",
79+
...
80+
},
81+
...
82+
]
83+
}
84+
}
85+
- Error response : (if the source_key is not valid)
86+
{
87+
"code": 400,
88+
"message": "Invalid parameters. Unable to find object: source"
89+
}
90+
91+
"""
92+
93+
query_params = {
94+
"source_key": validate_key("Source", source_key, regex=KEY_REGEX),
95+
"profile_key": validate_key("Key", profile_key, regex=KEY_REGEX),
96+
"profile_reference": validate_reference(profile_reference),
97+
"source_keys": json.dumps(validate_provider_keys(source_keys)),
98+
"limit": validate_limit(limit),
99+
"page": validate_page(page),
100+
"sort_by": validate_value(sort_by, SORT_BY_VALUES, "sort by"),
101+
"order_by": validate_value(order_by, ORDER_BY_VALUES, "order by"),
102+
"created_at_min": created_at_min, # TODO validate dates format
103+
"created_at_max": created_at_max, # TODO validate dates format
104+
}
105+
106+
params = {**query_params, **kwargs}
107+
response = self.client.get("profiles/matching", params)
108+
return validate_response(response)

0 commit comments

Comments
 (0)