-
Notifications
You must be signed in to change notification settings - Fork 6.6k
migrate code from googleapis/python-talent #8499
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 59 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
1654c75
Talent v4beta1 samples [Restoring deleted branch samples] [(#3273)](h…
munkhuushmgl 9623935
chore(deps): update dependency google.cloud.talent to v0.6.1 [(#3851)…
renovate-bot dba46e3
[jobs] testing: use multiple projects [(#4068)](https://github.com/Go…
dc0b61c
cleanup(jobs): remove unnecessary code [(#4257)](https://github.com/G…
df31d90
samples: Automl table batch test [(#4267)](https://github.com/GoogleC…
munkhuushmgl 3332087
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot e8b43ee
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot ffe4a88
chore: update templates
busunkim96 5df7915
test: fix sample tests
busunkim96 7d3ab01
test: fix samples
busunkim96 a20ccd8
sample: fix parent path
busunkim96 3b5afee
feat: add v4 (#29)
busunkim96 62d5fcc
chore(deps): update dependency google.cloud.talent to v1 (#34)
renovate-bot a6bdca4
chore(deps): update dependency google.cloud.talent to v2 (#39)
renovate-bot 662e92c
chore: update templates (#58)
yoshi-automation aef3b92
chore(deps): update dependency google.cloud.talent to v2.1.0 (#69)
renovate-bot d835d0c
fix: fix retry deadlines (#73)
yoshi-automation f15df5f
chore: migrate to owl bot (#87)
parthea e2fce3a
chore: new owl bot post processor docker image (#104)
gcf-owl-bot[bot] bc8ad2b
chore(deps): update dependency pytest to v6.2.4 (#93)
renovate-bot 1b72402
feat: add Samples section to CONTRIBUTING.rst (#134)
gcf-owl-bot[bot] 9d74ba9
chore: 'requirements.txt' is not a script (#131)
tseaver 8669806
chore(deps): update dependency google.cloud.talent to v2.2.0 (#117)
renovate-bot 2604be5
chore(deps): update dependency google.cloud.talent to v2.2.1 (#141)
renovate-bot fa03a8a
chore(deps): update dependency google.cloud.talent to v2.3.0 (#144)
renovate-bot d84d336
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#145)
gcf-owl-bot[bot] a4fa582
chore: drop mention of Python 2.7 from templates (#147)
gcf-owl-bot[bot] fd3fa1e
chore: blacken samples noxfile template (#160)
gcf-owl-bot[bot] 8a5c941
chore: fail samples nox session if python version is missing (#165)
gcf-owl-bot[bot] 5ffc898
chore(python): Add kokoro configs for python 3.10 samples testing (#170)
gcf-owl-bot[bot] 9088d2e
chore(deps): update dependency pytest to v6.2.5 (#156)
renovate-bot 72dbf67
chore(deps): update dependency google.cloud.talent to v2.4.0 (#178)
renovate-bot e1560d3
chore(python): run blacken session for all directories with a noxfile…
gcf-owl-bot[bot] a4df0b1
chore(samples): Add check for tests in directory (#189)
gcf-owl-bot[bot] 01c721c
chore(python): Noxfile recognizes that tests can live in a folder (#194)
gcf-owl-bot[bot] 4a0d0b1
chore(deps): update dependency pytest to v7 (#202)
renovate-bot d85a3b7
chore(deps): update all dependencies (#204)
renovate-bot 0b56b84
chore: Adding support for pytest-xdist and pytest-parallel (#214)
gcf-owl-bot[bot] 355f5b5
chore(deps): update dependency google.cloud.talent to v2.5.1 (#217)
renovate-bot 495d369
chore(deps): update dependency pytest to v7.1.0 (#220)
renovate-bot 8528541
chore(deps): update dependency pytest to v7.1.1 (#222)
renovate-bot 29ef2b6
chore(python): use black==22.3.0 (#229)
gcf-owl-bot[bot] ba1dca0
chore(deps): update dependency google.cloud.talent to v2.5.2 (#232)
renovate-bot ebca065
chore(python): add nox session to sort python imports (#240)
gcf-owl-bot[bot] 6000b9a
chore(deps): update dependency pytest to v7.1.2 (#243)
renovate-bot e077e05
fix: require python 3.7+ (#264)
gcf-owl-bot[bot] 9c1cebd
chore(deps): update all dependencies (#255)
renovate-bot eaf5a33
chore(deps): update all dependencies (#270)
renovate-bot 0e54475
chore(deps): update dependency google-cloud-talent to v2.7.1 (#277)
renovate-bot b0e0bc8
chore(deps): update dependency pytest to v7.1.3 (#288)
renovate-bot 50eb826
chore: detect samples tests in nested directories (#292)
gcf-owl-bot[bot] 8bbb862
chore(deps): update dependency google-cloud-talent to v2.7.2 (#296)
renovate-bot e9c3dd8
chore(deps): update dependency google-cloud-talent to v2.7.3 (#299)
renovate-bot 60882d3
chore(deps): update dependency pytest to v7.2.0 (#300)
renovate-bot 08bf939
Merge remote-tracking branch 'migration/main' into python-talent-migr…
198cc16
Added fields to codeowners and blunderbuss
2324832
Merge branch 'main' into python-talent-migration
xtineskim 86d51ec
Remove noxfile
5ca757e
Merge branch 'python-talent-migration' of https://github.com/GoogleCl…
3a8078c
Merge branch 'main' into python-talent-migration
xtineskim 36d64f9
Blunderbuss edit
20c08b1
Merge branch 'python-talent-migration' of https://github.com/GoogleCl…
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/jobs.googleapis.com | ||
|
||
To run the sample, you need to have the following roles: | ||
|
||
* `Talent Solution Job Editor` | ||
* `Talent Solution Profile Editor` |
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,86 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import uuid | ||
|
||
from google.api_core.exceptions import NotFound | ||
import pytest | ||
|
||
import job_search_create_company | ||
import job_search_create_job | ||
import job_search_create_tenant | ||
import job_search_delete_company | ||
import job_search_delete_job | ||
import job_search_delete_tenant | ||
|
||
PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def tenant(): | ||
tenant_ext_unique_id = "TEST_TENANT_{}".format(uuid.uuid4()) | ||
# create a temporary tenant | ||
tenant_name = job_search_create_tenant.create_tenant( | ||
PROJECT_ID, tenant_ext_unique_id | ||
) | ||
|
||
# extract company id | ||
tenant_id = tenant_name.split("/")[-1] | ||
|
||
yield tenant_id | ||
|
||
try: | ||
job_search_delete_tenant.delete_tenant(PROJECT_ID, tenant_id) | ||
except NotFound as e: | ||
print("Ignoring NotFound upon cleanup, details: {}".format(e)) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def company(tenant): | ||
company_ext_id = "COMPANY_EXT_ID_{}".format(uuid.uuid4()) | ||
|
||
# create a temporary company | ||
company_name = job_search_create_company.create_company( | ||
PROJECT_ID, tenant, "Test Company Name", company_ext_id | ||
) | ||
|
||
# extract company id | ||
company_id = company_name.split("/")[-1] | ||
|
||
yield company_id | ||
|
||
try: | ||
job_search_delete_company.delete_company(PROJECT_ID, tenant, company_id) | ||
except NotFound as e: | ||
print("Ignoring NotFound upon cleanup, details: {}".format(e)) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def job(tenant, company): | ||
post_unique_id = "TEST_POST_{}".format(uuid.uuid4().hex)[:20] | ||
# create a temporary job | ||
job_name = job_search_create_job.create_job( | ||
PROJECT_ID, tenant, company, post_unique_id, "www.jobUrl.com" | ||
) | ||
|
||
# extract company id | ||
job_id = job_name.split("/")[-1] | ||
|
||
yield job_id | ||
|
||
try: | ||
job_search_delete_job.delete_job(PROJECT_ID, tenant, job_id) | ||
except NotFound as e: | ||
print("Ignoring NotFound upon cleanup, details: {}".format(e)) |
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,54 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START job_search_autocomplete_job_title] | ||
|
||
from google.cloud import talent_v4beta1 | ||
import six | ||
|
||
|
||
def complete_query(project_id, tenant_id, query): | ||
"""Complete job title given partial text (autocomplete)""" | ||
|
||
client = talent_v4beta1.CompletionClient() | ||
|
||
# project_id = 'Your Google Cloud Project ID' | ||
# tenant_id = 'Your Tenant ID (using tenancy is optional)' | ||
# query = '[partially typed job title]' | ||
|
||
if isinstance(project_id, six.binary_type): | ||
project_id = project_id.decode("utf-8") | ||
if isinstance(tenant_id, six.binary_type): | ||
tenant_id = tenant_id.decode("utf-8") | ||
if isinstance(query, six.binary_type): | ||
query = query.decode("utf-8") | ||
|
||
parent = f"projects/{project_id}/tenants/{tenant_id}" | ||
|
||
request = talent_v4beta1.CompleteQueryRequest( | ||
parent=parent, | ||
query=query, | ||
page_size=5, # limit for number of results | ||
language_codes=["en-US"], # language code | ||
) | ||
response = client.complete_query(request=request) | ||
for result in response.completion_results: | ||
print(f"Suggested title: {result.suggestion}") | ||
# Suggestion type is JOB_TITLE or COMPANY_TITLE | ||
print( | ||
f"Suggestion type: {talent_v4beta1.CompleteQueryRequest.CompletionType(result.type_).name}" | ||
) | ||
|
||
|
||
# [END job_search_autocomplete_job_title] |
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,25 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
import job_search_autocomplete_job_title | ||
|
||
PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
|
||
|
||
def test_autocomplete_job_title(capsys, tenant): | ||
job_search_autocomplete_job_title.complete_query(PROJECT_ID, tenant, "Software") | ||
out, _ = capsys.readouterr() | ||
assert "Suggested title:" in out |
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,133 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START job_search_batch_create_jobs] | ||
|
||
from google.cloud import talent | ||
import six | ||
|
||
|
||
def batch_create_jobs( | ||
project_id, | ||
tenant_id, | ||
company_name_one, | ||
requisition_id_one, | ||
title_one, | ||
description_one, | ||
job_application_url_one, | ||
address_one, | ||
language_code_one, | ||
company_name_two, | ||
requisition_id_two, | ||
title_two, | ||
description_two, | ||
job_application_url_two, | ||
address_two, | ||
language_code_two, | ||
): | ||
""" | ||
Batch Create Jobs | ||
|
||
Args: | ||
project_id Your Google Cloud Project ID | ||
tenant_id Identifier of the Tenant | ||
""" | ||
|
||
client = talent.JobServiceClient() | ||
|
||
# project_id = 'Your Google Cloud Project ID' | ||
# tenant_id = 'Your Tenant ID (using tenancy is optional)' | ||
# company_name_one = 'Company name, e.g. projects/your-project/companies/company-id' | ||
# requisition_id_one = 'Job requisition ID, aka Posting ID. Unique per job.' | ||
# title_one = 'Software Engineer' | ||
# description_one = 'This is a description of this <i>wonderful</i> job!' | ||
# job_application_url_one = 'https://www.example.org/job-posting/123' | ||
# address_one = '1600 Amphitheatre Parkway, Mountain View, CA 94043' | ||
# language_code_one = 'en-US' | ||
# company_name_two = 'Company name, e.g. projects/your-project/companies/company-id' | ||
# requisition_id_two = 'Job requisition ID, aka Posting ID. Unique per job.' | ||
# title_two = 'Quality Assurance' | ||
# description_two = 'This is a description of this <i>wonderful</i> job!' | ||
# job_application_url_two = 'https://www.example.org/job-posting/123' | ||
# address_two = '111 8th Avenue, New York, NY 10011' | ||
# language_code_two = 'en-US' | ||
|
||
if isinstance(project_id, six.binary_type): | ||
project_id = project_id.decode("utf-8") | ||
if isinstance(tenant_id, six.binary_type): | ||
tenant_id = tenant_id.decode("utf-8") | ||
if isinstance(company_name_one, six.binary_type): | ||
company_name_one = company_name_one.decode("utf-8") | ||
if isinstance(requisition_id_one, six.binary_type): | ||
requisition_id_one = requisition_id_one.decode("utf-8") | ||
if isinstance(title_one, six.binary_type): | ||
title_one = title_one.decode("utf-8") | ||
if isinstance(description_one, six.binary_type): | ||
description_one = description_one.decode("utf-8") | ||
if isinstance(job_application_url_one, six.binary_type): | ||
job_application_url_one = job_application_url_one.decode("utf-8") | ||
if isinstance(address_one, six.binary_type): | ||
address_one = address_one.decode("utf-8") | ||
if isinstance(language_code_one, six.binary_type): | ||
language_code_one = language_code_one.decode("utf-8") | ||
if isinstance(company_name_two, six.binary_type): | ||
company_name_two = company_name_two.decode("utf-8") | ||
if isinstance(requisition_id_two, six.binary_type): | ||
requisition_id_two = requisition_id_two.decode("utf-8") | ||
if isinstance(title_two, six.binary_type): | ||
title_two = title_two.decode("utf-8") | ||
if isinstance(description_two, six.binary_type): | ||
description_two = description_two.decode("utf-8") | ||
if isinstance(job_application_url_two, six.binary_type): | ||
job_application_url_two = job_application_url_two.decode("utf-8") | ||
if isinstance(address_two, six.binary_type): | ||
address_two = address_two.decode("utf-8") | ||
if isinstance(language_code_two, six.binary_type): | ||
language_code_two = language_code_two.decode("utf-8") | ||
parent = f"projects/{project_id}/tenants/{tenant_id}" | ||
uris = [job_application_url_one] | ||
application_info = {"uris": uris} | ||
addresses = [address_one] | ||
jobs_element = { | ||
"company": company_name_one, | ||
"requisition_id": requisition_id_one, | ||
"title": title_one, | ||
"description": description_one, | ||
"application_info": application_info, | ||
"addresses": addresses, | ||
"language_code": language_code_one, | ||
} | ||
uris_2 = [job_application_url_two] | ||
application_info_2 = {"uris": uris_2} | ||
addresses_2 = [address_two] | ||
jobs_element_2 = { | ||
"company": company_name_two, | ||
"requisition_id": requisition_id_two, | ||
"title": title_two, | ||
"description": description_two, | ||
"application_info": application_info_2, | ||
"addresses": addresses_2, | ||
"language_code": language_code_two, | ||
} | ||
jobs = [jobs_element, jobs_element_2] | ||
|
||
operation = client.batch_create_jobs(parent=parent, jobs=jobs) | ||
|
||
print("Waiting for operation to complete...") | ||
response = operation.result(90) | ||
|
||
print("Batch response: {}".format(response)) | ||
|
||
|
||
# [END job_search_batch_create_jobs] |
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.